Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 844c7e8

Browse files
authoredMay 14, 2024
Rollup merge of #125047 - Oneirical:test5, r=jieyouxu
Migrate `run-make/issue-14500` to new `rmake.rs` format Part of #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.
2 parents 0458d8a + 45b50d3 commit 844c7e8

File tree

7 files changed

+39
-16
lines changed

7 files changed

+39
-16
lines changed
 

‎src/tools/run-make-support/src/rustc.rs

+13
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,19 @@ impl Rustc {
150150
self
151151
}
152152

153+
/// Enables link time optimizations in rustc. Equivalent to `-Clto``.
154+
pub fn lto(&mut self) -> &mut Self {
155+
self.cmd.arg("-Clto");
156+
self
157+
}
158+
159+
/// Add a directory to the library search path.
160+
pub fn library_search_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
161+
self.cmd.arg("-L");
162+
self.cmd.arg(path.as_ref());
163+
self
164+
}
165+
153166
/// Specify the edition year.
154167
pub fn edition(&mut self, edition: &str) -> &mut Self {
155168
self.cmd.arg("--edition");

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ run-make/issue-107094/Makefile
9595
run-make/issue-10971-temps-dir/Makefile
9696
run-make/issue-109934-lto-debuginfo/Makefile
9797
run-make/issue-11908/Makefile
98-
run-make/issue-14500/Makefile
9998
run-make/issue-14698/Makefile
10099
run-make/issue-15460/Makefile
101100
run-make/issue-18943/Makefile

‎tests/run-make/issue-14500/Makefile

-15
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Test to make sure that reachable extern fns are always available in final
2+
// productcs, including when link time optimizations (LTO) are used.
3+
4+
// In this test, the `foo` crate has a reahable symbol,
5+
// and is a dependency of the `bar` crate. When the `bar` crate
6+
// is compiled with LTO, it shouldn't strip the symbol from `foo`, and that's the
7+
// only way that `foo.c` will successfully compile.
8+
// See https://github.com/rust-lang/rust/issues/14500
9+
10+
//@ ignore-cross-compile
11+
12+
use run_make_support::{cc, extra_c_flags, run, rustc, static_lib, tmp_dir};
13+
14+
fn main() {
15+
let libbar_path = static_lib("bar");
16+
rustc().input("foo.rs").crate_type("rlib").run();
17+
rustc()
18+
.input("bar.rs")
19+
.crate_type("staticlib")
20+
.lto()
21+
.library_search_path(".")
22+
.output(&libbar_path)
23+
.run();
24+
cc().input("foo.c").input(libbar_path).args(&extra_c_flags()).out_exe("foo").run();
25+
run("foo");
26+
}

0 commit comments

Comments
 (0)
Failed to load comments.