rewrite static-dylib-by-default to rmake

This commit is contained in:
Oneirical 2024-07-22 16:22:34 -04:00
parent d111ccdb61
commit 952d916840
3 changed files with 25 additions and 18 deletions

View File

@ -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

View File

@ -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)

View File

@ -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");
}