1 use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, PanicStrategy, MergeFunctions};
2 use crate::spec::abi::Abi;
4 pub fn target() -> TargetResult {
6 arch: "nvptx64".to_string(),
7 data_layout: "e-i64:64-i128:128-v16:16-v32:32-n16:32:64".to_string(),
8 llvm_target: "nvptx64-nvidia-cuda".to_string(),
10 target_os: "cuda".to_string(),
11 target_vendor: "nvidia".to_string(),
12 target_env: String::new(),
14 linker_flavor: LinkerFlavor::PtxLinker,
16 target_endian: "little".to_string(),
17 target_pointer_width: "64".to_string(),
18 target_c_int_width: "32".to_string(),
20 options: TargetOptions {
21 // The linker can be installed from `crates.io`.
22 linker: Some("rust-ptx-linker".to_string()),
24 // With `ptx-linker` approach, it can be later overriden via link flags.
25 cpu: "sm_30".to_string(),
27 // FIXME: create tests for the atomics.
28 max_atomic_width: Some(64),
30 // Unwinding on CUDA is neither feasible nor useful.
31 panic_strategy: PanicStrategy::Abort,
33 // Needed to use `dylib` and `bin` crate types and the linker.
34 dynamic_linking: true,
37 // Avoid using dylib because it contain metadata not supported
38 // by LLVM NVPTX backend.
41 // Let the `ptx-linker` to handle LLVM lowering into MC / assembly.
44 // Convinient and predicable naming scheme.
45 dll_prefix: "".to_string(),
46 dll_suffix: ".ptx".to_string(),
47 exe_suffix: ".ptx".to_string(),
49 // Disable MergeFunctions LLVM optimisation pass because it can
50 // produce kernel functions that call other kernel functions.
51 // This behavior is not supported by PTX ISA.
52 merge_functions: MergeFunctions::Disabled,
54 // FIXME: enable compilation tests for the target and
55 // create the tests for this.