Skip to content

Commit 3a52529

Browse files
author
Kjetil Kjeka
committed
Nvptx: Use llbc as default linker
1 parent c0ff72f commit 3a52529

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2791,11 +2791,13 @@ impl Target {
27912791
matches!(self.linker_flavor, LinkerFlavor::Bpf),
27922792
"`linker_flavor` must be `bpf` if and only if `arch` is `bpf`"
27932793
);
2794-
check_eq!(
2795-
self.arch == Arch::Nvptx64,
2796-
matches!(self.linker_flavor, LinkerFlavor::Ptx),
2797-
"`linker_flavor` must be `ptc` if and only if `arch` is `nvptx64`"
2798-
);
2794+
if self.arch == Arch::Nvptx64 {
2795+
check_matches!(
2796+
self.linker_flavor,
2797+
LinkerFlavor::Llbc,
2798+
"`linker_flavor` must be `llbc` if `arch` is `nvptx64`"
2799+
);
2800+
}
27992801

28002802
for args in [
28012803
&self.pre_link_args,

compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ pub(crate) fn target() -> Target {
1919
options: TargetOptions {
2020
os: "cuda".into(),
2121
vendor: "nvidia".into(),
22-
linker_flavor: LinkerFlavor::Ptx,
23-
// The linker can be installed from `crates.io`.
24-
linker: Some("rust-ptx-linker".into()),
22+
linker_flavor: LinkerFlavor::Llbc,
2523

2624
// With `ptx-linker` approach, it can be later overridden via link flags.
2725
cpu: "sm_30".into(),

src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ platform.
1212

1313
## Requirements
1414

15-
This target is `no_std` and will typically be built with crate-type `cdylib` and `-C linker-flavor=llbc`, which generates PTX.
15+
This target is `no_std` using `llvm-bitcode-linker` by default. For PTX output, build with crate-type `cdylib`.
1616
The necessary components for this workflow are:
1717

1818
- `rustup toolchain add nightly`
@@ -38,7 +38,7 @@ While the compiler accepts `#[target_feature(enable = "ptx80", enable = "sm_89")
3838
A `no_std` crate containing one or more functions with `extern "ptx-kernel"` can be compiled to PTX using a command like the following.
3939

4040
```console
41-
$ RUSTFLAGS='-Ctarget-cpu=sm_89' cargo +nightly rustc --target=nvptx64-nvidia-cuda -Zbuild-std=core --crate-type=cdylib -- -Clinker-flavor=llbc -Zunstable-options
41+
$ RUSTFLAGS='-Ctarget-cpu=sm_89' cargo +nightly rustc --target=nvptx64-nvidia-cuda -Zbuild-std=core --crate-type=cdylib
4242
```
4343

4444
Intrinsics in `core::arch::nvptx` may use `#[cfg(target_feature = "...")]`, thus it's necessary to use `-Zbuild-std=core` with appropriate `RUSTFLAGS`. The following components are needed for this workflow:

tests/assembly-llvm/nvptx-arch-default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ assembly-output: ptx-linker
2-
//@ compile-flags: --crate-type cdylib -Z unstable-options -Clinker-flavor=llbc
2+
//@ compile-flags: --crate-type cdylib
33
//@ only-nvptx64
44

55
#![no_std]

tests/assembly-llvm/nvptx-arch-target-cpu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ assembly-output: ptx-linker
2-
//@ compile-flags: --crate-type cdylib -C target-cpu=sm_50 -Z unstable-options -Clinker-flavor=llbc
2+
//@ compile-flags: --crate-type cdylib -C target-cpu=sm_50
33
//@ only-nvptx64
44

55
#![no_std]

tests/assembly-llvm/nvptx-c-abi-arg-v7.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ assembly-output: ptx-linker
2-
//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 -Z unstable-options -Clinker-flavor=llbc
2+
//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86
33
//@ only-nvptx64
44

55
// The PTX ABI stability is tied to major versions of the PTX ISA

tests/assembly-llvm/nvptx-c-abi-ret-v7.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ assembly-output: ptx-linker
2-
//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 -Z unstable-options -Clinker-flavor=llbc
2+
//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86
33
//@ only-nvptx64
44

55
// The PTX ABI stability is tied to major versions of the PTX ISA

tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ assembly-output: ptx-linker
2-
//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 -Z unstable-options -Clinker-flavor=llbc
2+
//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86
33
//@ only-nvptx64
44

55
// The following ABI tests are made with nvcc 11.6 does.

tests/assembly-llvm/nvptx-safe-naming.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ assembly-output: ptx-linker
2-
//@ compile-flags: --crate-type cdylib -Z unstable-options -Clinker-flavor=llbc
2+
//@ compile-flags: --crate-type cdylib
33
//@ only-nvptx64
44
//@ revisions: LLVM20 LLVM21
55
//@ [LLVM21] min-llvm-version: 21

0 commit comments

Comments
 (0)