-
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 #128075 - Oneirical:try-your-damnetest, r=<try>
Migrate `rlib-format-packed-bundled-libs-2`, `native-link-modifier-whole-archive` and `no-builtins-attribute` `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). Please try: try-job: x86_64-msvc try-job: test-various try-job: armhf-gnu try-job: aarch64-apple try-job: x86_64-gnu-llvm-18
- Loading branch information
Showing
11 changed files
with
224 additions
and
96 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 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
52 changes: 0 additions & 52 deletions
52
tests/run-make/native-link-modifier-whole-archive/Makefile
This file was deleted.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
tests/run-make/native-link-modifier-whole-archive/rmake.rs
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,86 @@ | ||
// This test case makes sure that native libraries are linked with appropriate semantics | ||
// when the `[+-]bundle,[+-]whole-archive` modifiers are applied to them. | ||
// The test works by checking that the resulting executables produce the expected output, | ||
// part of which is emitted by otherwise unreferenced C code. If +whole-archive didn't work | ||
// that code would never make it into the final executable and we'd thus be missing some | ||
// of the output. | ||
// See https://github.com/rust-lang/rust/issues/88085 | ||
|
||
//@ ignore-cross-compile | ||
// Reason: compiling C++ code does not work well when cross-compiling | ||
// plus, the compiled binary is executed | ||
|
||
use run_make_support::{cxx, is_msvc, llvm_ar, run, run_with_args, rustc, static_lib_name}; | ||
|
||
fn main() { | ||
let mut cxx = cxx(); | ||
if is_msvc() { | ||
cxx.arg("-EHs"); | ||
} | ||
cxx.input("c_static_lib_with_constructor.cpp") | ||
.arg("-c") | ||
.out_exe("libc_static_lib_with_constructor") | ||
.run(); | ||
|
||
let mut llvm_ar = llvm_ar(); | ||
llvm_ar.obj_to_ar(); | ||
if is_msvc() { | ||
llvm_ar | ||
.output_input( | ||
static_lib_name("c_static_lib_with_constructor"), | ||
"libc_static_lib_with_constructor.obj", | ||
) | ||
.run(); | ||
} else { | ||
llvm_ar | ||
.output_input( | ||
static_lib_name("c_static_lib_with_constructor"), | ||
"libc_static_lib_with_constructor", | ||
) | ||
.run(); | ||
} | ||
|
||
// Native lib linked directly into executable | ||
rustc() | ||
.input("directly_linked.rs") | ||
.arg("-lstatic:+whole-archive=c_static_lib_with_constructor") | ||
.run(); | ||
|
||
// Native lib linked into test executable, +whole-archive | ||
rustc() | ||
.input("directly_linked_test_plus_whole_archive.rs") | ||
.arg("--test") | ||
.arg("-lstatic:+whole-archive=c_static_lib_with_constructor") | ||
.run(); | ||
|
||
// Native lib linked into test executable, -whole-archive | ||
rustc() | ||
.input("directly_linked_test_minus_whole_archive.rs") | ||
.arg("--test") | ||
.arg("-lstatic:-whole-archive=c_static_lib_with_constructor") | ||
.run(); | ||
|
||
// Native lib linked into rlib with via commandline | ||
rustc() | ||
.input("rlib_with_cmdline_native_lib.rs") | ||
.crate_type("rlib") | ||
.arg("-lstatic:-bundle,+whole-archive=c_static_lib_with_constructor") | ||
.run(); | ||
// Native lib linked into RLIB via `-l static:-bundle,+whole-archive` | ||
// RLIB linked into executable | ||
rustc().input("indirectly_linked.rs").run(); | ||
|
||
// Native lib linked into rlib via `#[link()]` attribute on extern block. | ||
rustc().input("native_lib_in_src.rs").crate_type("rlib").run(); | ||
// Native lib linked into RLIB via #[link] attribute, RLIB linked into executable | ||
rustc().input("indirectly_linked_via_attr.rs").run(); | ||
|
||
run("directly_linked").assert_stdout_contains("static-initializer.directly_linked."); | ||
run_with_args("directly_linked_test_plus_whole_archive", &["--nocapture"]) | ||
.assert_stdout_contains("static-initializer."); | ||
run_with_args("directly_linked_test_minus_whole_archive", &["--nocapture"]) | ||
.assert_stdout_not_contains("static-initializer."); | ||
run("indirectly_linked").assert_stdout_contains("static-initializer.indirectly_linked."); | ||
run("indirectly_linked_via_attr") | ||
.assert_stdout_contains("static-initializer.native_lib_in_src."); | ||
} |
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,13 @@ | ||
// `no_builtins` is an attribute related to LLVM's optimizations. In order to ensure that it has an | ||
// effect on link-time optimizations (LTO), it should be added to function declarations in a crate. | ||
// This test uses the `llvm-filecheck` tool to determine that this attribute is successfully | ||
// being added to these function declarations. | ||
// See https://github.com/rust-lang/rust/pull/113716 | ||
|
||
use run_make_support::{llvm_filecheck, rfs, rustc}; | ||
|
||
fn main() { | ||
rustc().input("no_builtins.rs").emit("link").run(); | ||
rustc().input("main.rs").emit("llvm-ir").run(); | ||
llvm_filecheck().patterns("filecheck.main.txt").stdin(rfs::read("main.ll")).run(); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.