Skip to content

Commit

Permalink
Unrolled build for rust-lang#125047
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#125047 - Oneirical:test5, r=jieyouxu

Migrate `run-make/issue-14500` to new `rmake.rs` format

Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Note: I find suspicious that `libbar.a` is hardcoded and is not using the `STATICLIB` call to adapt to Windows platforms. Is this intentional? If not, this will need to be changed.
  • Loading branch information
rust-timer authored May 14, 2024
2 parents bdfd941 + 45b50d3 commit 43bc409
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 16 deletions.
13 changes: 13 additions & 0 deletions src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ impl Rustc {
self
}

/// Enables link time optimizations in rustc. Equivalent to `-Clto``.
pub fn lto(&mut self) -> &mut Self {
self.cmd.arg("-Clto");
self
}

/// Add a directory to the library search path.
pub fn library_search_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg("-L");
self.cmd.arg(path.as_ref());
self
}

/// Specify the edition year.
pub fn edition(&mut self, edition: &str) -> &mut Self {
self.cmd.arg("--edition");
Expand Down
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 @@ -95,7 +95,6 @@ run-make/issue-107094/Makefile
run-make/issue-10971-temps-dir/Makefile
run-make/issue-109934-lto-debuginfo/Makefile
run-make/issue-11908/Makefile
run-make/issue-14500/Makefile
run-make/issue-14698/Makefile
run-make/issue-15460/Makefile
run-make/issue-18943/Makefile
Expand Down
15 changes: 0 additions & 15 deletions tests/run-make/issue-14500/Makefile

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions tests/run-make/reachable-extern-fn-available-lto/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Test to make sure that reachable extern fns are always available in final
// productcs, including when link time optimizations (LTO) are used.

// In this test, the `foo` crate has a reahable symbol,
// and is a dependency of the `bar` crate. When the `bar` crate
// is compiled with LTO, it shouldn't strip the symbol from `foo`, and that's the
// only way that `foo.c` will successfully compile.
// See https://github.com/rust-lang/rust/issues/14500

//@ ignore-cross-compile

use run_make_support::{cc, extra_c_flags, run, rustc, static_lib, tmp_dir};

fn main() {
let libbar_path = static_lib("bar");
rustc().input("foo.rs").crate_type("rlib").run();
rustc()
.input("bar.rs")
.crate_type("staticlib")
.lto()
.library_search_path(".")
.output(&libbar_path)
.run();
cc().input("foo.c").input(libbar_path).args(&extra_c_flags()).out_exe("foo").run();
run("foo");
}

0 comments on commit 43bc409

Please sign in to comment.