Skip to content

Commit

Permalink
tests/run-make: port issue-84395-lto-embed-bitcode to rmake.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
jieyouxu committed Oct 21, 2024
1 parent 6297283 commit 37aa1a0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ run-make/branch-protection-check-IBT/Makefile
run-make/cat-and-grep-sanity-check/Makefile
run-make/extern-fn-reachable/Makefile
run-make/incr-add-rust-src-component/Makefile
run-make/issue-84395-lto-embed-bitcode/Makefile
run-make/jobserver-error/Makefile
run-make/libs-through-symlinks/Makefile
run-make/split-debuginfo/Makefile
Expand Down
14 changes: 0 additions & 14 deletions tests/run-make/issue-84395-lto-embed-bitcode/Makefile

This file was deleted.

27 changes: 27 additions & 0 deletions tests/run-make/issue-84395-lto-embed-bitcode/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//! Smoke test to make sure the embed bitcode in elf created with
//! `--plugin-opt=-lto-embed-bitcode=optimized` is valid llvm BC module.
//!
//! See <https://github.com/rust-lang/rust/issues/84395> where passing
//! `-lto-embed-bitcode=optimized` to lld when linking rust code via `linker-plugin-lto` doesn't
//! produce the expected result.
//!
//! See PR <https://github.com/rust-lang/rust/pull/98162> which initially introduced this test.

//@ needs-force-clang-based-tests

use run_make_support::{env_var, llvm_dis, llvm_objcopy, rustc};

fn main() {
rustc()
.input("test.rs")
.arg("-Clink-arg=-fuse-ld=lld")
.arg("-Clinker-plugin-lto")
.arg(format!("-Clinker={}", env_var("CLANG")))
.arg("-Clink-arg=-Wl,--plugin-opt=-lto-embed-bitcode=optimized")
.arg("-Zemit-thin-lto=no")
.run();

llvm_objcopy().dump_section(".llvmbc", "test.bc").arg("test").run();

llvm_dis().arg("test.bc").run();
}

0 comments on commit 37aa1a0

Please sign in to comment.