Make Go an optional build dependency for the CMake build

Matching the various pre-generated builds, the CMake build no longer
actually requires Go. The only things that need it are:

- Running tests
- Builds with -DFIPS=1
- Builds with the experimental symbol prefixing thing

Bug: 542
Change-Id: I52bb427f54dd6e5719cfe77773e87fc394410380
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/67367
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin
2024-03-29 17:42:29 +00:00
committed by Boringssl LUCI CQ
parent 779d01dcdd
commit dfcaaddcb9
3 changed files with 46 additions and 28 deletions
+12 -9
View File
@@ -31,14 +31,6 @@ most recent stable version of each tool.
GCC (6.1+) and Clang should work on non-Windows platforms, and maybe on
Windows too.
* The most recent stable version of [Go](https://golang.org/dl/) is required.
Note Go is exempt from the five year support window. If not found by CMake,
the go executable may be configured explicitly by setting `GO_EXECUTABLE`.
* On x86_64 Linux, the tests have an optional
[libunwind](https://www.nongnu.org/libunwind/) dependency to test the
assembly more thoroughly.
## Building
Using Ninja (note the 'N' is capitalized in the cmake invocation):
@@ -127,7 +119,8 @@ supported.
BoringSSL's build system has experimental support for adding a custom prefix to
all symbols. This can be useful when linking multiple versions of BoringSSL in
the same project to avoid symbol conflicts.
the same project to avoid symbol conflicts. Symbol prefixing requires the most
recent stable version of [Go](https://go.dev/).
In order to build with prefixed symbols, the `BORINGSSL_PREFIX` CMake variable
should specify the prefix to add to all symbols, and the
@@ -195,6 +188,16 @@ and performance. For instance, BoringSSL's fastest P-256 implementation uses a
# Running Tests
There are two additional dependencies for running tests:
* The most recent stable version of [Go](https://go.dev/) is required.
Note Go is exempt from the five year support window. If not found by CMake,
the go executable may be configured explicitly by setting `GO_EXECUTABLE`.
* On x86_64 Linux, the tests have an optional
[libunwind](https://www.nongnu.org/libunwind/) dependency to test the
assembly more thoroughly.
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
util/all_tests.go`. The latter have to be run separately by running `go test`
+25 -16
View File
@@ -59,6 +59,7 @@ foreach(VAR CMAKE_C_FLAGS CMAKE_CXX_FLAGS CMAKE_ASM_FLAGS)
endforeach()
if(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_SYMBOLS)
require_go()
add_definitions(-DBORINGSSL_PREFIX=${BORINGSSL_PREFIX})
# CMake automatically connects include_directories to the NASM command-line,
# but not add_definitions.
@@ -309,6 +310,7 @@ if(GCOV)
endif()
if(FIPS)
require_go()
add_definitions(-DBORINGSSL_FIPS)
if(FIPS_BREAK_TEST)
add_definitions("-DBORINGSSL_FIPS_BREAK_${FIPS_BREAK_TEST}=1")
@@ -726,22 +728,29 @@ file(STRINGS util/go_tests.txt GO_TESTS)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
util/go_tests.txt)
add_custom_target(
run_tests
COMMAND ${CMAKE_COMMAND} -E echo "Running Go tests"
COMMAND ${GO_EXECUTABLE} test ${GO_TESTS}
COMMAND ${CMAKE_COMMAND} -E echo
COMMAND ${CMAKE_COMMAND} -E echo "Running unit tests"
COMMAND ${GO_EXECUTABLE} run util/all_tests.go -build-dir
${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E echo
COMMAND ${CMAKE_COMMAND} -E echo "Running SSL tests"
COMMAND cd ssl/test/runner &&
${GO_EXECUTABLE} test -shim-path $<TARGET_FILE:bssl_shim>
${HANDSHAKER_ARGS} ${RUNNER_ARGS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS all_tests bssl_shim handshaker fips_specific_tests_if_any
USES_TERMINAL)
if(GO_EXECUTABLE)
add_custom_target(
run_tests
COMMAND ${CMAKE_COMMAND} -E echo "Running Go tests"
COMMAND ${GO_EXECUTABLE} test ${GO_TESTS}
COMMAND ${CMAKE_COMMAND} -E echo
COMMAND ${CMAKE_COMMAND} -E echo "Running unit tests"
COMMAND ${GO_EXECUTABLE} run util/all_tests.go -build-dir
${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E echo
COMMAND ${CMAKE_COMMAND} -E echo "Running SSL tests"
COMMAND cd ssl/test/runner &&
${GO_EXECUTABLE} test -shim-path $<TARGET_FILE:bssl_shim>
${HANDSHAKER_ARGS} ${RUNNER_ARGS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS all_tests bssl_shim handshaker fips_specific_tests_if_any
USES_TERMINAL)
else()
add_custom_target(
run_tests
COMMAND ${CMAKE_COMMAND} -E echo "Running tests requires Go"
COMMAND ${CMAKE_COMMAND} -E false)
endif()
if(INSTALL_ENABLED)
# CMake versions before 3.14 do not have default destination values. Executable
+9 -3
View File
@@ -1,9 +1,15 @@
# Go is an optional dependency. It's a necessary dependency if running tests or
# the FIPS build, which will check these.
find_program(GO_EXECUTABLE go)
if(NOT GO_EXECUTABLE)
message(FATAL_ERROR "Could not find Go")
endif()
function(require_go)
if(NOT GO_EXECUTABLE)
message(FATAL_ERROR "Could not find Go")
endif()
endfunction()
function(go_executable dest package)
require_go()
set(godeps "${PROJECT_SOURCE_DIR}/util/godeps.go")
if(NOT CMAKE_GENERATOR STREQUAL "Ninja")
# The DEPFILE parameter to add_custom_command only works with Ninja. Query