rustc_target/spec/base/
bpf.rs

1use rustc_abi::Endian;
2
3use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, TargetOptions};
4
5pub(crate) fn opts(endian: Endian) -> TargetOptions {
6    TargetOptions {
7        allow_asm: true,
8        endian,
9        linker_flavor: LinkerFlavor::Bpf,
10        atomic_cas: false,
11        dynamic_linking: true,
12        no_builtins: true,
13        panic_strategy: PanicStrategy::Abort,
14        position_independent_executables: true,
15        // Disable MergeFunctions since:
16        // - older kernels don't support bpf-to-bpf calls
17        // - on newer kernels, userspace still needs to relocate before calling
18        //   BPF_PROG_LOAD and not all BPF libraries do that yet
19        merge_functions: MergeFunctions::Disabled,
20        obj_is_bitcode: true,
21        requires_lto: false,
22        singlethread: true,
23        // When targeting the `v3` cpu in llvm, 32-bit atomics are also supported.
24        // But making this value change based on the target cpu can be mostly confusing
25        // and would require a bit of a refactor.
26        min_atomic_width: Some(64),
27        max_atomic_width: Some(64),
28        ..Default::default()
29    }
30}