summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs')
-rw-r--r--compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs b/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs
new file mode 100644
index 000000000..1c5b68001
--- /dev/null
+++ b/compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs
@@ -0,0 +1,53 @@
+use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, Target, TargetOptions};
+
+pub fn target() -> Target {
+ Target {
+ arch: "nvptx64".into(),
+ data_layout: "e-i64:64-i128:128-v16:16-v32:32-n16:32:64".into(),
+ llvm_target: "nvptx64-nvidia-cuda".into(),
+ pointer_width: 64,
+
+ options: TargetOptions {
+ os: "cuda".into(),
+ vendor: "nvidia".into(),
+ linker_flavor: LinkerFlavor::PtxLinker,
+ // The linker can be installed from `crates.io`.
+ linker: Some("rust-ptx-linker".into()),
+ linker_is_gnu: false,
+
+ // With `ptx-linker` approach, it can be later overridden via link flags.
+ cpu: "sm_30".into(),
+
+ // FIXME: create tests for the atomics.
+ max_atomic_width: Some(64),
+
+ // Unwinding on CUDA is neither feasible nor useful.
+ panic_strategy: PanicStrategy::Abort,
+
+ // Needed to use `dylib` and `bin` crate types and the linker.
+ dynamic_linking: true,
+
+ // Avoid using dylib because it contain metadata not supported
+ // by LLVM NVPTX backend.
+ only_cdylib: true,
+
+ // Let the `ptx-linker` to handle LLVM lowering into MC / assembly.
+ obj_is_bitcode: true,
+
+ // Convenient and predicable naming scheme.
+ dll_prefix: "".into(),
+ dll_suffix: ".ptx".into(),
+ exe_suffix: ".ptx".into(),
+
+ // Disable MergeFunctions LLVM optimisation pass because it can
+ // produce kernel functions that call other kernel functions.
+ // This behavior is not supported by PTX ISA.
+ merge_functions: MergeFunctions::Disabled,
+
+ // The LLVM backend does not support stack canaries for this target
+ supports_stack_protector: false,
+
+ ..Default::default()
+ },
+ }
+}