rustc_target/spec/targets/nvptx64_nvidia_cuda.rs
1use crate::spec::{
2 Arch, LinkSelfContainedDefault, LinkerFlavor, MergeFunctions, 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: "cuda".into(),
21 vendor: "nvidia".into(),
22 linker_flavor: LinkerFlavor::Ptx,
23 // The linker can be installed from `crates.io`.
24 linker: Some("rust-ptx-linker".into()),
25
26 // With `ptx-linker` approach, it can be later overridden via link flags.
27 cpu: "sm_30".into(),
28
29 // FIXME: create tests for the atomics.
30 max_atomic_width: Some(64),
31
32 // Unwinding on CUDA is neither feasible nor useful.
33 panic_strategy: PanicStrategy::Abort,
34
35 // Needed to use `dylib` and `bin` crate types and the linker.
36 dynamic_linking: true,
37
38 // Avoid using dylib because it contain metadata not supported
39 // by LLVM NVPTX backend.
40 only_cdylib: true,
41
42 // Let the `ptx-linker` to handle LLVM lowering into MC / assembly.
43 obj_is_bitcode: true,
44
45 // Clearly a GPU
46 is_like_gpu: true,
47
48 // Convenient and predicable naming scheme.
49 dll_prefix: "".into(),
50 dll_suffix: ".ptx".into(),
51 exe_suffix: ".ptx".into(),
52
53 // Disable MergeFunctions LLVM optimisation pass because it can
54 // produce kernel functions that call other kernel functions.
55 // This behavior is not supported by PTX ISA.
56 merge_functions: MergeFunctions::Disabled,
57
58 // The LLVM backend does not support stack canaries for this target
59 supports_stack_protector: false,
60
61 // Support using `self-contained` linkers like the llvm-bitcode-linker
62 link_self_contained: LinkSelfContainedDefault::True,
63
64 ..Default::default()
65 },
66 }
67}