rewrite extern-flag-fun to rmake

This commit is contained in:
Oneirical 2024-06-14 13:42:42 -04:00
parent 7ac6c2fc68
commit a3b7c2993e
3 changed files with 36 additions and 21 deletions

View File

@ -43,7 +43,6 @@ run-make/error-writing-dependencies/Makefile
run-make/export-executable-symbols/Makefile
run-make/extern-diff-internal-name/Makefile
run-make/extern-flag-disambiguates/Makefile
run-make/extern-flag-fun/Makefile
run-make/extern-flag-pathless/Makefile
run-make/extern-flag-rename-transitive/Makefile
run-make/extern-fn-explicit-align/Makefile

View File

@ -1,20 +0,0 @@
# ignore-cross-compile
include ../tools.mk
all:
$(RUSTC) bar.rs --crate-type=rlib
$(RUSTC) bar.rs --crate-type=rlib -C extra-filename=-a
$(RUSTC) bar-alt.rs --crate-type=rlib
$(RUSTC) foo.rs --extern bar=no-exist && exit 1 || exit 0
$(RUSTC) foo.rs --extern bar=foo.rs && exit 1 || exit 0
$(RUSTC) foo.rs \
--extern bar=$(TMPDIR)/libbar.rlib \
--extern bar=$(TMPDIR)/libbar-alt.rlib \
&& exit 1 || exit 0
$(RUSTC) foo.rs \
--extern bar=$(TMPDIR)/libbar.rlib \
--extern bar=$(TMPDIR)/libbar-a.rlib
$(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib
# Try to be sneaky and load a private crate from with a non-private name.
$(RUSTC) rustc.rs -Zforce-unstable-if-unmarked --crate-type=rlib
$(RUSTC) gated_unstable.rs --extern alloc=$(TMPDIR)/librustc.rlib 2>&1 | $(CGREP) 'rustc_private'

View File

@ -0,0 +1,36 @@
// The --extern flag can override the default crate search of
// the compiler and directly fetch a given path. There are a few rules
// to follow: for example, there can't be more than one rlib, the crates must
// be valid ("no-exist" in this test), and private crates can't be loaded
// as non-private. This test checks that these rules are enforced.
// See https://github.com/rust-lang/rust/pull/15319
//@ ignore-cross-compile
use run_make_support::{rust_lib_name, rustc};
fn main() {
rustc().input("bar.rs").crate_type("rlib").run();
rustc().input("bar.rs").crate_type("rlib").extra_filename("-a").run();
rustc().input("bar-alt.rs").crate_type("rlib").run();
rustc().input("foo.rs").extern_("bar", "no-exist").run_fail();
rustc().input("foo.rs").extern_("bar", "foo.rs").run_fail();
rustc()
.input("foo.rs")
.extern_("bar", rust_lib_name("bar"))
.extern_("bar", rust_lib_name("bar-alt"))
.run_fail();
rustc()
.input("foo.rs")
.extern_("bar", rust_lib_name("bar"))
.extern_("bar", rust_lib_name("bar-a"))
.run();
rustc().input("foo.rs").extern_("bar", rust_lib_name("bar")).run();
// Try to be sneaky and load a private crate from with a non-private name.
rustc().input("rustc.rs").arg("-Zforce-unstable-if-unmarked").crate_type("rlib").run();
rustc()
.input("gated_unstable.rs")
.extern_("alloc", rust_lib_name("rustc"))
.run_fail()
.assert_stderr_contains("rustc_private");
}