Skip to content

Commit a50a39f

Browse files
committed
Support TARGET_CC and CC_{target}
1 parent 21f2885 commit a50a39f

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ jobs:
145145
apt_packages: gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
146146
check_only: true
147147
custom_env:
148-
CC: arm-linux-gnueabi-gcc
149-
CXX: arm-linux-gnueabi-g++
148+
CC_arm-unknown-linux-gnueabi: arm-linux-gnueabi-gcc
149+
CXX_arm-unknown-linux-gnueabi: arm-linux-gnueabi-g++
150150
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER: arm-linux-gnueabi-g++
151151
- thing: aarch64-linux
152152
target: aarch64-unknown-linux-gnu
@@ -155,8 +155,8 @@ jobs:
155155
apt_packages: crossbuild-essential-arm64
156156
check_only: true
157157
custom_env:
158-
CC: aarch64-linux-gnu-gcc
159-
CXX: aarch64-linux-gnu-g++
158+
CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc
159+
CXX_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++
160160
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-g++
161161
- thing: arm64-macos
162162
target: aarch64-apple-darwin

boring-sys/build/config.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ pub(crate) struct Env {
3636
pub(crate) android_ndk_home: Option<PathBuf>,
3737
pub(crate) cmake_toolchain_file: Option<PathBuf>,
3838
pub(crate) cpp_runtime_lib: Option<OsString>,
39+
/// C compiler (ignored if using FIPS)
40+
pub(crate) cc: Option<OsString>,
41+
pub(crate) cxx: Option<OsString>,
3942
pub(crate) docs_rs: bool,
4043
}
4144

@@ -146,18 +149,15 @@ impl Env {
146149
const NORMAL_PREFIX: &str = "BORING_BSSL";
147150
const FIPS_PREFIX: &str = "BORING_BSSL_FIPS";
148151

152+
let var_prefix = if host == target { "HOST" } else { "TARGET" };
149153
let target_with_underscores = target.replace('-', "_");
150154

151-
// Logic stolen from cmake-rs.
152-
let target_var = |name: &str| {
153-
let kind = if host == target { "HOST" } else { "TARGET" };
154-
155-
// TODO(rmehra): look for just `name` first, as most people just set that
155+
let target_only_var = |name: &str| {
156156
var(&format!("{name}_{target}"))
157157
.or_else(|| var(&format!("{name}_{target_with_underscores}")))
158-
.or_else(|| var(&format!("{kind}_{name}")))
159-
.or_else(|| var(name))
158+
.or_else(|| var(&format!("{var_prefix}_{name}")))
160159
};
160+
let target_var = |name: &str| target_only_var(name).or_else(|| var(name));
161161

162162
let boringssl_var = |name: &str| {
163163
// The passed name is the non-fips version of the environment variable,
@@ -186,6 +186,9 @@ impl Env {
186186
android_ndk_home: target_var("ANDROID_NDK_HOME").map(Into::into),
187187
cmake_toolchain_file: target_var("CMAKE_TOOLCHAIN_FILE").map(Into::into),
188188
cpp_runtime_lib: target_var("BORING_BSSL_RUST_CPPLIB"),
189+
// matches the `cc` crate
190+
cc: target_only_var("CC"),
191+
cxx: target_only_var("CXX"),
189192
docs_rs: var("DOCS_RS").is_some(),
190193
}
191194
}

boring-sys/build/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
216216
.define("CMAKE_ASM_COMPILER_TARGET", &config.target);
217217
}
218218

219+
if !config.features.fips {
220+
if let Some(cc) = &config.env.cc {
221+
boringssl_cmake.define("CMAKE_C_COMPILER", cc);
222+
}
223+
if let Some(cxx) = &config.env.cxx {
224+
boringssl_cmake.define("CMAKE_CXX_COMPILER", cxx);
225+
}
226+
}
227+
219228
if let Some(sysroot) = &config.env.sysroot {
220229
boringssl_cmake.define("CMAKE_SYSROOT", sysroot);
221230
}

0 commit comments

Comments
 (0)