Skip to content

Commit

Permalink
rewrite pgo-gen-no-imp-symbols to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jul 22, 2024
1 parent 96ffb66 commit cdd38a3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 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 @@ -67,7 +67,6 @@ run-make/panic-abort-eh_frame/Makefile
run-make/pass-non-c-like-enum-to-c/Makefile
run-make/pdb-buildinfo-cl-cmd/Makefile
run-make/pgo-gen-lto/Makefile
run-make/pgo-gen-no-imp-symbols/Makefile
run-make/pgo-indirect-call-promotion/Makefile
run-make/pointer-auth-link-with-c/Makefile
run-make/print-calling-conventions/Makefile
Expand Down
3 changes: 2 additions & 1 deletion tests/run-make/lto-linkage-used-attr/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
// This test checks that the impl_* symbols are preserved as they should.
// See https://github.com/rust-lang/rust/issues/108030

//FIXME(Oneirical): try it on more than only-x86_64-unknown-linux-gnu
//@ only-x86_64-unknown-linux-gnu
// Reason: some of the inline assembly directives are architecture-specific.

use run_make_support::rustc;

Expand Down
11 changes: 0 additions & 11 deletions tests/run-make/pgo-gen-no-imp-symbols/Makefile

This file was deleted.

27 changes: 27 additions & 0 deletions tests/run-make/pgo-gen-no-imp-symbols/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// LLVM's profiling instrumentation adds a few symbols that are used by the profiler runtime.
// Since these show up as globals in the LLVM IR, the compiler generates dllimport-related
// __imp_ stubs for them. This can lead to linker errors because the instrumentation
// symbols have weak linkage or are in a comdat section, but the __imp_ stubs aren't.
// Since profiler-related symbols were excluded from stub-generation in #59812, this has
// been fixed, and this test checks that the llvm profile symbol appear, but without the
// anomalous __imp_ stubs.
// See https://github.com/rust-lang/rust/pull/59812

use run_make_support::{cwd, rfs, rustc};

fn main() {
rustc()
.input("test.rs")
.emit("llvm-ir")
.opt()
.codegen_units(1)
.profile_generate(cwd())
.arg("-Zno-profiler-runtime")
.run();
let out = rfs::read_to_string("test.ll");
// We expect symbols starting with "__llvm_profile_".
assert!(out.contains("__llvm_profile_"));
// We do NOT expect the "__imp_" version of these symbols.
assert!(!out.contains("__imp___llvm_profile_")); // 64 bit
assert!(!out.contains("__imp____llvm_profile_")); // 32 bit
}

0 comments on commit cdd38a3

Please sign in to comment.