rustc_target/spec/targets/nvptx64_nvidia_cuda.rs
1use crate::spec::{
2 Arch, LinkSelfContainedDefault, LinkerFlavor, MergeFunctions, Os, PanicStrategy, Target,
3 TargetMetadata, TargetOptions,
4};
5
6pub(crate) fn target() -> Target {
7 Target {
8 arch: Arch::Nvptx64,
9 data_layout: "e-p6:32:32-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64".into(),
10 llvm_target: "nvptx64-nvidia-cuda".into(),
11 metadata: TargetMetadata {
12 description: Some("--emit=asm generates PTX code that runs on NVIDIA GPUs".into()),
13 tier: Some(2),
14 host_tools: Some(false),
15 std: Some(false),
16 },
17 pointer_width: 64,
18
19 options: TargetOptions {
20 os: Os::Cuda,
21 vendor: "nvidia".into(),
22 linker_flavor: LinkerFlavor::Llbc,
23
24 // With `ptx-linker` approach, it can be later overridden via link flags.
25 cpu: "sm_30".into(),
26
27 // FIXME: create tests for the atomics.
28 max_atomic_width: Some(64),
29
30 // Unwinding on CUDA is neither feasible nor useful.
31 panic_strategy: PanicStrategy::Abort,
32
33 // Needed to use `dylib` and `bin` crate types and the linker.
34 dynamic_linking: true,
35
36 // Avoid using dylib because it contain metadata not supported
37 // by LLVM NVPTX backend.
38 only_cdylib: true,
39
40 // Let the `ptx-linker` to handle LLVM lowering into MC / assembly.
41 obj_is_bitcode: true,
42
43 // Clearly a GPU
44 is_like_gpu: true,
45
46 // Convenient and predicable naming scheme.
47 dll_prefix: "".into(),
48 dll_suffix: ".ptx".into(),
49 exe_suffix: ".ptx".into(),
50
51 // Disable MergeFunctions LLVM optimisation pass because it can
52 // produce kernel functions that call other kernel functions.
53 // This behavior is not supported by PTX ISA.
54 merge_functions: MergeFunctions::Disabled,
55
56 // The LLVM backend does not support stack canaries for this target
57 supports_stack_protector: false,
58
59 // Support using `self-contained` linkers like the llvm-bitcode-linker
60 link_self_contained: LinkSelfContainedDefault::True,
61
62 ..Default::default()
63 },
64 }
65}