|
|
|
@ -202,14 +202,13 @@ impl<'a> Toolchain<'a> {
|
|
|
|
|
|
|
|
|
|
|
|
/// Emit cfg flags that describe the desired BPF target architecture.
|
|
|
|
/// Emit cfg flags that describe the desired BPF target architecture.
|
|
|
|
pub fn emit_bpf_target_arch_cfg() {
|
|
|
|
pub fn emit_bpf_target_arch_cfg() {
|
|
|
|
const RUSTFLAGS: &str = "CARGO_ENCODED_RUSTFLAGS";
|
|
|
|
// The presence of this environment variable indicates that `--cfg
|
|
|
|
|
|
|
|
// bpf_target_arch="..."` was passed to the compiler, so we don't need to
|
|
|
|
println!("cargo:rerun-if-env-changed={RUSTFLAGS}");
|
|
|
|
// emit it again. Note that we cannot *set* this environment variable - it
|
|
|
|
let rustc_cfgs = std::env::var_os(RUSTFLAGS).unwrap_or_else(|| panic!("{RUSTFLAGS} not set"));
|
|
|
|
// is set by cargo.
|
|
|
|
let rustc_cfgs = rustc_cfgs
|
|
|
|
const BPF_TARGET_ARCH: &str = "CARGO_CFG_BPF_TARGET_ARCH";
|
|
|
|
.to_str()
|
|
|
|
println!("cargo:rerun-if-env-changed={BPF_TARGET_ARCH}");
|
|
|
|
.unwrap_or_else(|| panic!("{RUSTFLAGS}={rustc_cfgs:?} not unicode"));
|
|
|
|
if std::env::var_os(BPF_TARGET_ARCH).is_none() {
|
|
|
|
if !rustc_cfgs.contains("bpf_target_arch") {
|
|
|
|
|
|
|
|
let bpf_target_arch = target_arch();
|
|
|
|
let bpf_target_arch = target_arch();
|
|
|
|
println!("cargo:rustc-cfg=bpf_target_arch=\"{bpf_target_arch}\"");
|
|
|
|
println!("cargo:rustc-cfg=bpf_target_arch=\"{bpf_target_arch}\"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|