Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

BUILDING.md 6.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. To build the tests, you also need a C++ compiler with C++11 support.
  24. * [Go](https://golang.org/dl/) is required. If not found by CMake, the go
  25. executable may be configured explicitly by setting `GO_EXECUTABLE`.
  26. * To build the x86 and x86\_64 assembly, your assembler must support AVX2
  27. instructions. If using GNU binutils, you must have 2.22 or later.
  28. ## Building
  29. Using Ninja (note the 'N' is capitalized in the cmake invocation):
  30. mkdir build
  31. cd build
  32. cmake -GNinja ..
  33. ninja
  34. Using Make (does not work on Windows):
  35. mkdir build
  36. cd build
  37. cmake ..
  38. make
  39. You usually don't need to run `cmake` again after changing `CMakeLists.txt`
  40. files because the build scripts will detect changes to them and rebuild
  41. themselves automatically.
  42. Note that the default build flags in the top-level `CMakeLists.txt` are for
  43. debugging—optimisation isn't enabled. Pass `-DCMAKE_BUILD_TYPE=Release` to
  44. `cmake` to configure a release build.
  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. See [CMake's documentation](https://cmake.org/cmake/help/v3.4/manual/cmake-variables.7.html)
  57. for other variables which may be used to configure the build.
  58. ### Building for Android
  59. It's possible to build BoringSSL with the Android NDK using CMake. This has
  60. been tested with version 10d of the NDK.
  61. Unpack the Android NDK somewhere and export `ANDROID_NDK` to point to the
  62. directory. Then make a build directory as above and run CMake like this:
  63. cmake -DANDROID_ABI=armeabi-v7a \
  64. -DCMAKE_TOOLCHAIN_FILE=../third_party/android-cmake/android.toolchain.cmake \
  65. -DANDROID_NATIVE_API_LEVEL=16 \
  66. -GNinja ..
  67. Once you've run that, Ninja should produce Android-compatible binaries. You
  68. can replace `armeabi-v7a` in the above with `arm64-v8a` and use API level 21 or
  69. higher to build aarch64 binaries.
  70. For other options, see [android-cmake's documentation](./third_party/android-cmake/README.md).
  71. ## Known Limitations on Windows
  72. * Versions of CMake since 3.0.2 have a bug in its Ninja generator that causes
  73. yasm to output warnings
  74. yasm: warning: can open only one input file, only the last file will be processed
  75. These warnings can be safely ignored. The cmake bug is
  76. http://www.cmake.org/Bug/view.php?id=15253.
  77. * CMake can generate Visual Studio projects, but the generated project files
  78. don't have steps for assembling the assembly language source files, so they
  79. currently cannot be used to build BoringSSL.
  80. ## Embedded ARM
  81. ARM, unlike Intel, does not have an instruction that allows applications to
  82. discover the capabilities of the processor. Instead, the capability information
  83. has to be provided by the operating system somehow.
  84. BoringSSL will try to use `getauxval` to discover the capabilities and, failing
  85. that, will probe for NEON support by executing a NEON instruction and handling
  86. any illegal-instruction signal. But some environments don't support that sort
  87. of thing and, for them, it's possible to configure the CPU capabilities
  88. at compile time.
  89. If you define `OPENSSL_STATIC_ARMCAP` then you can define any of the following
  90. to enabling the corresponding ARM feature.
  91. * `OPENSSL_STATIC_ARMCAP_NEON` or `__ARM_NEON__` (note that the latter is set by compilers when NEON support is enabled).
  92. * `OPENSSL_STATIC_ARMCAP_AES`
  93. * `OPENSSL_STATIC_ARMCAP_SHA1`
  94. * `OPENSSL_STATIC_ARMCAP_SHA256`
  95. * `OPENSSL_STATIC_ARMCAP_PMULL`
  96. Note that if a feature is enabled in this way, but not actually supported at
  97. run-time, BoringSSL will likely crash.
  98. ## Assembling ARMv8 with Clang
  99. In order to support the ARMv8 crypto instructions, Clang requires that the
  100. architecture be `armv8-a+crypto`. However, setting that as a general build flag
  101. would allow the compiler to assume that crypto instructions are *always*
  102. supported, even without testing for them.
  103. It's possible to set the architecture in an assembly file using the `.arch`
  104. directive, but only very recent versions of Clang support this. If
  105. `BORINGSSL_CLANG_SUPPORTS_DOT_ARCH` is defined then `.arch` directives will be
  106. used with Clang, otherwise you may need to craft acceptable assembler flags.
  107. # Running tests
  108. There are two sets of tests: the C/C++ tests and the blackbox tests. For former
  109. are built by Ninja and can be run from the top-level directory with `go run
  110. util/all_tests.go`. The latter have to be run separately by running `go test`
  111. from within `ssl/test/runner`.
  112. Both sets of tests may also be run with `ninja -C build run_tests`, but CMake
  113. 3.2 or later is required to avoid Ninja's output buffering.