Comments (7)
On Ubuntu 16.04, amd64, cargo build --release
worked but cargo test --release
deterministically failed with the above error. Without going too deeply into the rabbit hole, adding -fPIC
to the compiler flags (as suggested in the error message) in boringssl/boringssl/CMakeLists.txt
and rebuilding made the tests pass:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1586d34..6cc8d5e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,7 +84,7 @@ endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CLANG)
# Note clang-cl is odd and sets both CLANG and MSVC. We base our configuration
# primarily on our normal Clang one.
- set(C_CXX_FLAGS "-Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings")
+ set(C_CXX_FLAGS "-Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings -fPIC")
if(MSVC)
# clang-cl sets different default warnings than clang. It also treats -Wall
# as -Weverything, to match MSVC. Instead -W3 is the alias for -Wall.
I noticed that -fPIC
is mentioned in a couple of other build files, but haven't tried to whether it's possible to make it appear in CMakeLists.txt
before starting the build.
from mundane.
I believe it could work on 32bit Linux distributions because of:
32bit libs are built with -fPIC
but it cannot be enabled so easily for amd64 because rypto/cipher_extra/asm/aes128gcmsiv-x86_64.pl
takes only two arguments, file format and file name.
from mundane.
@inejge Would your approach work w/o having to edit CMakeLists.txt
(or any other source file from the BoringSSL source tree)? Or do you think that's the only way of passing -fPIC
?
from mundane.
It could be done by postprocessing the build files generated by CMake.
find . -name flags.make -o -name link.txt -o -name build.ninja | xargs sed -i '/-fPIC/n; s/-Wwrite-strings/& -fPIC/'
I also made it work with a mundane
-private copy of CMakeLists.txt
. It's a bit painful, since CMake really likes relative paths and having CMakeLists.txt
in the root of the source tree:
--- boringssl/boringssl/CMakeLists.txt 2018-11-27 08:53:52.451245046 +0100
+++ boringssl/cmake/fpic/CMakeLists.txt 2018-11-27 13:56:58.918880686 +0100
@@ -9,13 +9,15 @@
# Defer enabling C and CXX languages.
project(BoringSSL NONE)
+set(ACTUAL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../boringssl)
+
if(WIN32)
# On Windows, prefer cl over gcc if both are available. By default most of
# the CMake generators prefer gcc, even on Windows.
set(CMAKE_GENERATOR_CC cl)
endif()
-include(sources.cmake)
+include(${ACTUAL_SOURCE_DIR}/sources.cmake)
enable_language(C)
enable_language(CXX)
@@ -84,7 +86,7 @@
if(CMAKE_COMPILER_IS_GNUCXX OR CLANG)
# Note clang-cl is odd and sets both CLANG and MSVC. We base our configuration
# primarily on our normal Clang one.
- set(C_CXX_FLAGS "-Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings")
+ set(C_CXX_FLAGS "-Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings -fPIC")
if(MSVC)
# clang-cl sets different default warnings than clang. It also treats -Wall
# as -Weverything, to match MSVC. Instead -W3 is the alias for -Wall.
@@ -490,10 +492,10 @@
# Add minimal googletest targets. The provided one has many side-effects, and
# googletest has a very straightforward build.
-add_library(boringssl_gtest third_party/googletest/src/gtest-all.cc)
-target_include_directories(boringssl_gtest PRIVATE third_party/googletest)
+add_library(boringssl_gtest ${ACTUAL_SOURCE_DIR}/third_party/googletest/src/gtest-all.cc)
+target_include_directories(boringssl_gtest PRIVATE ${ACTUAL_SOURCE_DIR}/third_party/googletest)
-include_directories(third_party/googletest/include)
+include_directories(${ACTUAL_SOURCE_DIR}/third_party/googletest/include)
# Declare a dummy target to build all unit tests. Test targets should inject
# themselves as dependencies next to the target definition.
@@ -508,12 +510,12 @@
add_library(crypto_test_data OBJECT crypto_test_data.cc)
-add_subdirectory(crypto)
-add_subdirectory(ssl)
-add_subdirectory(ssl/test)
-add_subdirectory(fipstools)
-add_subdirectory(tool)
-add_subdirectory(decrepit)
+add_subdirectory(${ACTUAL_SOURCE_DIR}/crypto ${CMAKE_CURRENT_BINARY_DIR}/crypto)
+add_subdirectory(${ACTUAL_SOURCE_DIR}/ssl ${CMAKE_CURRENT_BINARY_DIR}/ssl)
+add_subdirectory(${ACTUAL_SOURCE_DIR}/ssl/test ${CMAKE_CURRENT_BINARY_DIR}/ssl/test)
+add_subdirectory(${ACTUAL_SOURCE_DIR}/fipstools ${CMAKE_CURRENT_BINARY_DIR}/fipstools)
+add_subdirectory(${ACTUAL_SOURCE_DIR}/tool ${CMAKE_CURRENT_BINARY_DIR}/tool)
+add_subdirectory(${ACTUAL_SOURCE_DIR}/decrepit ${CMAKE_CURRENT_BINARY_DIR}/decrepit)
if(FUZZ)
add_subdirectory(fuzz)
For this to work, the crypto
and util
subdirectories from the BoringSSL source tree must be symlinked to boringssl/cmake/fpic
, where the modified CMakeLists.txt
resides.
from mundane.
I'm sorry for leading y'all astray. I asked one of the BoringSSL folks, and they pointed me to the CMAKE_POSITION_INDEPENDENT_CODE
variable. At least on my machine, it works if you simply pass that variable to CMake. Does this PR work for y'all?
from mundane.
Yup, the tests pass on Ubuntu 64-bit.
from mundane.
OK cool; I'll submit that.
from mundane.
Related Issues (20)
- Pin to a particular version of BoringSSL HOT 1
- In what ways does Mundane differ from ring?
- CONTRIBUTING.md: Document that you need to pull from googlesource.com HOT 2
- Eliminating build dependency on Go HOT 4
- Test BoringSSL refcounting HOT 2
- Run tests with MSan HOT 9
- Rename Signature::verify to is_valid HOT 4
- Switch to opaque error type?
- Make keys Send and Sync, remove Clone HOT 7
- Implement core::hash::Hasher for Hasher, Hmac
- Build docs.rs documentation with all features enabled HOT 1
- Document items behind feature flags HOT 5
- Support for TLS? HOT 2
- Replace "whitelist" with "allowlist" HOT 2
- Add BoringSSL exponent and modulus getters HOT 12
- Figure out coherent strategy around RSA keys
- docs.rs build fails for 0.4.4 HOT 3
- Outdated dependency for cmake HOT 10
- BoringSSL build failure with GCC > 9 HOT 6
- How can i sign the message without hashing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mundane.