use env variables CC or HOST_CC if specified regardless of feature

CI environments do this, such as crane + nix

and we shouldn't eat these environment variables anyways

Signed-off-by: strawberry <strawberry@pupbrain.dev>
This commit is contained in:
strawberry 2024-04-20 01:08:09 -04:00
parent 7d6eb700ca
commit 0e3c79750a
2 changed files with 14 additions and 5 deletions

View file

@ -10,7 +10,7 @@ categories = ["api-bindings", "memory-management"]
readme = "README.md"
# everything after the '+' is the latest GrapheneOS hardened_malloc repo tag
version = "0.1.1+12"
version = "0.1.2+12"
# https://github.com/GrapheneOS/hardened_malloc?tab=readme-ov-file#dependencies
# Debian stable (currently Debian 12) determines the most ancient set of supported dependencies

View file

@ -76,10 +76,19 @@ fn main() {
update_submodules();
}
let compiler = if cfg!(feature = "gcc") {
check_compiler("gcc")
} else {
check_compiler("clang")
// despite the feature selected, prefer CC or HOST_CC if in env
let compiler = match option_env!("CC") {
Some(cc) => check_compiler(cc),
None => match option_env!("HOST_CC") {
Some(cc) => check_compiler(cc),
None => {
if cfg!(feature = "gcc") {
check_compiler("gcc")
} else {
check_compiler("clang")
}
},
},
};
// "default" is hardened_malloc's default.mk. this crate's feature uses