HowToBuildOnARM.rst 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ===================================================================
  2. How To Build On ARM
  3. ===================================================================
  4. Introduction
  5. ============
  6. This document contains information about building/testing LLVM and
  7. Clang on an ARM machine.
  8. This document is *NOT* tailored to help you cross-compile LLVM/Clang
  9. to ARM on another architecture, for example an x86_64 machine. To find
  10. out more about cross-compiling, please check :doc:`HowToCrossCompileLLVM`.
  11. Notes On Building LLVM/Clang on ARM
  12. =====================================
  13. Here are some notes on building/testing LLVM/Clang on ARM. Note that
  14. ARM encompasses a wide variety of CPUs; this advice is primarily based
  15. on the ARMv6 and ARMv7 architectures and may be inapplicable to older chips.
  16. #. The most popular Linaro/Ubuntu OS's for ARM boards, e.g., the
  17. Pandaboard, have become hard-float platforms. There are a number of
  18. choices when using CMake. Autoconf usage is deprecated as of 3.8.
  19. Building LLVM/Clang in ``Relese`` mode is preferred since it consumes
  20. a lot less memory. Otherwise, the building process will very likely
  21. fail due to insufficient memory. It's also a lot quicker to only build
  22. the relevant back-ends (ARM and AArch64), since it's very unlikely that
  23. you'll use an ARM board to cross-compile to other arches. If you're
  24. running Compiler-RT tests, also include the x86 back-end, or some tests
  25. will fail.
  26. .. code-block:: bash
  27. cmake $LLVM_SRC_DIR -DCMAKE_BUILD_TYPE=Release \
  28. -DLLVM_TARGETS_TO_BUILD="ARM;X86;AArch64"
  29. Other options you can use are:
  30. .. code-block:: bash
  31. Use Ninja instead of Make: "-G Ninja"
  32. Build with assertions on: "-DLLVM_ENABLE_ASSERTIONS=True"
  33. Force Python2: "-DPYTHON_EXECUTABLE=/usr/bin/python2"
  34. Local (non-sudo) install path: "-DCMAKE_INSTALL_PREFIX=$HOME/llvm/instal"
  35. CPU flags: "DCMAKE_C_FLAGS=-mcpu=cortex-a15" (same for CXX_FLAGS)
  36. After that, just typing ``make -jN`` or ``ninja`` will build everything.
  37. ``make -jN check-all`` or ``ninja check-all`` will run all compiler tests. For
  38. running the test suite, please refer to :doc:`TestingGuide`.
  39. #. If you are building LLVM/Clang on an ARM board with 1G of memory or less,
  40. please use ``gold`` rather then GNU ``ld``. In any case it is probably a good
  41. idea to set up a swap partition, too.
  42. .. code-block:: bash
  43. $ sudo ln -sf /usr/bin/ld /usr/bin/ld.gold
  44. #. ARM development boards can be unstable and you may experience that cores
  45. are disappearing, caches being flushed on every big.LITTLE switch, and
  46. other similar issues. To help ease the effect of this, set the Linux
  47. scheduler to "performance" on **all** cores using this little script:
  48. .. code-block:: bash
  49. # The code below requires the package 'cpufrequtils' to be installed.
  50. for ((cpu=0; cpu<`grep -c proc /proc/cpuinfo`; cpu++)); do
  51. sudo cpufreq-set -c $cpu -g performance
  52. done
  53. Remember to turn that off after the build, or you may risk burning your
  54. CPU. Most modern kernels don't need that, so only use it if you have
  55. problems.
  56. #. Running the build on SD cards is ok, but they are more prone to failures
  57. than good quality USB sticks, and those are more prone to failures than
  58. external hard-drives (those are also a lot faster). So, at least, you
  59. should consider to buy a fast USB stick. On systems with a fast eMMC,
  60. that's a good option too.
  61. #. Make sure you have a decent power supply (dozens of dollars worth) that can
  62. provide *at least* 4 amperes, this is especially important if you use USB
  63. devices with your board. Externally powered USB/SATA harddrives are even
  64. better than having a good power supply.