diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /tests/run-make | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.tar.xz rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make')
21 files changed, 142 insertions, 11 deletions
diff --git a/tests/run-make/incremental-session-fail/Makefile b/tests/run-make/incremental-session-fail/Makefile index 0461bb926..6ce137092 100644 --- a/tests/run-make/incremental-session-fail/Makefile +++ b/tests/run-make/incremental-session-fail/Makefile @@ -9,6 +9,6 @@ all: touch $(SESSION_DIR) # Check exit code is 1 for an error, and not 101 for ICE. $(RUSTC) foo.rs --crate-type=rlib -C incremental=$(SESSION_DIR) > $(OUTPUT_FILE) 2>&1; [ $$? -eq 1 ] - $(CGREP) "Could not create incremental compilation crate directory" < $(OUTPUT_FILE) + $(CGREP) "could not create incremental compilation crate directory" < $(OUTPUT_FILE) # -v tests are fragile, hopefully this text won't change $(CGREP) -v "internal compiler error" < $(OUTPUT_FILE) diff --git a/tests/run-make/native-link-modifier-bundle/Makefile b/tests/run-make/native-link-modifier-bundle/Makefile index 7c78d7783..e8a1121bf 100644 --- a/tests/run-make/native-link-modifier-bundle/Makefile +++ b/tests/run-make/native-link-modifier-bundle/Makefile @@ -5,7 +5,12 @@ include ../../run-make-fulldeps/tools.mk # We're using the llvm-nm instead of the system nm to ensure it is compatible # with the LLVM bitcode generated by rustc. +# Except on Windows where piping/IO redirection under MSYS2 is wonky with llvm-nm. +ifndef IS_WINDOWS NM = "$(LLVM_BIN_DIR)"/llvm-nm +else +NM = nm +endif all: $(call NATIVE_STATICLIB,native-staticlib) # Build a staticlib and a rlib, the `native_func` symbol will be bundled into them diff --git a/tests/run-make/no-input-file/Makefile b/tests/run-make/no-input-file/Makefile new file mode 100644 index 000000000..2f0215922 --- /dev/null +++ b/tests/run-make/no-input-file/Makefile @@ -0,0 +1,4 @@ +include ../../run-make-fulldeps/tools.mk + +all: + $(RUSTC) --print crate-name 2>&1 | diff - no-input-file.stderr diff --git a/tests/run-make/no-input-file/no-input-file.stderr b/tests/run-make/no-input-file/no-input-file.stderr new file mode 100644 index 000000000..b843eb524 --- /dev/null +++ b/tests/run-make/no-input-file/no-input-file.stderr @@ -0,0 +1,2 @@ +error: no input filename given + diff --git a/tests/run-make/overwrite-input/Makefile b/tests/run-make/overwrite-input/Makefile new file mode 100644 index 000000000..03b03eb14 --- /dev/null +++ b/tests/run-make/overwrite-input/Makefile @@ -0,0 +1,13 @@ +include ../../run-make-fulldeps/tools.mk + +all: + $(RUSTC) main.rs -o main.rs 2> $(TMPDIR)/file.stderr || echo "failed successfully" + $(RUSTC) main.rs -o . 2> $(TMPDIR)/folder.stderr || echo "failed successfully" + +ifdef RUSTC_BLESS_TEST + cp "$(TMPDIR)"/file.stderr file.stderr + cp "$(TMPDIR)"/folder.stderr folder.stderr +else + $(DIFF) file.stderr "$(TMPDIR)"/file.stderr + $(DIFF) folder.stderr "$(TMPDIR)"/folder.stderr +endif diff --git a/tests/run-make/overwrite-input/file.stderr b/tests/run-make/overwrite-input/file.stderr new file mode 100644 index 000000000..9936962b4 --- /dev/null +++ b/tests/run-make/overwrite-input/file.stderr @@ -0,0 +1,6 @@ +warning: ignoring --out-dir flag due to -o flag + +error: the input file "main.rs" would be overwritten by the generated executable + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/run-make/overwrite-input/folder.stderr b/tests/run-make/overwrite-input/folder.stderr new file mode 100644 index 000000000..81b1e7367 --- /dev/null +++ b/tests/run-make/overwrite-input/folder.stderr @@ -0,0 +1,6 @@ +warning: ignoring --out-dir flag due to -o flag + +error: the generated executable for the input file "main.rs" conflicts with the existing directory "." + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/run-make/overwrite-input/main.rs b/tests/run-make/overwrite-input/main.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/tests/run-make/overwrite-input/main.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/tests/run-make/overwrite-input/main.stderr b/tests/run-make/overwrite-input/main.stderr new file mode 100644 index 000000000..9936962b4 --- /dev/null +++ b/tests/run-make/overwrite-input/main.stderr @@ -0,0 +1,6 @@ +warning: ignoring --out-dir flag due to -o flag + +error: the input file "main.rs" would be overwritten by the generated executable + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/run-make/raw-dylib-inline-cross-dylib/Makefile b/tests/run-make/raw-dylib-inline-cross-dylib/Makefile index 9e603f958..722a49b02 100644 --- a/tests/run-make/raw-dylib-inline-cross-dylib/Makefile +++ b/tests/run-make/raw-dylib-inline-cross-dylib/Makefile @@ -4,15 +4,19 @@ include ../../run-make-fulldeps/tools.mk +# We'd be using the llvm-objdump instead of the system objdump to ensure compatibility +# with the LLVM bitcode generated by rustc but on Windows piping/IO redirection under MSYS2 is wonky with llvm-objdump. +OBJDUMP = objdump + all: $(RUSTC) --crate-type dylib --crate-name raw_dylib_test lib.rs -C prefer-dynamic $(RUSTC) --crate-type dylib --crate-name raw_dylib_test_wrapper lib_wrapper.rs -C prefer-dynamic $(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)" -C prefer-dynamic # Make sure we don't find an import to the functions we expect to be inlined. - "$(LLVM_BIN_DIR)"/llvm-objdump -p $(TMPDIR)/driver.exe | $(CGREP) -v -e "inline_library_function" - "$(LLVM_BIN_DIR)"/llvm-objdump -p $(TMPDIR)/driver.exe | $(CGREP) -v -e "inline_library_function_calls_inline" + $(OBJDUMP) -p $(TMPDIR)/driver.exe | $(CGREP) -v -e "inline_library_function" + $(OBJDUMP) -p $(TMPDIR)/driver.exe | $(CGREP) -v -e "inline_library_function_calls_inline" # Make sure we do find an import to the functions we expect to be imported. - "$(LLVM_BIN_DIR)"/llvm-objdump -p $(TMPDIR)/driver.exe | $(CGREP) -e "library_function" + $(OBJDUMP) -p $(TMPDIR)/driver.exe | $(CGREP) -e "library_function" $(call COMPILE_OBJ,"$(TMPDIR)"/extern_1.obj,extern_1.c) $(call COMPILE_OBJ,"$(TMPDIR)"/extern_2.obj,extern_2.c) ifdef IS_MSVC diff --git a/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile b/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile index 4574cf17f..37b8d809a 100644 --- a/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile +++ b/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile @@ -6,7 +6,12 @@ # We're using the llvm-nm instead of the system nm to ensure it is compatible # with the LLVM bitcode generated by rustc. +# Except on Windows where piping/IO redirection under MSYS2 is wonky with llvm-nm. +ifndef IS_WINDOWS NM = "$(LLVM_BIN_DIR)"/llvm-nm +else +NM = nm +endif all: # Build strange-named dep. diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile b/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile new file mode 100644 index 000000000..62dc1b5f6 --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile @@ -0,0 +1,35 @@ +-include ../../run-make-fulldeps/tools.mk + +# ignore-cross-compile +# only-linux + +# Make sure -Zpacked_bundled_libs-like behavior activates with whole-archive. + +# We're using the llvm-nm instead of the system nm to ensure it is compatible +# with the LLVM bitcode generated by rustc. +NM = "$(LLVM_BIN_DIR)"/llvm-nm + +all: $(call NATIVE_STATICLIB,native_dep_1) $(call NATIVE_STATICLIB,native_dep_2) $(call NATIVE_STATICLIB,native_dep_3) $(call NATIVE_STATICLIB,native_dep_4) + # test cfg with packed bundle + $(RUSTC) rust_dep_cfg.rs --crate-type=rlib -Zpacked_bundled_libs + $(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep_cfg.rlib --crate-type=staticlib --cfg should_add + $(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_1.a" + $(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_2.a" + $(AR) t $(TMPDIR)/libmain.a | $(CGREP) -e "libnative_dep_1.o" + $(AR) t $(TMPDIR)/libmain.a | $(CGREP) -ev "libnative_dep_2.o" + + + # test bundle with whole_archive + $(RUSTC) rust_dep.rs --crate-type=rlib + $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "native_dep_1" + $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "native_dep_3" + $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -ev "native_dep_2" + $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -ev "native_dep_4" + + # Make sure compiler doesn't use files, that it shouldn't know about. + rm $(TMPDIR)/libnative_dep_1.a + rm $(TMPDIR)/libnative_dep_3.a + + $(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep.rlib --print link-args > $(TMPDIR)/link_args + cat $(TMPDIR)/link_args | $(CGREP) -ev "native_dep_3" + cat $(TMPDIR)/link_args | $(CGREP) -e "--whole-archive.*native_dep_1.*--whole-archive.*lnative_dep_2.*no-whole-archive.*lnative_dep_4" diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/main.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/main.rs new file mode 100644 index 000000000..8d2b8a285 --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/main.rs @@ -0,0 +1,5 @@ +extern crate rust_dep; + +pub fn main() { + rust_dep::rust_dep(); +} diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c new file mode 100644 index 000000000..07be8562c --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c @@ -0,0 +1 @@ +int native_f1() { return 1; } diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c new file mode 100644 index 000000000..a1b94e40d --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c @@ -0,0 +1 @@ +int native_f2() { return 2; } diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c new file mode 100644 index 000000000..f81f397a4 --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c @@ -0,0 +1 @@ +int native_f3() { return 3; } diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c new file mode 100644 index 000000000..14d41d60b --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c @@ -0,0 +1 @@ +int native_f4() { return 4; } diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs new file mode 100644 index 000000000..abd846b68 --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs @@ -0,0 +1,16 @@ +#![feature(packed_bundled_libs)] + +#[link(name = "native_dep_1", kind = "static", modifiers = "+whole-archive,+bundle")] +extern "C" {} + +#[link(name = "native_dep_2", kind = "static", modifiers = "+whole-archive,-bundle")] +extern "C" {} + +#[link(name = "native_dep_3", kind = "static", modifiers = "+bundle")] +extern "C" {} + +#[link(name = "native_dep_4", kind = "static", modifiers = "-bundle")] +extern "C" {} + +#[no_mangle] +pub fn rust_dep() {} diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs new file mode 100644 index 000000000..506ca62a8 --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs @@ -0,0 +1,10 @@ +#![feature(link_cfg)] + +#[link(name = "native_dep_1", kind = "static", cfg(should_add))] +extern "C" {} + +#[link(name = "native_dep_2", kind = "static", cfg(should_not_add))] +extern "C" {} + +#[no_mangle] +pub fn rust_dep() {} diff --git a/tests/run-make/rlib-format-packed-bundled-libs/Makefile b/tests/run-make/rlib-format-packed-bundled-libs/Makefile index 0b991ac42..7fb6ce8d1 100644 --- a/tests/run-make/rlib-format-packed-bundled-libs/Makefile +++ b/tests/run-make/rlib-format-packed-bundled-libs/Makefile @@ -6,7 +6,12 @@ # We're using the llvm-nm instead of the system nm to ensure it is compatible # with the LLVM bitcode generated by rustc. +# Except on Windows where piping/IO redirection under MSYS2 is wonky with llvm-nm. +ifndef IS_WINDOWS NM = "$(LLVM_BIN_DIR)"/llvm-nm +else +NM = nm +endif all: $(call NATIVE_STATICLIB,native_dep_1) $(call NATIVE_STATICLIB,native_dep_2) $(call NATIVE_STATICLIB,native_dep_3) $(RUSTC) rust_dep_up.rs --crate-type=rlib -Zpacked_bundled_libs diff --git a/tests/run-make/translation/Makefile b/tests/run-make/translation/Makefile index 20e86c7f9..5b0b331ca 100644 --- a/tests/run-make/translation/Makefile +++ b/tests/run-make/translation/Makefile @@ -6,8 +6,10 @@ include ../../run-make-fulldeps/tools.mk SYSROOT:=$(shell $(RUSTC) --print sysroot) FAKEROOT=$(TMPDIR)/fakeroot +RUSTC_LOG:=rustc_error_messages +export RUSTC_TRANSLATION_NO_DEBUG_ASSERT:=1 -all: normal custom sysroot +all: normal custom missing broken sysroot sysroot-invalid sysroot-missing # Check that the test works normally, using the built-in fallback bundle. normal: test.rs @@ -32,6 +34,7 @@ broken: test.rs broken.ftl # identifier by making a local copy of the sysroot and adding the custom locale # to it. sysroot: test.rs working.ftl + rm -rf $(FAKEROOT) mkdir $(FAKEROOT) ln -s $(SYSROOT)/* $(FAKEROOT) rm -f $(FAKEROOT)/lib @@ -51,12 +54,12 @@ sysroot: test.rs working.ftl # found. This test might start failing if there actually exists a Klingon # translation of rustc's error messages. sysroot-missing: - $(RUSTC) $< -Ztranslate-lang=tlh 2>&1 || grep "missing locale directory" + $(RUSTC) $< -Ztranslate-lang=tlh 2>&1 | grep "missing locale directory" -# Check that the compiler errors out when the sysroot requested cannot be -# found. This test might start failing if there actually exists a Klingon -# translation of rustc's error messages. +# Check that the compiler errors out when the directory for the locale in the +# sysroot is actually a file. sysroot-invalid: test.rs working.ftl + rm -rf $(FAKEROOT) mkdir $(FAKEROOT) ln -s $(SYSROOT)/* $(FAKEROOT) rm -f $(FAKEROOT)/lib @@ -68,5 +71,6 @@ sysroot-invalid: test.rs working.ftl rm -f $(FAKEROOT)/lib/rustlib/src mkdir $(FAKEROOT)/lib/rustlib/src ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src - touch $(FAKEROOT)/share/locale/zh-CN/ - $(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 || grep "`\$sysroot/share/locales/\$locale` is not a directory" + mkdir -p $(FAKEROOT)/share/locale + touch $(FAKEROOT)/share/locale/zh-CN + $(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | grep "`\$sysroot/share/locales/\$locale` is not a directory" |