From 952d916840cc9e2a08ee7ac4a5db837b9f22e115 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 22 Jul 2024 16:22:34 -0400 Subject: [PATCH] rewrite static-dylib-by-default to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../run-make/static-dylib-by-default/Makefile | 17 ------------- .../run-make/static-dylib-by-default/rmake.rs | 25 +++++++++++++++++++ 3 files changed, 25 insertions(+), 18 deletions(-) delete mode 100644 tests/run-make/static-dylib-by-default/Makefile create mode 100644 tests/run-make/static-dylib-by-default/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 158d5cc8ade..eecaa193b46 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -77,7 +77,6 @@ run-make/share-generics-dylib/Makefile run-make/simd-ffi/Makefile run-make/split-debuginfo/Makefile run-make/stable-symbol-names/Makefile -run-make/static-dylib-by-default/Makefile run-make/staticlib-dylib-linkage/Makefile run-make/symbol-mangling-hashed/Makefile run-make/symbol-visibility/Makefile diff --git a/tests/run-make/static-dylib-by-default/Makefile b/tests/run-make/static-dylib-by-default/Makefile deleted file mode 100644 index cdaab42d06c..00000000000 --- a/tests/run-make/static-dylib-by-default/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -TO_LINK := $(call DYLIB,bar) -ifdef IS_MSVC -LINK_ARG = $(TO_LINK:dll=dll.lib) -else -LINK_ARG = $(TO_LINK) -endif - -all: - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(CC) main.c $(call OUT_EXE,main) $(LINK_ARG) $(EXTRACFLAGS) - rm $(TMPDIR)/*.rlib - rm $(call DYLIB,foo) - $(call RUN,main) diff --git a/tests/run-make/static-dylib-by-default/rmake.rs b/tests/run-make/static-dylib-by-default/rmake.rs new file mode 100644 index 00000000000..70f3815bdef --- /dev/null +++ b/tests/run-make/static-dylib-by-default/rmake.rs @@ -0,0 +1,25 @@ +// If a dylib is being produced, the compiler will first check to see if it can +// be created entirely statically before falling back to dynamic dependencies. This +// behavior can be overridden with `-C prefer-dynamic`. +// In this test, bar depends on foo and is compiled fully statically despite the available +// `foo` dynamic library. This allows the main binary to be executed in the final step. +// See https://github.com/rust-lang/rust/commit/3036b001276a6e43409b08b7f2334ce72aeeb036 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed +//FIXME(Oneirical): try on msvc, not because of an ignore but because i did wonky things + +use run_make_support::{ + cc, cwd, dynamic_lib_name, extra_c_flags, has_extension, rfs, run, rustc, shallow_find_files, +}; + +fn main() { + rustc().input("foo.rs").run(); + rustc().input("bar.rs").run(); + cc().input("main.c").out_exe("main").arg(dynamic_lib_name("bar")).args(extra_c_flags()).run(); + for rlib in shallow_find_files(cwd(), |path| has_extension(path, "rlib")) { + rfs::remove_file(rlib); + } + rfs::remove_file(dynamic_lib_name("foo")); + run("main"); +}