Skip to content

Commit

Permalink
Use Ninja for BoringSSL if available (cossacklabs#837)
Browse files Browse the repository at this point in the history
* Detect Ninja in configure

Look into the system if there is "ninja" binary available in PATH.
If there is one, note it for future use.

* Use Ninja for BoringSSL if available

Ninja build tool significantly reduces compilation time for BoringSSL in
default configuration. This is mostly due to the fact that it performs
parallel builds by default but there are other gains (Makefiles that
CMake generates are not that optimal). "make -j4" is also a viable
option, but it often ends up brittle.

* Install ninja for jobs that build BoringSSL

Make sure it's actually installed where relevant.

* Make a quick note in changelog about Ninja support
  • Loading branch information
ilammy authored May 30, 2021
1 parent e78dd5d commit 6834dbd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ jobs:
run: |
sudo sh -c 'echo "DEBIAN_FRONTEND=noninteractive" >> /etc/environment'
sudo apt update
sudo apt install --yes gcc make libssl-dev valgrind
sudo apt install --yes gcc make libssl-dev valgrind ninja-build
- name: Check out code
uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-wasm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
run: |
sudo sh -c 'echo "DEBIAN_FRONTEND=noninteractive" >> /etc/environment'
sudo apt update
sudo apt install --yes gcc make libssl-dev
sudo apt install --yes gcc make libssl-dev ninja-build
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ _Infrastructure:_
- MSYS2 builds for Windows are now checked by CI ([#791](https://github.com/cossacklabs/themis/pull/791)).
- Added automated tests for Android example project ([#813](https://github.com/cossacklabs/themis/pull/813)).
- Added automated tests for desktop Java example project ([#816](https://github.com/cossacklabs/themis/pull/816)).
- Embedded BoringSSL now builds faster if Ninja is available ([#837](https://github.com/cossacklabs/themis/pull/837)).

## [0.13.10](https://github.com/cossacklabs/themis/releases/tag/0.13.10), May 26th 2021

Expand Down
9 changes: 9 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ detect_language_runtimes() {
set_variable PYTHON3_VERSION "$(exec 2>/dev/null; which python3 >/dev/null && python3 --version)"
}

detect_optional_toolchain() {
local ninja="$(which ninja 2>/dev/null || true)"
if [ -n "$ninja" ]
then
set_variable NINJA "$ninja"
fi
}

main() {
write_boilerplate
parse_commandline "$@"
Expand All @@ -258,6 +266,7 @@ main() {
configure_macos_toolchain
find_macos_openssl
detect_language_runtimes
detect_optional_toolchain
echo "configuration written to $configure_mk"
}

Expand Down
12 changes: 12 additions & 0 deletions src/soter/boringssl/soter.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ CRYPTO_ENGINE_LDFLAGS += -lcrypto -ldecrepit -lpthread
SOTER_ENGINE_CMAKE_FLAGS += -DCMAKE_BUILD_TYPE=Release
SOTER_ENGINE_CMAKE_FLAGS += -DCMAKE_C_FLAGS="-fpic"

ifneq ($(NINJA),)
SOTER_ENGINE_CMAKE_FLAGS += -G Ninja
endif

ifdef IS_LINUX
RENAME_BORINGSSL_SYMBOLS = yes
endif
Expand All @@ -60,7 +64,11 @@ $(BIN_PATH)/boringssl/crypto/libcrypto.a $(BIN_PATH)/boringssl/decrepit/libdecre
@mkdir -p $(BIN_PATH)/boringssl/stage-1
@cd $(BIN_PATH)/boringssl/stage-1 && \
$(CMAKE) $(SOTER_ENGINE_CMAKE_FLAGS) $(abspath third_party/boringssl/src)
ifeq ($(NINJA),)
@$(MAKE) -C $(BIN_PATH)/boringssl/stage-1 crypto decrepit
else
@$(NINJA) -C $(BIN_PATH)/boringssl/stage-1 crypto decrepit
endif
@mkdir -p $(BIN_PATH)/boringssl/crypto $(BIN_PATH)/boringssl/decrepit
@cp $(BIN_PATH)/boringssl/stage-1/crypto/libcrypto.a $(BIN_PATH)/boringssl/crypto/libcrypto.a
@cp $(BIN_PATH)/boringssl/stage-1/decrepit/libdecrepit.a $(BIN_PATH)/boringssl/decrepit/libdecrepit.a
Expand All @@ -78,7 +86,11 @@ ifeq ($(RENAME_BORINGSSL_SYMBOLS),yes)
-DBORINGSSL_PREFIX=$(SOTER_BORINGSSL_PREFIX) \
-DBORINGSSL_PREFIX_SYMBOLS=../symbols.txt \
$(abspath third_party/boringssl/src)
ifeq ($(NINJA),)
@$(MAKE) -C $(BIN_PATH)/boringssl/stage-2 crypto decrepit
else
@$(NINJA) -C $(BIN_PATH)/boringssl/stage-2 crypto decrepit
endif
@mkdir -p $(BIN_PATH)/boringssl/crypto $(BIN_PATH)/boringssl/decrepit
@cp $(BIN_PATH)/boringssl/stage-2/crypto/libcrypto.a $(BIN_PATH)/boringssl/crypto/libcrypto.a
@cp $(BIN_PATH)/boringssl/stage-2/decrepit/libdecrepit.a $(BIN_PATH)/boringssl/decrepit/libdecrepit.a
Expand Down

0 comments on commit 6834dbd

Please sign in to comment.