Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

BUILDING.md 5.6 KiB

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