-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #126437 - Oneirical:test-we-forget, r=<try>
Migrate `issue-64153`, `invalid-staticlib` and `no-builtins-lto` `run-make` tests to `rmake` Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). try-job: x86_64-msvc
- Loading branch information
Showing
11 changed files
with
107 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// If the static library provided is not valid (in this test, | ||
// created as an empty file), | ||
// rustc should print a normal error message and not throw | ||
// an internal compiler error (ICE). | ||
// See https://github.com/rust-lang/rust/pull/28673 | ||
|
||
use run_make_support::{fs_wrapper, rustc, static_lib_name}; | ||
|
||
fn main() { | ||
fs_wrapper::create_file(static_lib_name("foo")); | ||
rustc() | ||
.arg("-") | ||
.crate_type("rlib") | ||
.arg("-lstatic=foo") | ||
.run_fail() | ||
.assert_stderr_contains("failed to add native library"); | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// ignore-tidy-tab | ||
// Staticlibs don't include Rust object files from upstream crates if the same | ||
// code was already pulled into the lib via LTO. However, the bug described in | ||
// https://github.com/rust-lang/rust/issues/64153 lead to this exclusion not | ||
// working properly if the upstream crate was compiled with an explicit filename | ||
// (via `-o`). | ||
|
||
// This test makes sure that functions defined in the upstream crates do not | ||
// appear twice in the final staticlib when listing all the symbols from it. | ||
|
||
//FIXME(Oneirical): temporarily remove ignorewindows | ||
// Reason: `llvm-objdump`'s output looks different on windows than on other platforms. | ||
// Only checking on Unix platforms should suffice. | ||
|
||
use run_make_support::{llvm_objdump, regex, rust_lib_name, rustc, static_lib_name}; | ||
|
||
fn main() { | ||
rustc() | ||
.crate_type("rlib") | ||
.input("upstream.rs") | ||
.output(rust_lib_name("upstream")) | ||
.codegen_units(1) | ||
.run(); | ||
rustc() | ||
.crate_type("staticlib") | ||
.input("downstream.rs") | ||
.arg("-Clto") | ||
.output(static_lib_name("downstream")) | ||
.codegen_units(1) | ||
.run(); | ||
let syms = llvm_objdump().arg("-t").input(static_lib_name("downstream")).run().stdout_utf8(); | ||
let re = regex::Regex::new(r#"\s*g\s*F\s.*issue64153_test_function"#).unwrap(); | ||
// Count the global instances of `issue64153_test_function`. There'll be 2 | ||
// if the `upstream` object file got erroneously included twice. | ||
// The line we are testing for with the regex looks something like: | ||
// 0000000000000000 g F .text.issue64153_test_function 00000023 issue64153_test_function | ||
assert_eq!(re.find_iter(syms.as_str()).count(), 1); | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// The rlib produced by a no_builtins crate should be explicitely linked | ||
// during compilation, and as a result be present in the linker arguments. | ||
// See the comments inside this file for more details. | ||
// See https://github.com/rust-lang/rust/pull/35637 | ||
|
||
use run_make_support::{rust_lib_name, rustc}; | ||
|
||
fn main() { | ||
// Compile a `#![no_builtins]` rlib crate | ||
rustc().input("no_builtins.rs").run(); | ||
// Build an executable that depends on that crate using LTO. The no_builtins crate doesn't | ||
// participate in LTO, so its rlib must be explicitly | ||
// linked into the final binary. Verify this by grepping the linker arguments. | ||
rustc() | ||
.input("main.rs") | ||
.arg("-Clto") | ||
.print("link-args") | ||
.run() | ||
.assert_stdout_contains(rust_lib_name("no_builtins")); | ||
} |