diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 4b50bcb38fd01..1cb52ea91f9c2 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -1,8 +1,6 @@ run-make/branch-protection-check-IBT/Makefile run-make/c-dynamic-dylib/Makefile run-make/c-dynamic-rlib/Makefile -run-make/c-static-dylib/Makefile -run-make/c-static-rlib/Makefile run-make/c-unwind-abi-catch-lib-panic/Makefile run-make/c-unwind-abi-catch-panic/Makefile run-make/cat-and-grep-sanity-check/Makefile @@ -21,9 +19,7 @@ run-make/emit-to-stdout/Makefile run-make/export-executable-symbols/Makefile run-make/extern-diff-internal-name/Makefile run-make/extern-flag-disambiguates/Makefile -run-make/extern-fn-generic/Makefile run-make/extern-fn-reachable/Makefile -run-make/extern-fn-with-union/Makefile run-make/extern-multiple-copies/Makefile run-make/extern-multiple-copies2/Makefile run-make/fmt-write-bloat/Makefile @@ -36,7 +32,6 @@ run-make/interdependent-c-libraries/Makefile run-make/issue-107094/Makefile run-make/issue-14698/Makefile run-make/issue-15460/Makefile -run-make/issue-28595/Makefile run-make/issue-33329/Makefile run-make/issue-35164/Makefile run-make/issue-36710/Makefile @@ -52,11 +47,9 @@ run-make/libtest-junit/Makefile run-make/libtest-thread-limit/Makefile run-make/link-cfg/Makefile run-make/link-framework/Makefile -run-make/linkage-attr-on-static/Makefile run-make/long-linker-command-lines-cmd-exe/Makefile run-make/long-linker-command-lines/Makefile run-make/lto-linkage-used-attr/Makefile -run-make/lto-no-link-whole-rlib/Makefile run-make/macos-deployment-target/Makefile run-make/min-global-align/Makefile run-make/native-link-modifier-bundle/Makefile @@ -65,7 +58,6 @@ run-make/no-alloc-shim/Makefile run-make/no-builtins-attribute/Makefile run-make/no-duplicate-libs/Makefile run-make/panic-abort-eh_frame/Makefile -run-make/pass-non-c-like-enum-to-c/Makefile run-make/pdb-buildinfo-cl-cmd/Makefile run-make/pgo-gen-lto/Makefile run-make/pgo-gen-no-imp-symbols/Makefile @@ -82,7 +74,6 @@ run-make/redundant-libs/Makefile run-make/remap-path-prefix-dwarf/Makefile run-make/reproducible-build-2/Makefile run-make/reproducible-build/Makefile -run-make/return-non-c-like-enum-from-c/Makefile run-make/rlib-format-packed-bundled-libs-2/Makefile run-make/rlib-format-packed-bundled-libs-3/Makefile run-make/rlib-format-packed-bundled-libs/Makefile diff --git a/tests/run-make/c-static-dylib/Makefile b/tests/run-make/c-static-dylib/Makefile deleted file mode 100644 index 05da1743c83ba..0000000000000 --- a/tests/run-make/c-static-dylib/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# This test checks that static Rust linking with C does not encounter any errors, with dynamic dependencies given preference over static. -# See /~https://github.com/rust-lang/rust/issues/10434 - -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,cfoo) - $(RUSTC) foo.rs -C prefer-dynamic - $(RUSTC) bar.rs - rm $(call NATIVE_STATICLIB,cfoo) - $(call RUN,bar) - $(call REMOVE_DYLIBS,foo) - $(call FAIL,bar) diff --git a/tests/run-make/c-static-dylib/rmake.rs b/tests/run-make/c-static-dylib/rmake.rs new file mode 100644 index 0000000000000..12ec06c8199d6 --- /dev/null +++ b/tests/run-make/c-static-dylib/rmake.rs @@ -0,0 +1,20 @@ +// This test checks that static Rust linking with C does not encounter any errors, +// with dynamic dependencies given preference over static. +// See /~https://github.com/rust-lang/rust/issues/10434 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{ + build_native_static_lib, dynamic_lib_name, rfs, run, run_fail, rustc, static_lib_name, +}; + +fn main() { + build_native_static_lib("cfoo"); + rustc().input("foo.rs").arg("-Cprefer-dynamic").run(); + rustc().input("bar.rs").run(); + rfs::remove_file(static_lib_name("cfoo")); + run("bar"); + rfs::remove_file(dynamic_lib_name("foo")); + run_fail("bar"); +} diff --git a/tests/run-make/c-static-rlib/Makefile b/tests/run-make/c-static-rlib/Makefile deleted file mode 100644 index 298e432cdb8ad..0000000000000 --- a/tests/run-make/c-static-rlib/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# This test checks that static Rust linking with C does not encounter any errors, with static dependencies given preference over dynamic. (This is the default behaviour.) -# See /~https://github.com/rust-lang/rust/issues/10434 - -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,cfoo) - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(call REMOVE_RLIBS,foo) - rm $(call NATIVE_STATICLIB,cfoo) - $(call RUN,bar) diff --git a/tests/run-make/c-static-rlib/rmake.rs b/tests/run-make/c-static-rlib/rmake.rs new file mode 100644 index 0000000000000..447e29a14f657 --- /dev/null +++ b/tests/run-make/c-static-rlib/rmake.rs @@ -0,0 +1,17 @@ +// This test checks that static Rust linking with C does not encounter any errors, +// with static dependencies given preference over dynamic. (This is the default behaviour.) +// See /~https://github.com/rust-lang/rust/issues/10434 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, rfs, run, rust_lib_name, rustc, static_lib_name}; + +fn main() { + build_native_static_lib("cfoo"); + rustc().input("foo.rs").run(); + rustc().input("bar.rs").run(); + rfs::remove_file(rust_lib_name("foo")); + rfs::remove_file(static_lib_name("cfoo")); + run("bar"); +} diff --git a/tests/run-make/extern-fn-generic/Makefile b/tests/run-make/extern-fn-generic/Makefile deleted file mode 100644 index 7dceea6cb887c..0000000000000 --- a/tests/run-make/extern-fn-generic/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) testcrate.rs - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/tests/run-make/extern-fn-generic/rmake.rs b/tests/run-make/extern-fn-generic/rmake.rs new file mode 100644 index 0000000000000..05de839a1b0d8 --- /dev/null +++ b/tests/run-make/extern-fn-generic/rmake.rs @@ -0,0 +1,16 @@ +// Generic types in foreign-function interfaces were introduced in #15831 - this +// test simply runs a Rust program containing generics that is also reliant on +// a C library, and checks that compilation and execution are successful. +// See /~https://github.com/rust-lang/rust/pull/15831 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("test"); + rustc().input("testcrate.rs").run(); + rustc().input("test.rs").run(); + run("test"); +} diff --git a/tests/run-make/extern-fn-with-union/Makefile b/tests/run-make/extern-fn-with-union/Makefile deleted file mode 100644 index e6c8c9936791b..0000000000000 --- a/tests/run-make/extern-fn-with-union/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,ctest) - $(RUSTC) testcrate.rs - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/tests/run-make/extern-fn-with-union/rmake.rs b/tests/run-make/extern-fn-with-union/rmake.rs new file mode 100644 index 0000000000000..200602eabeb5c --- /dev/null +++ b/tests/run-make/extern-fn-with-union/rmake.rs @@ -0,0 +1,16 @@ +// If an external function from foreign-function interface was called upon, +// its attributes would only be passed to LLVM if and only if it was called in the same crate. +// This caused passing around unions to be incorrect. +// See /~https://github.com/rust-lang/rust/pull/14191 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("ctest"); + rustc().input("testcrate.rs").run(); + rustc().input("test.rs").run(); + run("test"); +} diff --git a/tests/run-make/issue-28595/Makefile b/tests/run-make/issue-28595/Makefile deleted file mode 100644 index 258f9788aafa7..0000000000000 --- a/tests/run-make/issue-28595/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,a) $(call NATIVE_STATICLIB,b) - $(RUSTC) a.rs - $(RUSTC) b.rs - $(call RUN,b) diff --git a/tests/run-make/linkage-attr-on-static/Makefile b/tests/run-make/linkage-attr-on-static/Makefile deleted file mode 100644 index ef50a7ef9f13c..0000000000000 --- a/tests/run-make/linkage-attr-on-static/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) - $(RUSTC) bar.rs - $(call RUN,bar) || exit 1 diff --git a/tests/run-make/linkage-attr-on-static/rmake.rs b/tests/run-make/linkage-attr-on-static/rmake.rs new file mode 100644 index 0000000000000..cd85542e9587d --- /dev/null +++ b/tests/run-make/linkage-attr-on-static/rmake.rs @@ -0,0 +1,15 @@ +// #[linkage] is a useful attribute which can be applied to statics to allow +// external linkage, something which was not possible before #18890. This test +// checks that using this new feature results in successful compilation and execution. +// See /~https://github.com/rust-lang/rust/pull/18890 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("foo"); + rustc().input("bar.rs").run(); + run("bar"); +} diff --git a/tests/run-make/lto-no-link-whole-rlib/Makefile b/tests/run-make/lto-no-link-whole-rlib/Makefile deleted file mode 100644 index 3e82322e72d34..0000000000000 --- a/tests/run-make/lto-no-link-whole-rlib/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar) - $(RUSTC) lib1.rs - $(RUSTC) lib2.rs - $(RUSTC) main.rs -Clto - $(call RUN,main) - diff --git a/tests/run-make/lto-no-link-whole-rlib/rmake.rs b/tests/run-make/lto-no-link-whole-rlib/rmake.rs new file mode 100644 index 0000000000000..8cd653d5f0866 --- /dev/null +++ b/tests/run-make/lto-no-link-whole-rlib/rmake.rs @@ -0,0 +1,18 @@ +// In order to improve linking performance, entire rlibs will only be linked if a dylib is being +// created. Otherwise, an executable will only link one rlib as usual. Linking will fail in this +// test should this optimization be reverted. +// See /~https://github.com/rust-lang/rust/pull/31460 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("foo"); + build_native_static_lib("bar"); + rustc().input("lib1.rs").run(); + rustc().input("lib2.rs").run(); + rustc().input("main.rs").arg("-Clto").run(); + run("main"); +} diff --git a/tests/run-make/issue-28595/a.c b/tests/run-make/native-lib-load-order/a.c similarity index 100% rename from tests/run-make/issue-28595/a.c rename to tests/run-make/native-lib-load-order/a.c diff --git a/tests/run-make/issue-28595/a.rs b/tests/run-make/native-lib-load-order/a.rs similarity index 100% rename from tests/run-make/issue-28595/a.rs rename to tests/run-make/native-lib-load-order/a.rs diff --git a/tests/run-make/issue-28595/b.c b/tests/run-make/native-lib-load-order/b.c similarity index 100% rename from tests/run-make/issue-28595/b.c rename to tests/run-make/native-lib-load-order/b.c diff --git a/tests/run-make/issue-28595/b.rs b/tests/run-make/native-lib-load-order/b.rs similarity index 100% rename from tests/run-make/issue-28595/b.rs rename to tests/run-make/native-lib-load-order/b.rs diff --git a/tests/run-make/native-lib-load-order/rmake.rs b/tests/run-make/native-lib-load-order/rmake.rs new file mode 100644 index 0000000000000..ffe20a64168f8 --- /dev/null +++ b/tests/run-make/native-lib-load-order/rmake.rs @@ -0,0 +1,16 @@ +// An old compiler bug from 2015 caused native libraries to be loaded in the +// wrong order, causing `b` to be loaded before `a` in this test. If the compilation +// is successful, the libraries were loaded in the correct order. + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("a"); + build_native_static_lib("b"); + rustc().input("a.rs").run(); + rustc().input("b.rs").run(); + run("b"); +} diff --git a/tests/run-make/pass-non-c-like-enum-to-c/Makefile b/tests/run-make/pass-non-c-like-enum-to-c/Makefile deleted file mode 100644 index bd441d321bfab..0000000000000 --- a/tests/run-make/pass-non-c-like-enum-to-c/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) nonclike.rs -L$(TMPDIR) -ltest - $(call RUN,nonclike) diff --git a/tests/run-make/pass-non-c-like-enum-to-c/rmake.rs b/tests/run-make/pass-non-c-like-enum-to-c/rmake.rs new file mode 100644 index 0000000000000..c706e82f4a0cc --- /dev/null +++ b/tests/run-make/pass-non-c-like-enum-to-c/rmake.rs @@ -0,0 +1,19 @@ +// Similar to the `return-non-c-like-enum-from-c` test, where +// the C code is the library, and the Rust code compiles +// into the executable. Once again, enum variants should be treated +// like an union of structs, which should prevent segfaults or +// unexpected results. The only difference with the aforementioned +// test is that the structs are passed into C directly through the +// `tt_add` and `t_add` function calls. +// See /~https://github.com/rust-lang/rust/issues/68190 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("test"); + rustc().input("nonclike.rs").arg("-ltest").run(); + run("nonclike"); +} diff --git a/tests/run-make/return-non-c-like-enum-from-c/Makefile b/tests/run-make/return-non-c-like-enum-from-c/Makefile deleted file mode 100644 index bd441d321bfab..0000000000000 --- a/tests/run-make/return-non-c-like-enum-from-c/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) nonclike.rs -L$(TMPDIR) -ltest - $(call RUN,nonclike) diff --git a/tests/run-make/return-non-c-like-enum-from-c/rmake.rs b/tests/run-make/return-non-c-like-enum-from-c/rmake.rs new file mode 100644 index 0000000000000..f24bd6d5fc763 --- /dev/null +++ b/tests/run-make/return-non-c-like-enum-from-c/rmake.rs @@ -0,0 +1,17 @@ +// A reversed version of the `return-non-c-like-enum` test, though +// this time, the C code is the library, and the Rust code compiles +// into the executable. Once again, enum variants should be treated +// like an union of structs, which should prevent segfaults or +// unexpected results. +// See /~https://github.com/rust-lang/rust/issues/68190 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("test"); + rustc().input("nonclike.rs").arg("-ltest").run(); + run("nonclike"); +}