Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
945 B
Rust
Raw Normal View History

2024-05-12 14:00:09 -04:00
// Test to make sure that reachable extern fns are always available in final
// productcs, including when link time optimizations (LTO) are used.
2024-05-12 14:00:09 -04:00
// 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_name};
2024-05-12 14:00:09 -04:00
fn main() {
let libbar_path = static_lib_name("bar");
2024-05-12 14:13:02 -04:00
rustc().input("foo.rs").crate_type("rlib").run();
rustc()
.input("bar.rs")
2024-05-12 15:02:22 -04:00
.crate_type("staticlib")
2024-05-11 19:34:19 -04:00
.arg("-Clto")
2024-05-12 14:00:09 -04:00
.library_search_path(".")
.output(&libbar_path)
.run();
2024-05-12 14:13:02 -04:00
cc().input("foo.c").input(libbar_path).args(&extra_c_flags()).out_exe("foo").run();
2024-05-12 14:00:09 -04:00
run("foo");
}