Skip to content

Commit 121df8c

Browse files
authored
Merge pull request #2230 from davidben/bssl-update
Fix building with latest BoringSSL
2 parents af91e4e + dd1753f commit 121df8c

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
- false
153153
library:
154154
- name: boringssl
155-
version: e6489902b7fb692875341b8ab5e57f0515f47bc1
155+
version: 2db0eb3f96a5756298dcd7f9319e56a98585bd10
156156
- name: openssl
157157
version: vendored
158158
- name: openssl
@@ -277,7 +277,7 @@ jobs:
277277
;;
278278
"i686-unknown-linux-gnu")
279279
OS_COMPILER=linux-elf
280-
OS_FLAGS=-m32
280+
OS_FLAGS="-m32 -msse2"
281281
;;
282282
"arm-unknown-linux-gnueabihf")
283283
OS_COMPILER=linux-armv4

openssl-sys/build/main.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,34 @@ fn main() {
132132
println!("cargo:rustc-link-lib={}={}", kind, lib);
133133
}
134134

135+
// libssl in BoringSSL requires the C++ runtime, and static libraries do
136+
// not carry dependency information. On unix-like platforms, the C++
137+
// runtime and standard library are typically picked up by default via the
138+
// C++ compiler, which has a platform-specific default. (See implementations
139+
// of `GetDefaultCXXStdlibType` in Clang.) Builds may also choose to
140+
// override this and specify their own with `-nostdinc++` and `-nostdlib++`
141+
// flags. Some compilers also provide options like `-stdlib=libc++`.
142+
//
143+
// Typically, such information is carried all the way up the build graph,
144+
// but Cargo is not an integrated cross-language build system, so it cannot
145+
// safely handle any of these situations. As a result, we need to make
146+
// guesses. Getting this wrong may result in symbol conflicts and memory
147+
// errors, but this unsafety is inherent to driving builds with
148+
// externally-built libraries using Cargo.
149+
//
150+
// For now, we guess that the build was made with the defaults. This too is
151+
// difficult because Rust does not expose this information from Clang, but
152+
// try to match the behavior for common platforms. For a more robust option,
153+
// this likely needs to be deferred to the caller with an environment
154+
// variable.
155+
if version == Version::Boringssl && kind == "static" && env::var("CARGO_CFG_UNIX").is_ok() {
156+
let cpp_lib = match env::var("CARGO_CFG_TARGET_OS").unwrap().as_ref() {
157+
"macos" => "c++",
158+
_ => "stdc++",
159+
};
160+
println!("cargo:rustc-link-lib={}", cpp_lib);
161+
}
162+
135163
// https://github.com/openssl/openssl/pull/15086
136164
if version == Version::Openssl3xx
137165
&& kind == "static"

openssl/src/x509/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ fn test_verify_param_set_depth_fails_verification() {
944944
store_bldr.add_cert(ca).unwrap();
945945
let mut verify_params = X509VerifyParam::new().unwrap();
946946
// OpenSSL 1.1.0+ considers the root certificate to not be part of the chain, while 1.0.2 and LibreSSL do
947-
let expected_depth = if cfg!(any(ossl110)) { 0 } else { 1 };
947+
let expected_depth = if cfg!(any(ossl110, boringssl)) { 0 } else { 1 };
948948
verify_params.set_depth(expected_depth);
949949
store_bldr.set_param(&verify_params).unwrap();
950950
let store = store_bldr.build();

0 commit comments

Comments
 (0)