Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ struct CompiledModules {

fn need_bitcode_in_object(tcx: TyCtxt<'_>) -> bool {
let sess = tcx.sess;
sess.opts.cg.embed_bitcode
(sess.lto() != config::Lto::No || sess.opts.cg.embed_bitcode)
&& tcx.crate_types().contains(&CrateType::Rlib)
&& sess.opts.output_types.contains_key(&OutputType::Exe)
}
Expand Down
5 changes: 0 additions & 5 deletions src/doc/rustc/src/platform-support/amdgcn-amd-amdhsa.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ Build the library as `cdylib`:
# Cargo.toml
[lib]
crate-type = ["cdylib"]

[profile.dev]
lto = true # LTO must be explicitly enabled for now
[profile.release]
lto = true
```

The target-cpu must be from the list [supported by LLVM] (or printed with `rustc --target amdgcn-amd-amdhsa --print target-cpus`).
Expand Down
7 changes: 6 additions & 1 deletion src/tools/tidy/src/target_specific_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ pub fn check(tests_path: &Path, tidy_ctx: TidyCtx) {
});

// Skip run-make tests as revisions are not supported.
if entry.path().strip_prefix(tests_path).is_ok_and(|rest| rest.starts_with("run-make")) {
// Skip run-make-cargo tests as they can specify the target in ways we do not detect here.
if entry
.path()
.strip_prefix(tests_path)
.is_ok_and(|rest| rest.starts_with("run-make") || rest.starts_with("run-make-cargo"))
{
return;
}

Expand Down
8 changes: 8 additions & 0 deletions tests/run-make-cargo/amdgpu-lto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "amdgpu_lto"
version = "0.1.0"
edition = "2024"

[lib]
path = "lib.rs"
crate-type = ["cdylib"]
9 changes: 9 additions & 0 deletions tests/run-make-cargo/amdgpu-lto/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![no_std]

#[panic_handler]
fn panic_handler(_info: &core::panic::PanicInfo) -> ! {
loop {}
}

#[unsafe(no_mangle)]
fn foo() {}
28 changes: 28 additions & 0 deletions tests/run-make-cargo/amdgpu-lto/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Check that compiling for the amdgpu target which has requires_lto=true works with a default
// cargo configuration.

//@ needs-llvm-components: amdgpu
//@ needs-rust-lld

#![deny(warnings)]

use run_make_support::{cargo, path};

fn main() {
let target_dir = path("target");

cargo()
.args(&[
"build",
"--release",
"--lib",
"--manifest-path",
"Cargo.toml",
"-Zbuild-std=core",
"--target",
"amdgcn-amd-amdhsa",
])
.env("RUSTFLAGS", "-Ctarget-cpu=gfx900")
.env("CARGO_TARGET_DIR", &target_dir)
.run();
}
Loading