Skip to content

Commit 9e1e77b

Browse files
committed
Auto merge of #150186 - JonathanBrouwer:rollup-bd22oaq, r=JonathanBrouwer
Rollup of 2 pull requests Successful merges: - #148499 (Nvptx: Use llbc as default linker) - #150172 (Handle remapped paths correctly when generating "Source" links) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d0835ad + a546937 commit 9e1e77b

File tree

12 files changed

+50
-22
lines changed

12 files changed

+50
-22
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,11 +2956,6 @@ impl Target {
29562956
matches!(self.linker_flavor, LinkerFlavor::Bpf),
29572957
"`linker_flavor` must be `bpf` if and only if `arch` is `bpf`"
29582958
);
2959-
check_eq!(
2960-
self.arch == Arch::Nvptx64,
2961-
matches!(self.linker_flavor, LinkerFlavor::Ptx),
2962-
"`linker_flavor` must be `ptc` if and only if `arch` is `nvptx64`"
2963-
);
29642959

29652960
for args in [
29662961
&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: Os::Cuda,
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`, and uses the `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:

src/librustdoc/html/render/context.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_hir::def_id::{DefIdMap, LOCAL_CRATE};
1414
use rustc_middle::ty::TyCtxt;
1515
use rustc_session::Session;
1616
use rustc_span::edition::Edition;
17-
use rustc_span::{BytePos, FileName, Symbol};
17+
use rustc_span::{BytePos, FileName, RemapPathScopeComponents, Symbol};
1818
use tracing::info;
1919

2020
use super::print_item::{full_path, print_item, print_item_path};
@@ -365,7 +365,10 @@ impl<'tcx> Context<'tcx> {
365365

366366
// We can safely ignore synthetic `SourceFile`s.
367367
let file = match span.filename(self.sess()) {
368-
FileName::Real(ref path) => path.local_path()?.to_path_buf(),
368+
FileName::Real(ref path) => path
369+
.local_path()
370+
.unwrap_or(path.path(RemapPathScopeComponents::MACRO))
371+
.to_path_buf(),
369372
_ => return None,
370373
};
371374
let file = &file;
@@ -499,10 +502,12 @@ impl<'tcx> Context<'tcx> {
499502
} = options;
500503

501504
let src_root = match krate.src(tcx) {
502-
FileName::Real(ref p) => match p.local_path().map(|p| p.parent()).flatten() {
503-
Some(p) => p.to_path_buf(),
504-
None => PathBuf::new(),
505-
},
505+
FileName::Real(ref p) => {
506+
match p.local_path().unwrap_or(p.path(RemapPathScopeComponents::MACRO)).parent() {
507+
Some(p) => p.to_path_buf(),
508+
None => PathBuf::new(),
509+
}
510+
}
506511
_ => PathBuf::new(),
507512
};
508513
// If user passed in `--playground-url` arg, we fill in crate name here

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)