blob: 5b5fbc1f8f4a7278050f0a53ad4c13ff8374d089 [file] [log] [blame]
George Landerda55ef92015-11-19 12:05:06 +00001ARM math library functions
2----------------------------
3
4This package contains a number of math functions from ARM's math library,
5as well as a build system and a test suite. In addition to the source code,
6there is also a script "remez.jl", which was used to generate coefficients
7used in the implementation of these functions (see comments in the code).
8
9Requirements: gcc >= 4.8, cmake >= 2.8, mpfr, mpc, qemu-user-static.
10
11For a native build on an AArch64 platform, everything (including tests) should
12work out-of the box, assuming the system compiler is a recent gcc. Simply follow
13the instructions below to configure the build using cmake (leaving out the
14-DCMAKE_TOOLCHAIN_FILE argument).
15
16Cross builds are supported for Linux hosts. First, install the required
17packages to build and run the tests on your distro of choice:
18# apt-get install qemu-user-static gcc-aarch64-linux-gnu libmpfr-dev \
19 libmpc-dev cmake
20
21You could also use a custom aarch64-linux-gnu-gcc cross toolchain, e.g. from
22Linaro, if your system doesn't provide one:
23
24https://releases.linaro.org/15.02/components/toolchain/binaries/
25
26The build script will build both a shared and a static math library object
27containing the ARM functions for the specified target, a host-side application
28rtest that generates test cases, and a target-side application mathtest that is
29linked against the math library and actually executes the tests.
30
31Generally, the steps to build and run the tests are:
32
33mkdir -p /my/build/folder && cd /my/build/folder
34cmake /path/to/src -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain/file
35make
36make check
37
38The toolchain file specifies the paths to the cross-compiler, i.e.
39aarch64-linux-gnu-gcc, as well as the sysroot parameter for the build. An
40example can be found in toolchain-gcc.cmake, which assumes that you have
41the cross toolchain installed in /usr/bin and the sysroot is
42/usr/aarch64-linux-gnu respectively. This should work with the Ubuntu packages
43suggested above as-is. Edit the paths as necessary if your cross toolchain
44lives somewhere else. Alternatively, you can specify the necessary parameters
45from the toolchain file directly on the command line.
46
47The files are built in the build directory as follows:
48build/
49 bin/
50 rtest
51 mathtest
52 runtest.sh
53 lib/
54 libmathlib.so
55 libmathlib_static.a
56 include/
57 arm_math.h
58
59It is possible to specify which emulator to use for the execution of the tests
60in the cross compilation case by specifying the following option:
61cmake (...) -DCMAKE_CROSSCOMPILING_EMULATOR=/path/to/your/emulator
62By default, qemu-aarch64-static will be used, so this has to be on your path
63if you want to cross-run the test suite.
64
65Whenever the CMake configuration is changed, it is wise to delete the whole
66build folder instead of just rerunning CMake inside the existing folder.
67
68The build system also has experimental support for using clang as the cross
69compiler.
70!!!You need CMake >= 3.0 and clang >= 3.5.0 for this!!!
71Before compilation, apply the source patch in the patches/ folder to make sure
72everything works properly when compiled with clang. There is a sample toolchain
73file for clang included as toolchain-clang.cmake.