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