mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
rewrite link-cfg to rmake
This commit is contained in:
parent
4db3d12e6f
commit
e9f45e1eb2
@ -25,7 +25,6 @@ run-make/libs-through-symlinks/Makefile
|
|||||||
run-make/libtest-json/Makefile
|
run-make/libtest-json/Makefile
|
||||||
run-make/libtest-junit/Makefile
|
run-make/libtest-junit/Makefile
|
||||||
run-make/libtest-thread-limit/Makefile
|
run-make/libtest-thread-limit/Makefile
|
||||||
run-make/link-cfg/Makefile
|
|
||||||
run-make/long-linker-command-lines-cmd-exe/Makefile
|
run-make/long-linker-command-lines-cmd-exe/Makefile
|
||||||
run-make/long-linker-command-lines/Makefile
|
run-make/long-linker-command-lines/Makefile
|
||||||
run-make/macos-deployment-target/Makefile
|
run-make/macos-deployment-target/Makefile
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
# ignore-cross-compile
|
|
||||||
include ../tools.mk
|
|
||||||
|
|
||||||
all: $(call DYLIB,return1) $(call DYLIB,return2) $(call NATIVE_STATICLIB,return3)
|
|
||||||
ls $(TMPDIR)
|
|
||||||
$(BARE_RUSTC) --print cfg --target x86_64-unknown-linux-musl | $(CGREP) crt-static
|
|
||||||
|
|
||||||
$(RUSTC) no-deps.rs --cfg foo
|
|
||||||
$(call RUN,no-deps)
|
|
||||||
$(RUSTC) no-deps.rs --cfg bar
|
|
||||||
$(call RUN,no-deps)
|
|
||||||
|
|
||||||
$(RUSTC) dep.rs
|
|
||||||
$(RUSTC) with-deps.rs --cfg foo
|
|
||||||
$(call RUN,with-deps)
|
|
||||||
$(RUSTC) with-deps.rs --cfg bar
|
|
||||||
$(call RUN,with-deps)
|
|
||||||
|
|
||||||
$(RUSTC) dep-with-staticlib.rs
|
|
||||||
$(RUSTC) with-staticlib-deps.rs --cfg foo
|
|
||||||
$(call RUN,with-staticlib-deps)
|
|
||||||
$(RUSTC) with-staticlib-deps.rs --cfg bar
|
|
||||||
$(call RUN,with-staticlib-deps)
|
|
43
tests/run-make/link-cfg/rmake.rs
Normal file
43
tests/run-make/link-cfg/rmake.rs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// The `#[link(cfg(..))]` annotation means that the `#[link]`
|
||||||
|
// directive is only active in a compilation unit if that `cfg` value is satisfied.
|
||||||
|
// For example, when compiling an rlib, these directives are just encoded and
|
||||||
|
// ignored for dylibs, and all staticlibs are continued to be put into the rlib as
|
||||||
|
// usual. When placing that rlib into a staticlib, executable, or dylib, however,
|
||||||
|
// the `cfg` is evaluated *as if it were defined in the final artifact* and the
|
||||||
|
// library is decided to be linked or not.
|
||||||
|
// This test exercises this new feature by testing it with no dependencies, then
|
||||||
|
// with only dynamic libraries, then with both a staticlib and dylibs. Compilation
|
||||||
|
// and execution should be successful.
|
||||||
|
// See https://github.com/rust-lang/rust/pull/37545
|
||||||
|
|
||||||
|
//@ ignore-cross-compile
|
||||||
|
// Reason: the compiled binary is executed
|
||||||
|
|
||||||
|
use run_make_support::{bare_rustc, build_native_dynamic_lib, build_native_static_lib, run, rustc};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
build_native_dynamic_lib("return1");
|
||||||
|
build_native_dynamic_lib("return2");
|
||||||
|
build_native_static_lib("return3");
|
||||||
|
bare_rustc()
|
||||||
|
.print("cfg")
|
||||||
|
.target("x86_64-unknown-linux-musl")
|
||||||
|
.run()
|
||||||
|
.assert_stdout_contains("crt-static");
|
||||||
|
rustc().input("no-deps.rs").cfg("foo").run();
|
||||||
|
run("no-deps");
|
||||||
|
rustc().input("no-deps.rs").cfg("bar").run();
|
||||||
|
run("no-deps");
|
||||||
|
|
||||||
|
rustc().input("dep.rs").run();
|
||||||
|
rustc().input("with-deps.rs").cfg("foo").run();
|
||||||
|
run("with-deps");
|
||||||
|
rustc().input("with-deps.rs").cfg("bar").run();
|
||||||
|
run("with-deps");
|
||||||
|
|
||||||
|
rustc().input("dep-with-staticlib.rs").run();
|
||||||
|
rustc().input("with-staticlib-deps.rs").cfg("foo").run();
|
||||||
|
run("with-staticlib-deps");
|
||||||
|
rustc().input("with-staticlib-deps.rs").cfg("bar").run();
|
||||||
|
run("with-staticlib-deps");
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user