Rollup merge of #125047 - Oneirical:test5, r=jieyouxu · rust-lang/rust@844c7e8 (original) (raw)

File tree

7 files changed

lines changed

7 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -150,6 +150,19 @@ impl Rustc {
150 150 self
151 151 }
152 152
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 +
153 166 /// Specify the edition year.
154 167 pub fn edition(&mut self, edition: &str) -> &mut Self {
155 168 self.cmd.arg("--edition");
Original file line number Diff line number Diff line change
@@ -95,7 +95,6 @@ run-make/issue-107094/Makefile
95 95 run-make/issue-10971-temps-dir/Makefile
96 96 run-make/issue-109934-lto-debuginfo/Makefile
97 97 run-make/issue-11908/Makefile
98 -run-make/issue-14500/Makefile
99 98 run-make/issue-14698/Makefile
100 99 run-make/issue-15460/Makefile
101 100 run-make/issue-18943/Makefile

File renamed without changes.

File renamed without changes.

File renamed without changes.

Original file line number Diff line number Diff 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 +}