You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BUILDING.md 5.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. # Building BoringSSL
  2. ## Build Prerequisites
  3. * [CMake](http://www.cmake.org/download/) 2.8.8 or later is required.
  4. * Perl 5.6.1 or later is required. On Windows,
  5. [Strawberry Perl](http://strawberryperl.com/) and MSYS Perl have both been
  6. reported to work. If not found by CMake, it may be configured explicitly by
  7. setting `PERL_EXECUTABLE`.
  8. * On Windows you currently must use [Ninja](https://martine.github.io/ninja/)
  9. to build; on other platforms, it is not required, but recommended, because
  10. it makes builds faster.
  11. * If you need to build Ninja from source, then a recent version of
  12. [Python](https://www.python.org/downloads/) is required (Python 2.7.5 works).
  13. * On Windows only, [Yasm](http://yasm.tortall.net/) is required. If not found
  14. by CMake, it may be configured explicitly by setting
  15. `CMAKE_ASM_NASM_COMPILER`.
  16. * A C compiler is required. On Windows, MSVC 12 (Visual Studio 2013) or later
  17. with Platform SDK 8.1 or later are supported. Recent versions of GCC and
  18. Clang should work on non-Windows platforms, and maybe on Windows too.
  19. * [Go](https://golang.org/dl/) is required. If not found by CMake, the go
  20. executable may be configured explicitly by setting `GO_EXECUTABLE`.
  21. * If you change crypto/chacha/chacha\_vec.c, you will need the
  22. arm-linux-gnueabihf-gcc compiler:
  23. ```
  24. wget https://releases.linaro.org/14.11/components/toolchain/binaries/arm-linux-gnueabihf/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar.xz && \
  25. echo bc4ca2ced084d2dc12424815a4442e19cb1422db87068830305d90075feb1a3b gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar.xz | sha256sum -c && \
  26. tar xf gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar.xz && \
  27. sudo mv gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf /opt/
  28. ```
  29. ## Building
  30. Using Ninja (note the 'N' is capitalized in the cmake invocation):
  31. mkdir build
  32. cd build
  33. cmake -GNinja ..
  34. ninja
  35. Using Make (does not work on Windows):
  36. mkdir build
  37. cd build
  38. cmake ..
  39. make
  40. You usually don't need to run `cmake` again after changing `CMakeLists.txt`
  41. files because the build scripts will detect changes to them and rebuild
  42. themselves automatically.
  43. Note that the default build flags in the top-level `CMakeLists.txt` are for
  44. debugging—optimisation isn't enabled.
  45. If you want to cross-compile then there is an example toolchain file for 32-bit
  46. Intel in `util/`. Wipe out the build directory, recreate it and run `cmake` like
  47. this:
  48. cmake -DCMAKE_TOOLCHAIN_FILE=../util/32-bit-toolchain.cmake -GNinja ..
  49. If you want to build as a shared library, pass `-DBUILD_SHARED_LIBS=1`. On
  50. Windows, where functions need to be tagged with `dllimport` when coming from a
  51. shared library, define `BORINGSSL_SHARED_LIBRARY` in any code which `#include`s
  52. the BoringSSL headers.
  53. In order to serve environments where code-size is important as well as those
  54. where performance is the overriding concern, `OPENSSL_SMALL` can be defined to
  55. remove some code that is especially large.
  56. ### Building for Android
  57. It's possible to build BoringSSL with the Android NDK using CMake. This has
  58. been tested with version 10d of the NDK.
  59. Unpack the Android NDK somewhere and export `ANDROID_NDK` to point to the
  60. directory. Clone https://github.com/taka-no-me/android-cmake into `util/`. Then
  61. make a build directory as above and run CMake *twice* like this:
  62. cmake -DANDROID_NATIVE_API_LEVEL=android-9 \
  63. -DANDROID_ABI=armeabi-v7a \
  64. -DCMAKE_TOOLCHAIN_FILE=../util/android-cmake/android.toolchain.cmake \
  65. -DANDROID_NATIVE_API_LEVEL=16 \
  66. -GNinja ..
  67. Once you've run that twice, Ninja should produce Android-compatible binaries.
  68. You can replace `armeabi-v7a` in the above with `arm64-v8a` to build aarch64
  69. binaries.
  70. ## Known Limitations on Windows
  71. * Versions of CMake since 3.0.2 have a bug in its Ninja generator that causes
  72. yasm to output warnings
  73. yasm: warning: can open only one input file, only the last file will be processed
  74. These warnings can be safely ignored. The cmake bug is
  75. http://www.cmake.org/Bug/view.php?id=15253.
  76. * CMake can generate Visual Studio projects, but the generated project files
  77. don't have steps for assembling the assembly language source files, so they
  78. currently cannot be used to build BoringSSL.
  79. ## Embedded ARM
  80. ARM, unlike Intel, does not have an instruction that allows applications to
  81. discover the capabilities of the processor. Instead, the capability information
  82. has to be provided by the operating system somehow.
  83. BoringSSL will try to use `getauxval` to discover the capabilities and, failing
  84. that, will probe for NEON support by executing a NEON instruction and handling
  85. any illegal-instruction signal. But some environments don't support that sort
  86. of thing and, for them, it's possible to configure the CPU capabilities
  87. at compile time.
  88. If you define `OPENSSL_STATIC_ARMCAP` then you can define any of the following
  89. to enabling the corresponding ARM feature.
  90. * `OPENSSL_STATIC_ARMCAP_NEON` or `__ARM_NEON__` (note that the latter is set by compilers when NEON support is enabled).
  91. * `OPENSSL_STATIC_ARMCAP_AES`
  92. * `OPENSSL_STATIC_ARMCAP_SHA1`
  93. * `OPENSSL_STATIC_ARMCAP_SHA256`
  94. * `OPENSSL_STATIC_ARMCAP_PMULL`
  95. Note that if a feature is enabled in this way, but not actually supported at
  96. run-time, BoringSSL will likely crash.
  97. # Running tests
  98. There are two sets of tests: the C/C++ tests and the blackbox tests. For former
  99. are built by Ninja and can be run from the top-level directory with `go run
  100. util/all_tests.go`. The latter have to be run separately by running `go test`
  101. from within `ssl/test/runner`.
  102. Both sets of tests may also be run with `ninja -C build run_tests`, but CMake
  103. 3.2 or later is required to avoid Ninja's output buffering.