rewrite issue-14500 to rmake

This commit is contained in:
Oneirical 2024-05-12 14:00:09 -04:00
parent 3349155ac0
commit f2de5fb2ae
4 changed files with 45 additions and 16 deletions

View File

@ -150,6 +150,20 @@ impl Rustc {
self
}
/// Pass a codegen option.
pub fn codegen_option(&mut self, option: &str) -> &mut Self {
self.cmd.arg("-C");
self.cmd.arg(option);
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");

View File

@ -99,7 +99,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

View File

@ -1,15 +0,0 @@
include ../tools.mk
# ignore-cross-compile
# Test to make sure that reachable extern fns are always available in final
# productcs, including when LTO is 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.
all:
$(RUSTC) foo.rs --crate-type=rlib
$(RUSTC) bar.rs --crate-type=staticlib -C lto -L. -o $(TMPDIR)/libbar.a
$(CC) foo.c $(TMPDIR)/libbar.a $(EXTRACFLAGS) $(call OUT_EXE,foo)
$(call RUN,foo)

View File

@ -0,0 +1,31 @@
// Test to make sure that reachable extern fns are always available in final
// productcs, including when LTO is 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};
fn main() {
let libbar_path = tmp_dir().join("libbar.a");
rustc().input("foo.rs")
.crate_type("rlib")
.run();
rustc().input("bar.rs")
.static_lib("staticlib")
.codegen_option("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");
}