about summary refs log tree commit diff
path: root/compiler/rustc_target/src/spec/base/bpf.rs
diff options
context:
space:
mode:
authorDavid Wood <david.wood@huawei.com>2023-11-08 14:15:26 +0800
committerDavid Wood <david.wood@huawei.com>2023-11-08 14:15:26 +0800
commit76aa83e3e13bf23168389699ca69c59d7a79a336 (patch)
tree54205a5e9157d87c1e4c0a034053519c8a522295 /compiler/rustc_target/src/spec/base/bpf.rs
parent0d5ec963bb9f3e481bca1d0149d26f1688784341 (diff)
downloadrust-76aa83e3e13bf23168389699ca69c59d7a79a336.tar.gz
rust-76aa83e3e13bf23168389699ca69c59d7a79a336.zip
target: move base specs to spec/base
Signed-off-by: David Wood <david@davidtw.co>
Diffstat (limited to 'compiler/rustc_target/src/spec/base/bpf.rs')
-rw-r--r--compiler/rustc_target/src/spec/base/bpf.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/spec/base/bpf.rs b/compiler/rustc_target/src/spec/base/bpf.rs
new file mode 100644
index 00000000000..4d03747d016
--- /dev/null
+++ b/compiler/rustc_target/src/spec/base/bpf.rs
@@ -0,0 +1,29 @@
+use crate::abi::Endian;
+use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, TargetOptions};
+
+pub fn opts(endian: Endian) -> TargetOptions {
+    TargetOptions {
+        allow_asm: true,
+        endian,
+        linker_flavor: LinkerFlavor::Bpf,
+        atomic_cas: false,
+        dynamic_linking: true,
+        no_builtins: true,
+        panic_strategy: PanicStrategy::Abort,
+        position_independent_executables: true,
+        // Disable MergeFunctions since:
+        // - older kernels don't support bpf-to-bpf calls
+        // - on newer kernels, userspace still needs to relocate before calling
+        //   BPF_PROG_LOAD and not all BPF libraries do that yet
+        merge_functions: MergeFunctions::Disabled,
+        obj_is_bitcode: true,
+        requires_lto: false,
+        singlethread: true,
+        // When targeting the `v3` cpu in llvm, 32-bit atomics are also supported.
+        // But making this value change based on the target cpu can be mostly confusing
+        // and would require a bit of a refactor.
+        min_atomic_width: Some(64),
+        max_atomic_width: Some(64),
+        ..Default::default()
+    }
+}