From 45b50d303c52a11785469364c82e083cbe14140b Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 13 May 2024 22:56:21 -0400 Subject: [PATCH] lto function, static_library call, rename --- src/tools/run-make-support/src/rustc.rs | 7 +++---- .../bar.rs | 0 .../foo.c | 0 .../foo.rs | 0 .../rmake.rs | 8 ++++---- 5 files changed, 7 insertions(+), 8 deletions(-) rename tests/run-make/{issue-14500 => reachable-extern-fn-available-lto}/bar.rs (100%) rename tests/run-make/{issue-14500 => reachable-extern-fn-available-lto}/foo.c (100%) rename tests/run-make/{issue-14500 => reachable-extern-fn-available-lto}/foo.rs (100%) rename tests/run-make/{issue-14500 => reachable-extern-fn-available-lto}/rmake.rs (78%) diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs index c92e9f9b11f4c..0de5a38c0c486 100644 --- a/src/tools/run-make-support/src/rustc.rs +++ b/src/tools/run-make-support/src/rustc.rs @@ -150,10 +150,9 @@ 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); + /// Enables link time optimizations in rustc. Equivalent to `-Clto``. + pub fn lto(&mut self) -> &mut Self { + self.cmd.arg("-Clto"); self } diff --git a/tests/run-make/issue-14500/bar.rs b/tests/run-make/reachable-extern-fn-available-lto/bar.rs similarity index 100% rename from tests/run-make/issue-14500/bar.rs rename to tests/run-make/reachable-extern-fn-available-lto/bar.rs diff --git a/tests/run-make/issue-14500/foo.c b/tests/run-make/reachable-extern-fn-available-lto/foo.c similarity index 100% rename from tests/run-make/issue-14500/foo.c rename to tests/run-make/reachable-extern-fn-available-lto/foo.c diff --git a/tests/run-make/issue-14500/foo.rs b/tests/run-make/reachable-extern-fn-available-lto/foo.rs similarity index 100% rename from tests/run-make/issue-14500/foo.rs rename to tests/run-make/reachable-extern-fn-available-lto/foo.rs diff --git a/tests/run-make/issue-14500/rmake.rs b/tests/run-make/reachable-extern-fn-available-lto/rmake.rs similarity index 78% rename from tests/run-make/issue-14500/rmake.rs rename to tests/run-make/reachable-extern-fn-available-lto/rmake.rs index 58f632e590938..3e38b92b2b87d 100644 --- a/tests/run-make/issue-14500/rmake.rs +++ b/tests/run-make/reachable-extern-fn-available-lto/rmake.rs @@ -1,5 +1,5 @@ // Test to make sure that reachable extern fns are always available in final -// productcs, including when LTO is used. +// productcs, including when link time optimizations (LTO) are used. // In this test, the `foo` crate has a reahable symbol, // and is a dependency of the `bar` crate. When the `bar` crate @@ -9,15 +9,15 @@ //@ ignore-cross-compile -use run_make_support::{cc, extra_c_flags, run, rustc, tmp_dir}; +use run_make_support::{cc, extra_c_flags, run, rustc, static_lib, tmp_dir}; fn main() { - let libbar_path = tmp_dir().join("libbar.a"); + let libbar_path = static_lib("bar"); rustc().input("foo.rs").crate_type("rlib").run(); rustc() .input("bar.rs") .crate_type("staticlib") - .codegen_option("lto") + .lto() .library_search_path(".") .output(&libbar_path) .run();