From 6291af4e52eb96f1b56cde466a86f92c1699ec65 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Fri, 23 Mar 2018 13:49:27 -0400 Subject: [PATCH] Add -DOPENSSL_SMALL to CMake. Adding preprocessor flags requires a lot of typing in the CMake command-line (-DCMAKE_C_FLAGS=-DOPENSSL_SMALL -DCMAKE_CXX_FLAGS=-DOPENSSL_SMALL). Change-Id: Ieafc4155d656306c1f22746f780faa5c1d3e27be Reviewed-on: https://boringssl-review.googlesource.com/26784 Reviewed-by: Adam Langley Commit-Queue: Adam Langley CQ-Verified: CQ bot account: commit-bot@chromium.org --- BUILDING.md | 9 ++++++++- CMakeLists.txt | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index 46f27e3f..19dbe015 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -150,7 +150,14 @@ corresponding ARM feature. Note that if a feature is enabled in this way, but not actually supported at run-time, BoringSSL will likely crash. -# Running tests +## Binary Size + +The implementations of some algorithms require a trade-off between binary size +and performance. For instance, BoringSSL's fastest P-256 implementation uses a +148 KiB pre-computed table. To optimize instead for binary size, pass +`-DOPENSSL_SMALL=1` to CMake or define the `OPENSSL_SMALL` preprocessor symbol. + +# Running Tests There are two sets of tests: the C/C++ tests and the blackbox tests. For former are built by Ninja and can be run from the top-level directory with `go run diff --git a/CMakeLists.txt b/CMakeLists.txt index 4445b557..97ea2896 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -279,6 +279,10 @@ if(FIPS) endif() endif() +if(OPENSSL_SMALL) + add_definitions(-DOPENSSL_SMALL) +endif() + # CMake's iOS support uses Apple's multiple-architecture toolchain. It takes an # architecture list from CMAKE_OSX_ARCHITECTURES, leaves CMAKE_SYSTEM_PROCESSOR # alone, and expects all architecture-specific logic to be conditioned within