Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

BUILDING.md 8.0 KiB

Do a cursory conversion of a few tests to GTest. For now, this is the laziest conversion possible. The intent is to just get the build setup ready so that we can get everything working in our consumers. The intended end state is: - The standalone build produces three test targets, one per library: {crypto,ssl,decrepit}_tests. - Each FOO_test is made up of: FOO/**/*_test.cc crypto/test/gtest_main.cc test_support - generate_build_files.py emits variables crypto_test_sources and ssl_test_sources. These variables are populated with FindCFiles, looking for *_test.cc. - The consuming file assembles those variables into the two test targets (plus decrepit) from there. This avoids having generate_build_files.py emit actual build rules. - Our standalone builders, Chromium, and Android just run the top-level test targets using whatever GTest-based reporting story they have. In transition, we start by converting one of two tests in each library to populate the three test targets. Those are added to all_tests.json and all_tests.go hacked to handle them transparently. This keeps our standalone builder working. generate_build_files.py, to start with, populates the new source lists manually and subtracts them out of the old machinery. We emit both for the time being. When this change rolls in, we'll write all the build glue needed to build the GTest-based tests and add it to consumers' continuous builders. Next, we'll subsume a file-based test and get the consumers working with that. (I.e. make sure the GTest targets can depend on a data file.) Once that's all done, we'll be sure all this will work. At that point, we start subsuming the remaining tests into the GTest targets and, asynchronously, rewriting tests to use GTest properly rather than cursory conversion here. When all non-GTest tests are gone, the old generate_build_files.py hooks will be removed, consumers updated to not depend on them, and standalone builders converted to not rely on all_tests.go, which can then be removed. (Unless bits end up being needed as a malloc test driver. I'm thinking we'll want to do something with --gtest_filter.) As part of this CL, I've bumped the CMake requirements (for target_include_directories) and added a few suppressions for warnings that GTest doesn't pass. BUG=129 Change-Id: I881b26b07a8739cc0b52dbb51a30956908e1b71a Reviewed-on: https://boringssl-review.googlesource.com/13232 Reviewed-by: Adam Langley <agl@google.com>
7 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. # Building BoringSSL
  2. ## Build Prerequisites
  3. * [CMake](https://cmake.org/download/) 2.8.11 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. * The most recent stable version of [Go](https://golang.org/dl/) is required.
  25. If not found by CMake, the go executable may be configured explicitly by
  26. setting `GO_EXECUTABLE`.
  27. * To build the x86 and x86\_64 assembly, your assembler must support AVX2
  28. instructions and MOVBE. If using GNU binutils, you must have 2.22 or later
  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. Pass `-DCMAKE_BUILD_TYPE=Release` to
  45. `cmake` to configure a release build.
  46. If you want to cross-compile then there is an example toolchain file for 32-bit
  47. Intel in `util/`. Wipe out the build directory, recreate it and run `cmake` like
  48. this:
  49. cmake -DCMAKE_TOOLCHAIN_FILE=../util/32-bit-toolchain.cmake -GNinja ..
  50. If you want to build as a shared library, pass `-DBUILD_SHARED_LIBS=1`. On
  51. Windows, where functions need to be tagged with `dllimport` when coming from a
  52. shared library, define `BORINGSSL_SHARED_LIBRARY` in any code which `#include`s
  53. the BoringSSL headers.
  54. In order to serve environments where code-size is important as well as those
  55. where performance is the overriding concern, `OPENSSL_SMALL` can be defined to
  56. remove some code that is especially large.
  57. See [CMake's documentation](https://cmake.org/cmake/help/v3.4/manual/cmake-variables.7.html)
  58. for other variables which may be used to configure the build.
  59. ### Building for Android
  60. It's possible to build BoringSSL with the Android NDK using CMake. Recent
  61. versions of the NDK include a CMake toolchain file which works with CMake 3.6.0
  62. or later. This has been tested with version r16b of the NDK.
  63. Unpack the Android NDK somewhere and export `ANDROID_NDK` to point to the
  64. directory. Then make a build directory as above and run CMake like this:
  65. cmake -DANDROID_ABI=armeabi-v7a \
  66. -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
  67. -DANDROID_NATIVE_API_LEVEL=16 \
  68. -GNinja ..
  69. Once you've run that, Ninja should produce Android-compatible binaries. You
  70. can replace `armeabi-v7a` in the above with `arm64-v8a` and use API level 21 or
  71. higher to build aarch64 binaries.
  72. For older NDK versions, BoringSSL ships a third-party CMake toolchain file. Use
  73. `../third_party/android-cmake/android.toolchain.cmake` for
  74. `CMAKE_TOOLCHAIN_FILE` instead.
  75. For other options, see the documentation in the toolchain file.
  76. ### Building for iOS
  77. To build for iOS, pass `-DCMAKE_OSX_SYSROOT=iphoneos` and
  78. `-DCMAKE_OSX_ARCHITECTURES=ARCH` to CMake, where `ARCH` is the desired
  79. architecture, matching values used in the `-arch` flag in Apple's toolchain.
  80. Passing multiple architectures for a multiple-architecture build is not
  81. supported.
  82. ### Building with Prefixed Symbols
  83. BoringSSL's build system has experimental support for adding a custom prefix to
  84. all symbols. This can be useful when linking multiple versions of BoringSSL in
  85. the same project to avoid symbol conflicts.
  86. In order to build with prefixed symbols, the `BORINGSSL_PREFIX` CMake variable
  87. should specify the prefix to add to all symbols, and the
  88. `BORINGSSL_PREFIX_SYMBOLS` CMake variable should specify the path to a file
  89. which contains a list of symbols which should be prefixed (one per line;
  90. comments are supported with `#`). In other words, `cmake ..
  91. -DBORINGSSL_PREFIX=MY_CUSTOM_PREFIX
  92. -DBORINGSSL_PREFIX_SYMBOLS=/path/to/symbols.txt` will configure the build to add
  93. the prefix `MY_CUSTOM_PREFIX` to all of the symbols listed in
  94. `/path/to/symbols.txt`.
  95. It is currently the caller's responsibility to create and maintain the list of
  96. symbols to be prefixed. Alternatively, `util/read_symbols.go` reads the list of
  97. exported symbols from a `.a` file, and can be used in a build script to generate
  98. the symbol list on the fly (by building without prefixing, using
  99. `read_symbols.go` to construct a symbol list, and then building again with
  100. prefixing).
  101. This mechanism is under development and may change over time. Please contact the
  102. BoringSSL maintainers if making use of it.
  103. ## Known Limitations on Windows
  104. * Versions of CMake since 3.0.2 have a bug in its Ninja generator that causes
  105. yasm to output warnings
  106. yasm: warning: can open only one input file, only the last file will be processed
  107. These warnings can be safely ignored. The cmake bug is
  108. http://www.cmake.org/Bug/view.php?id=15253.
  109. * CMake can generate Visual Studio projects, but the generated project files
  110. don't have steps for assembling the assembly language source files, so they
  111. currently cannot be used to build BoringSSL.
  112. ## Embedded ARM
  113. ARM, unlike Intel, does not have an instruction that allows applications to
  114. discover the capabilities of the processor. Instead, the capability information
  115. has to be provided by the operating system somehow.
  116. By default, on Linux-based systems, BoringSSL will try to use `getauxval` and
  117. `/proc` to discover the capabilities. But some environments don't support that
  118. sort of thing and, for them, it's possible to configure the CPU capabilities at
  119. compile time.
  120. On iOS or builds which define `OPENSSL_STATIC_ARMCAP`, features will be
  121. determined based on the `__ARM_NEON__` and `__ARM_FEATURE_CRYPTO` preprocessor
  122. symbols reported by the compiler. These values are usually controlled by the
  123. `-march` flag. You can also define any of the following to enable the
  124. corresponding ARM feature.
  125. * `OPENSSL_STATIC_ARMCAP_NEON`
  126. * `OPENSSL_STATIC_ARMCAP_AES`
  127. * `OPENSSL_STATIC_ARMCAP_SHA1`
  128. * `OPENSSL_STATIC_ARMCAP_SHA256`
  129. * `OPENSSL_STATIC_ARMCAP_PMULL`
  130. Note that if a feature is enabled in this way, but not actually supported at
  131. run-time, BoringSSL will likely crash.
  132. ## Binary Size
  133. The implementations of some algorithms require a trade-off between binary size
  134. and performance. For instance, BoringSSL's fastest P-256 implementation uses a
  135. 148 KiB pre-computed table. To optimize instead for binary size, pass
  136. `-DOPENSSL_SMALL=1` to CMake or define the `OPENSSL_SMALL` preprocessor symbol.
  137. # Running Tests
  138. There are two sets of tests: the C/C++ tests and the blackbox tests. For former
  139. are built by Ninja and can be run from the top-level directory with `go run
  140. util/all_tests.go`. The latter have to be run separately by running `go test`
  141. from within `ssl/test/runner`.
  142. Both sets of tests may also be run with `ninja -C build run_tests`, but CMake
  143. 3.2 or later is required to avoid Ninja's output buffering.