Skip to content

Commit eb61c71

Browse files
committed
Support TARGET_CC and CC_{target}
1 parent 7bb4a65 commit eb61c71

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ jobs:
141141
apt_packages: gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
142142
check_only: true
143143
custom_env:
144-
CC: arm-linux-gnueabi-gcc
145-
CXX: arm-linux-gnueabi-g++
144+
CC_arm-unknown-linux-gnueabi: arm-linux-gnueabi-gcc
145+
CXX_arm-unknown-linux-gnueabi: arm-linux-gnueabi-g++
146146
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER: arm-linux-gnueabi-g++
147147
- thing: aarch64-linux
148148
target: aarch64-unknown-linux-gnu
@@ -151,8 +151,8 @@ jobs:
151151
apt_packages: crossbuild-essential-arm64
152152
check_only: true
153153
custom_env:
154-
CC: aarch64-linux-gnu-gcc
155-
CXX: aarch64-linux-gnu-g++
154+
CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc
155+
CXX_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++
156156
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-g++
157157
- thing: arm64-macos
158158
target: aarch64-apple-darwin

boring-sys/build/config.rs

Lines changed: 8 additions & 3 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

@@ -149,15 +152,14 @@ impl Env {
149152
let target_with_underscores = target.replace('-', "_");
150153

151154
// Logic stolen from cmake-rs.
152-
let target_var = |name: &str| {
155+
let target_only_var = |name: &str| {
153156
let kind = if host == target { "HOST" } else { "TARGET" };
154157

155-
// TODO(rmehra): look for just `name` first, as most people just set that
156158
var(&format!("{name}_{target}"))
157159
.or_else(|| var(&format!("{name}_{target_with_underscores}")))
158160
.or_else(|| var(&format!("{kind}_{name}")))
159-
.or_else(|| var(name))
160161
};
162+
let target_var = |name: &str| target_only_var(name).or_else(|| var(name));
161163

162164
let boringssl_var = |name: &str| {
163165
// The passed name is the non-fips version of the environment variable,
@@ -186,6 +188,9 @@ impl Env {
186188
android_ndk_home: target_var("ANDROID_NDK_HOME").map(Into::into),
187189
cmake_toolchain_file: target_var("CMAKE_TOOLCHAIN_FILE").map(Into::into),
188190
cpp_runtime_lib: target_var("BORING_BSSL_RUST_CPPLIB"),
191+
// matches the `cc` crate
192+
cc: target_only_var("CC"),
193+
cxx: target_only_var("CXX"),
189194
docs_rs: var("DOCS_RS").is_some(),
190195
}
191196
}

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)