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 f2de5fb

Browse files
committedMay 12, 2024
rewrite issue-14500 to rmake
1 parent 3349155 commit f2de5fb

File tree

4 files changed

+45
-16
lines changed

4 files changed

+45
-16
lines changed
 

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

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

153+
/// Pass a codegen option.
154+
pub fn codegen_option(&mut self, option: &str) -> &mut Self {
155+
self.cmd.arg("-C");
156+
self.cmd.arg(option);
157+
self
158+
}
159+
160+
/// Add a directory to the library search path.
161+
pub fn library_search_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
162+
self.cmd.arg("-L");
163+
self.cmd.arg(path.as_ref());
164+
self
165+
}
166+
153167
/// Specify the edition year.
154168
pub fn edition(&mut self, edition: &str) -> &mut Self {
155169
self.cmd.arg("--edition");

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

-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ run-make/issue-107094/Makefile
9999
run-make/issue-10971-temps-dir/Makefile
100100
run-make/issue-109934-lto-debuginfo/Makefile
101101
run-make/issue-11908/Makefile
102-
run-make/issue-14500/Makefile
103102
run-make/issue-14698/Makefile
104103
run-make/issue-15460/Makefile
105104
run-make/issue-18943/Makefile

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

-15
This file was deleted.

‎tests/run-make/issue-14500/rmake.rs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Test to make sure that reachable extern fns are always available in final
2+
// productcs, including when LTO is 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};
13+
14+
fn main() {
15+
let libbar_path = tmp_dir().join("libbar.a");
16+
rustc().input("foo.rs")
17+
.crate_type("rlib")
18+
.run();
19+
rustc().input("bar.rs")
20+
.static_lib("staticlib")
21+
.codegen_option("lto")
22+
.library_search_path(".")
23+
.output(&libbar_path)
24+
.run();
25+
cc().input("foo.c")
26+
.input(libbar_path)
27+
.args(&extra_c_flags())
28+
.out_exe("foo")
29+
.run();
30+
run("foo");
31+
}

0 commit comments

Comments
 (0)
Failed to load comments.