Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate run-make/issue-14500 to new rmake.rs format #125047

Merged
merged 4 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think specific helpers for specific codegen options are better, i.e. .lto() over .codegen_options("lto") or something.


/// 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");
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions tests/run-make/issue-14500/Makefile

This file was deleted.

26 changes: 26 additions & 0 deletions tests/run-make/issue-14500/rmake.rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take the opportunity to rename this test to something that's not as opaque as issue-14500. Maybe reachable-extern-fn-available-lto?

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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, tmp_dir};

fn main() {
let libbar_path = tmp_dir().join("libbar.a");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall exactly, do we have a static library name helper? If not, can you add one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already one! I should use it.

rustc().input("foo.rs").crate_type("rlib").run();
rustc()
.input("bar.rs")
.crate_type("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");
}
Loading