diff options
Diffstat (limited to 'src/test/run-make')
115 files changed, 759 insertions, 109 deletions
diff --git a/src/test/run-make/const_fn_mir/Makefile b/src/test/run-make/const_fn_mir/Makefile index 2aa0bc9d4..ad5695093 100644 --- a/src/test/run-make/const_fn_mir/Makefile +++ b/src/test/run-make/const_fn_mir/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: $(RUSTC) main.rs --emit=mir -o "$(TMPDIR)"/dump.mir diff --git a/src/test/run-make/coverage-llvmir/filecheck.testprog.txt b/src/test/run-make/coverage-llvmir/filecheck.testprog.txt index 7a5f21922..c943261d7 100644 --- a/src/test/run-make/coverage-llvmir/filecheck.testprog.txt +++ b/src/test/run-make/coverage-llvmir/filecheck.testprog.txt @@ -9,7 +9,7 @@ CHECK-SAME: section "[[INSTR_PROF_COVFUN]]"[[COMDAT_IF_SUPPORTED]], align 8 CHECK: @__llvm_coverage_mapping = private constant CHECK-SAME: section "[[INSTR_PROF_COVMAP]]", align 8 -WINDOWS: @__llvm_profile_runtime = external global i32 +WINDOWS: @__llvm_profile_runtime = external{{.*}}global i32 CHECK: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called = {{private|internal}} global CHECK-SAME: section "[[INSTR_PROF_CNTS]]"{{.*}}, align 8 diff --git a/src/test/run-make/coverage-reports/Makefile b/src/test/run-make/coverage-reports/Makefile index 4e75672f2..6fc2a6bad 100644 --- a/src/test/run-make/coverage-reports/Makefile +++ b/src/test/run-make/coverage-reports/Makefile @@ -60,7 +60,7 @@ endif # for now, but it is effectively ignored for all tests that don't include this file anyway. # # (Note that it's also possible the `_counters.<test>.txt` and `<test>.json` files (if generated) -# may order results from multiple files inconsistently, which might also have to be accomodated +# may order results from multiple files inconsistently, which might also have to be accommodated # if and when we allow `llvm-cov` to produce results for multiple files. Note, the path separators # appear to be normalized to `/` in those files, thankfully.) LLVM_COV_IGNORE_FILES=\ @@ -75,7 +75,7 @@ ifdef RUSTC_BLESS_TEST rm -f expected_* endif --include clear_expected_if_blessed +include clear_expected_if_blessed %: $(SOURCEDIR)/lib/%.rs # Compile the test library with coverage instrumentation @@ -157,7 +157,7 @@ else # `// ignore-llvm-cov-show-diffs` anymore. This directive exists to work around a limitation # with `llvm-cov show`. When reporting coverage for multiple instantiations of a generic function, # with different type substitutions, `llvm-cov show` prints these in a non-deterministic order, - # breaking the `diff` comparision. + # breaking the `diff` comparison. # # A partial workaround is implemented below, with `diff --ignore-matching-lines=RE` # to ignore each line prefixing each generic instantiation coverage code region. diff --git a/src/test/run-make/coverage-reports/expected_show_coverage.async.txt b/src/test/run-make/coverage-reports/expected_show_coverage.async.txt index 2f69adbd8..87ccb6c43 100644 --- a/src/test/run-make/coverage-reports/expected_show_coverage.async.txt +++ b/src/test/run-make/coverage-reports/expected_show_coverage.async.txt @@ -55,7 +55,7 @@ 53| 1| 1 // This line appears covered, but the 1-character expression span covering the `1` ^0 54| 1| // is not executed. (`llvm-cov show` displays a `^0` below the `1` ). This is because - 55| 1| // `fn j()` executes the open brace for the funciton body, followed by the function's + 55| 1| // `fn j()` executes the open brace for the function body, followed by the function's 56| 1| // first executable statement, `match x`. Inner function declarations are not 57| 1| // "visible" to the MIR for `j()`, so the code region counts all lines between the 58| 1| // open brace and the first statement as executed, which is, in a sense, true. diff --git a/src/test/run-make/coverage-reports/expected_show_coverage.closure.txt b/src/test/run-make/coverage-reports/expected_show_coverage.closure.txt index 09ad276aa..e463099a5 100644 --- a/src/test/run-make/coverage-reports/expected_show_coverage.closure.txt +++ b/src/test/run-make/coverage-reports/expected_show_coverage.closure.txt @@ -37,7 +37,7 @@ 37| 0| countdown = 10; 38| 0| } 39| 0| "alt string 2".to_owned() - 40| | }; + 40| 0| }; 41| 1| println!( 42| 1| "The string or alt: {}" 43| 1| , @@ -79,7 +79,7 @@ 79| 0| countdown = 10; 80| 1| } 81| 1| "alt string 4".to_owned() - 82| | }; + 82| 1| }; 83| 1| println!( 84| 1| "The string or alt: {}" 85| 1| , @@ -101,7 +101,7 @@ 101| 0| countdown = 10; 102| 5| } 103| 5| format!("'{}'", val) - 104| | }; + 104| 5| }; 105| 1| println!( 106| 1| "Repeated, quoted string: {:?}" 107| 1| , @@ -125,7 +125,7 @@ 125| 0| countdown = 10; 126| 0| } 127| 0| "closure should be unused".to_owned() - 128| | }; + 128| 0| }; 129| | 130| 1| let mut countdown = 10; 131| 1| let _short_unused_closure = | _unused_arg: u8 | countdown += 1; @@ -177,7 +177,7 @@ 173| 0| println!( 174| 0| "not called: {}", 175| 0| if is_true { "check" } else { "me" } - 176| | ) + 176| 0| ) 177| | ; 178| | 179| 1| let short_used_not_covered_closure_line_break_block_embedded_branch = @@ -187,7 +187,7 @@ 183| 0| "not called: {}", 184| 0| if is_true { "check" } else { "me" } 185| | ) - 186| | } + 186| 0| } 187| | ; 188| | 189| 1| let short_used_covered_closure_line_break_no_block_embedded_branch = @@ -196,7 +196,7 @@ 192| 1| "not called: {}", 193| 1| if is_true { "check" } else { "me" } ^0 - 194| | ) + 194| 1| ) 195| | ; 196| | 197| 1| let short_used_covered_closure_line_break_block_embedded_branch = @@ -207,7 +207,7 @@ 202| 1| if is_true { "check" } else { "me" } ^0 203| | ) - 204| | } + 204| 1| } 205| | ; 206| | 207| 1| if is_false { diff --git a/src/test/run-make/coverage-reports/expected_show_coverage.doctest.txt b/src/test/run-make/coverage-reports/expected_show_coverage.doctest.txt index 7ae0e9788..732de6526 100644 --- a/src/test/run-make/coverage-reports/expected_show_coverage.doctest.txt +++ b/src/test/run-make/coverage-reports/expected_show_coverage.doctest.txt @@ -23,12 +23,6 @@ 22| 1|//! ``` 23| 2|//! #[derive(Debug, PartialEq)] ^1 - ------------------ - | Unexecuted instantiation: <rust_out::main::_doctest_main____coverage_doctest_rs_22_0::SomeError as core::cmp::PartialEq>::ne - ------------------ - | <rust_out::main::_doctest_main____coverage_doctest_rs_22_0::SomeError as core::cmp::PartialEq>::eq: - | 23| 2|//! #[derive(Debug, PartialEq)] - ------------------ 24| 1|//! struct SomeError { 25| 1|//! msg: String, 26| 1|//! } diff --git a/src/test/run-make/coverage-reports/expected_show_coverage.generator.txt b/src/test/run-make/coverage-reports/expected_show_coverage.generator.txt index d70e12e41..0fb3808ff 100644 --- a/src/test/run-make/coverage-reports/expected_show_coverage.generator.txt +++ b/src/test/run-make/coverage-reports/expected_show_coverage.generator.txt @@ -18,7 +18,7 @@ 17| 1| let mut generator = || { 18| 1| yield get_u32(is_true); 19| 1| return "foo"; - 20| | }; + 20| 1| }; 21| | 22| 1| match Pin::new(&mut generator).resume(()) { 23| 1| GeneratorState::Yielded(Ok(1)) => {} diff --git a/src/test/run-make/coverage-reports/expected_show_coverage.inline-dead.txt b/src/test/run-make/coverage-reports/expected_show_coverage.inline-dead.txt index effdef80e..a59fe1146 100644 --- a/src/test/run-make/coverage-reports/expected_show_coverage.inline-dead.txt +++ b/src/test/run-make/coverage-reports/expected_show_coverage.inline-dead.txt @@ -6,7 +6,7 @@ 6| 1| 7| 1| let f = |x: bool| { 8| | debug_assert!( - 9| | x + 9| 0| x 10| | ); 11| 1| }; 12| 1| f(false); diff --git a/src/test/run-make/coverage-reports/expected_show_coverage.issue-83601.txt b/src/test/run-make/coverage-reports/expected_show_coverage.issue-83601.txt index de32c88b7..25c74ab2e 100644 --- a/src/test/run-make/coverage-reports/expected_show_coverage.issue-83601.txt +++ b/src/test/run-make/coverage-reports/expected_show_coverage.issue-83601.txt @@ -2,12 +2,6 @@ 2| | 3| 3|#[derive(Debug, PartialEq, Eq)] ^2 - ------------------ - | <issue_83601::Foo as core::cmp::PartialEq>::eq: - | 3| 2|#[derive(Debug, PartialEq, Eq)] - ------------------ - | Unexecuted instantiation: <issue_83601::Foo as core::cmp::PartialEq>::ne - ------------------ 4| |struct Foo(u32); 5| | 6| 1|fn main() { diff --git a/src/test/run-make/coverage-reports/expected_show_coverage.issue-84561.txt b/src/test/run-make/coverage-reports/expected_show_coverage.issue-84561.txt index f24f7c694..4a60432c1 100644 --- a/src/test/run-make/coverage-reports/expected_show_coverage.issue-84561.txt +++ b/src/test/run-make/coverage-reports/expected_show_coverage.issue-84561.txt @@ -2,12 +2,6 @@ 2| | 3| |// expect-exit-status-101 4| 21|#[derive(PartialEq, Eq)] - ------------------ - | <issue_84561::Foo as core::cmp::PartialEq>::eq: - | 4| 21|#[derive(PartialEq, Eq)] - ------------------ - | Unexecuted instantiation: <issue_84561::Foo as core::cmp::PartialEq>::ne - ------------------ 5| |struct Foo(u32); 6| 1|fn test3() { 7| 1| let is_true = std::env::args().len() == 1; diff --git a/src/test/run-make/coverage-reports/expected_show_coverage.partial_eq.txt b/src/test/run-make/coverage-reports/expected_show_coverage.partial_eq.txt index fc2666533..a77175af6 100644 --- a/src/test/run-make/coverage-reports/expected_show_coverage.partial_eq.txt +++ b/src/test/run-make/coverage-reports/expected_show_coverage.partial_eq.txt @@ -3,11 +3,6 @@ 3| | 4| 2|#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] ^0 ^0 ^0 ^1 ^1 ^0^0 - ------------------ - | Unexecuted instantiation: <partial_eq::Version as core::cmp::PartialEq>::ne - ------------------ - | Unexecuted instantiation: <partial_eq::Version as core::cmp::PartialEq>::eq - ------------------ 5| |pub struct Version { 6| | major: usize, 7| | minor: usize, diff --git a/src/test/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt b/src/test/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt index dab31cbf4..748343885 100644 --- a/src/test/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt +++ b/src/test/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt @@ -61,12 +61,12 @@ 46| 4| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); 47| 4|} ------------------ - | used_inline_crate::used_only_from_this_lib_crate_generic_function::<alloc::vec::Vec<i32>>: + | used_inline_crate::used_only_from_this_lib_crate_generic_function::<&str>: | 45| 2|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) { | 46| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); | 47| 2|} ------------------ - | used_inline_crate::used_only_from_this_lib_crate_generic_function::<&str>: + | used_inline_crate::used_only_from_this_lib_crate_generic_function::<alloc::vec::Vec<i32>>: | 45| 2|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) { | 46| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); | 47| 2|} diff --git a/src/test/run-make/coverage-reports/expected_show_coverage.yield.txt b/src/test/run-make/coverage-reports/expected_show_coverage.yield.txt index 60a8d943f..6e2f23ee7 100644 --- a/src/test/run-make/coverage-reports/expected_show_coverage.yield.txt +++ b/src/test/run-make/coverage-reports/expected_show_coverage.yield.txt @@ -8,7 +8,7 @@ 8| 1| let mut generator = || { 9| 1| yield 1; 10| 1| return "foo" - 11| | }; + 11| 1| }; 12| | 13| 1| match Pin::new(&mut generator).resume(()) { 14| 1| GeneratorState::Yielded(1) => {} @@ -24,7 +24,7 @@ 24| 1| yield 2; 25| 0| yield 3; 26| 0| return "foo" - 27| | }; + 27| 0| }; 28| | 29| 1| match Pin::new(&mut generator).resume(()) { 30| 1| GeneratorState::Yielded(1) => {} diff --git a/src/test/run-make/coverage/async.rs b/src/test/run-make/coverage/async.rs index a6e387747..efd9e62d6 100644 --- a/src/test/run-make/coverage/async.rs +++ b/src/test/run-make/coverage/async.rs @@ -52,7 +52,7 @@ fn j(x: u8) { if x == 8 { 1 // This line appears covered, but the 1-character expression span covering the `1` // is not executed. (`llvm-cov show` displays a `^0` below the `1` ). This is because - // `fn j()` executes the open brace for the funciton body, followed by the function's + // `fn j()` executes the open brace for the function body, followed by the function's // first executable statement, `match x`. Inner function declarations are not // "visible" to the MIR for `j()`, so the code region counts all lines between the // open brace and the first statement as executed, which is, in a sense, true. diff --git a/src/test/run-make/dep-graph/Makefile b/src/test/run-make/dep-graph/Makefile index 88916022c..ae97b1672 100644 --- a/src/test/run-make/dep-graph/Makefile +++ b/src/test/run-make/dep-graph/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # ignore-cross-compile diff --git a/src/test/run-make/emit-named-files/Makefile b/src/test/run-make/emit-named-files/Makefile index 03eb83b97..e081fa479 100644 --- a/src/test/run-make/emit-named-files/Makefile +++ b/src/test/run-make/emit-named-files/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk OUT=$(TMPDIR)/emit diff --git a/src/test/run-make/emit-path-unhashed/Makefile b/src/test/run-make/emit-path-unhashed/Makefile index b6b2d8af6..c144d4aa9 100644 --- a/src/test/run-make/emit-path-unhashed/Makefile +++ b/src/test/run-make/emit-path-unhashed/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk OUT=$(TMPDIR)/emit diff --git a/src/test/run-make/emit-shared-files/Makefile b/src/test/run-make/emit-shared-files/Makefile index 9f46883be..09b4c29c1 100644 --- a/src/test/run-make/emit-shared-files/Makefile +++ b/src/test/run-make/emit-shared-files/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk INVOCATION_ONLY = $(TMPDIR)/invocation-only TOOLCHAIN_ONLY = $(TMPDIR)/toolchain-only diff --git a/src/test/run-make/env-dep-info/Makefile b/src/test/run-make/env-dep-info/Makefile index 25d9a31c2..1675a61b1 100644 --- a/src/test/run-make/env-dep-info/Makefile +++ b/src/test/run-make/env-dep-info/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC` # instead of hardcoding them everywhere they're needed. diff --git a/src/test/run-make/export-executable-symbols/Makefile b/src/test/run-make/export-executable-symbols/Makefile index 5006f9cb8..daa77c99d 100644 --- a/src/test/run-make/export-executable-symbols/Makefile +++ b/src/test/run-make/export-executable-symbols/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # ignore-wasm32 # ignore-wasm64 diff --git a/src/test/run-make/fmt-write-bloat/Makefile b/src/test/run-make/fmt-write-bloat/Makefile index 26e08086a..07e6e025e 100644 --- a/src/test/run-make/fmt-write-bloat/Makefile +++ b/src/test/run-make/fmt-write-bloat/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # ignore-windows diff --git a/src/test/run-make/issue-10971-temps-dir/Makefile b/src/test/run-make/issue-10971-temps-dir/Makefile index 5ce271926..e589bbffe 100644 --- a/src/test/run-make/issue-10971-temps-dir/Makefile +++ b/src/test/run-make/issue-10971-temps-dir/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # Regression test for issue #10971 # Running two invocations in parallel would overwrite each other's temp files. diff --git a/src/test/run-make/issue-47384/Makefile b/src/test/run-make/issue-47384/Makefile index f10365f8c..0aadf6c88 100644 --- a/src/test/run-make/issue-47384/Makefile +++ b/src/test/run-make/issue-47384/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-linux # ignore-cross-compile diff --git a/src/test/run-make/issue-71519/Makefile b/src/test/run-make/issue-71519/Makefile index 636665ec1..16d9a56e6 100644 --- a/src/test/run-make/issue-71519/Makefile +++ b/src/test/run-make/issue-71519/Makefile @@ -1,5 +1,6 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk +# ignore-msvc # needs-rust-lld all: RUSTC_LOG=rustc_codegen_ssa::back::link=info $(RUSTC) -Z gcc-ld=lld -C link-args=-Wl,-v main.rs 2> $(TMPDIR)/output.txt diff --git a/src/test/run-make/issue-85401-static-mir/Makefile b/src/test/run-make/issue-85401-static-mir/Makefile new file mode 100644 index 000000000..99590166b --- /dev/null +++ b/src/test/run-make/issue-85401-static-mir/Makefile @@ -0,0 +1,16 @@ +include ../../run-make-fulldeps/tools.mk + +# Regression test for issue #85401 +# Verify that we do not ICE when trying to access MIR for statics, +# but emit an error when linking. + +OUTPUT_FILE := $(TMPDIR)/build-output + +all: + $(RUSTC) --crate-type rlib --crate-name foo -Crelocation-model=pic --edition=2018 foo.rs -Zalways-encode-mir=yes --emit metadata -o $(TMPDIR)/libfoo.rmeta + $(RUSTC) --crate-type rlib --crate-name bar -Crelocation-model=pic --edition=2018 bar.rs -o $(TMPDIR)/libbar.rlib --extern=foo=$(TMPDIR)/libfoo.rmeta + $(RUSTC) --crate-type bin --crate-name baz -Crelocation-model=pic --edition=2018 baz.rs -o $(TMPDIR)/baz -L $(TMPDIR) --extern=bar=$(TMPDIR)/libbar.rlib > $(OUTPUT_FILE) 2>&1; [ $$? -eq 1 ] + cat $(OUTPUT_FILE) + $(CGREP) 'crate `foo` required to be available in rlib format, but was not found in this form' < $(OUTPUT_FILE) + # -v tests are fragile, hopefully this text won't change + $(CGREP) -v "internal compiler error" < $(OUTPUT_FILE) diff --git a/src/test/run-make/issue-85401-static-mir/bar.rs b/src/test/run-make/issue-85401-static-mir/bar.rs new file mode 100644 index 000000000..15b12ecf3 --- /dev/null +++ b/src/test/run-make/issue-85401-static-mir/bar.rs @@ -0,0 +1,4 @@ +pub fn bar() { + println!("bar {}", foo::FOO); + foo::foo(); +} diff --git a/src/test/run-make/issue-85401-static-mir/baz.rs b/src/test/run-make/issue-85401-static-mir/baz.rs new file mode 100644 index 000000000..2ff4c51e5 --- /dev/null +++ b/src/test/run-make/issue-85401-static-mir/baz.rs @@ -0,0 +1,3 @@ +fn main() { + bar::bar() +} diff --git a/src/test/run-make/issue-85401-static-mir/foo.rs b/src/test/run-make/issue-85401-static-mir/foo.rs new file mode 100644 index 000000000..d064c4546 --- /dev/null +++ b/src/test/run-make/issue-85401-static-mir/foo.rs @@ -0,0 +1,5 @@ +pub static FOO: &str = "foo"; + +pub fn foo() { + println!("foo"); +} diff --git a/src/test/run-make/issue-85441/Makefile b/src/test/run-make/issue-85441/Makefile index c7ae708c1..f04b07d51 100644 --- a/src/test/run-make/issue-85441/Makefile +++ b/src/test/run-make/issue-85441/Makefile @@ -1,6 +1,6 @@ # only-windows-msvc --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # Tests that WS2_32.dll is not unnecessarily linked, see issue #85441 diff --git a/src/test/run-make/issue-88756-default-output/Makefile b/src/test/run-make/issue-88756-default-output/Makefile index cacbcbf39..275c35c26 100644 --- a/src/test/run-make/issue-88756-default-output/Makefile +++ b/src/test/run-make/issue-88756-default-output/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: $(BARE_RUSTDOC) 2>&1 | sed -E 's@/nightly/|/beta/|/stable/|/1\.[0-9]+\.[0-9]+/@/$$CHANNEL/@g' | diff - output-default.stdout diff --git a/src/test/run-make/issue-96498/Makefile b/src/test/run-make/issue-96498/Makefile index eae6400ae..ce2b1b1ff 100644 --- a/src/test/run-make/issue-96498/Makefile +++ b/src/test/run-make/issue-96498/Makefile @@ -1,7 +1,7 @@ # only-windows # needs-rust-lld --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # Ensure that LLD can link all: diff --git a/src/test/run-make/libtest-thread-limit/Makefile b/src/test/run-make/libtest-thread-limit/Makefile index 29c1bc71d..d43a89e60 100644 --- a/src/test/run-make/libtest-thread-limit/Makefile +++ b/src/test/run-make/libtest-thread-limit/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-linux diff --git a/src/test/run-make/llvm-outputs/Makefile b/src/test/run-make/llvm-outputs/Makefile index d7f67577b..a3f25eba0 100644 --- a/src/test/run-make/llvm-outputs/Makefile +++ b/src/test/run-make/llvm-outputs/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: echo 'fn main() {}' | $(BARE_RUSTC) - --out-dir=$(TMPDIR)/random_directory_that_does_not_exist_ir/ --emit=llvm-ir diff --git a/src/test/run-make/native-link-modifier-bundle/Makefile b/src/test/run-make/native-link-modifier-bundle/Makefile index e4b0f74ac..7c78d7783 100644 --- a/src/test/run-make/native-link-modifier-bundle/Makefile +++ b/src/test/run-make/native-link-modifier-bundle/Makefile @@ -1,7 +1,7 @@ # ignore-cross-compile # ignore-windows-msvc --include ../../run-make-fulldeps/tools.mk +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. diff --git a/src/test/run-make/native-link-modifier-whole-archive/Makefile b/src/test/run-make/native-link-modifier-whole-archive/Makefile index 967cb065c..f26bd864c 100644 --- a/src/test/run-make/native-link-modifier-whole-archive/Makefile +++ b/src/test/run-make/native-link-modifier-whole-archive/Makefile @@ -8,7 +8,7 @@ # that code would never make it into the final executable and we'd thus be missing some # of the output. --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: $(TMPDIR)/$(call BIN,directly_linked) \ $(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive) \ diff --git a/src/test/run-make/pass-linker-flags-from-dep/Makefile b/src/test/run-make/pass-linker-flags-from-dep/Makefile index 365216b4c..b9426326a 100644 --- a/src/test/run-make/pass-linker-flags-from-dep/Makefile +++ b/src/test/run-make/pass-linker-flags-from-dep/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: # Build deps diff --git a/src/test/run-make/pass-linker-flags/Makefile b/src/test/run-make/pass-linker-flags/Makefile index 02b1e2179..a3efb8df6 100644 --- a/src/test/run-make/pass-linker-flags/Makefile +++ b/src/test/run-make/pass-linker-flags/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: $(RUSTC) rs.rs -Z unstable-options -l static=l1 -l link-arg=a1 -l static=l2 -l link-arg=a2 -l dylib=d1 -l link-arg=a3 --print link-args | $(CGREP) -e 'l1.*a1.*l2.*a2.*d1.*a3' diff --git a/src/test/run-make/raw-dylib-alt-calling-convention/Makefile b/src/test/run-make/raw-dylib-alt-calling-convention/Makefile index a254285ab..03f8778d2 100644 --- a/src/test/run-make/raw-dylib-alt-calling-convention/Makefile +++ b/src/test/run-make/raw-dylib-alt-calling-convention/Makefile @@ -3,7 +3,7 @@ # only-x86 # only-windows --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: $(RUSTC) --crate-type lib --crate-name raw_dylib_alt_calling_convention_test lib.rs diff --git a/src/test/run-make/raw-dylib-alt-calling-convention/extern.c b/src/test/run-make/raw-dylib-alt-calling-convention/extern.c index 0c4d12af9..344d4a6bf 100644 --- a/src/test/run-make/raw-dylib-alt-calling-convention/extern.c +++ b/src/test/run-make/raw-dylib-alt-calling-convention/extern.c @@ -70,6 +70,11 @@ __declspec(dllexport) void __stdcall stdcall_fn_9(uint8_t x, double y) { fflush(stdout); } +__declspec(dllexport) void __stdcall stdcall_fn_10(int i) { + printf("stdcall_fn_10(%d)\n", i); + fflush(stdout); +} + __declspec(dllexport) void __fastcall fastcall_fn_1(int i) { printf("fastcall_fn_1(%d)\n", i); fflush(stdout); @@ -122,6 +127,11 @@ __declspec(dllexport) void __fastcall fastcall_fn_9(uint8_t x, double y) { fflush(stdout); } +__declspec(dllexport) void __fastcall fastcall_fn_10(int i) { + printf("fastcall_fn_10(%d)\n", i); + fflush(stdout); +} + // GCC doesn't support vectorcall: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89485 #ifdef _MSC_VER __declspec(dllexport) void __vectorcall vectorcall_fn_1(int i) { @@ -175,4 +185,9 @@ __declspec(dllexport) void __vectorcall vectorcall_fn_9(uint8_t x, double y) { printf("vectorcall_fn_9(%d, %.1f)\n", x, y); fflush(stdout); } + +__declspec(dllexport) void __vectorcall vectorcall_fn_10(int i) { + printf("vectorcall_fn_10(%d)\n", i); + fflush(stdout); +} #endif diff --git a/src/test/run-make/raw-dylib-alt-calling-convention/lib.rs b/src/test/run-make/raw-dylib-alt-calling-convention/lib.rs index b5e9415b2..22f222c12 100644 --- a/src/test/run-make/raw-dylib-alt-calling-convention/lib.rs +++ b/src/test/run-make/raw-dylib-alt-calling-convention/lib.rs @@ -1,5 +1,5 @@ -#![feature(raw_dylib)] #![feature(abi_vectorcall)] +#![cfg_attr(target_arch = "x86", feature(raw_dylib))] #[repr(C)] #[derive(Clone)] @@ -32,6 +32,8 @@ extern "stdcall" { fn stdcall_fn_7(a: S2, b: i32); fn stdcall_fn_8(a: S3, b: S3); fn stdcall_fn_9(x: u8, y: f64); + #[link_name = "stdcall_fn_10"] + fn stdcall_fn_10_renamed(i: i32); } #[link(name = "extern", kind = "raw-dylib")] @@ -45,6 +47,8 @@ extern "fastcall" { fn fastcall_fn_7(a: S2, b: i32); fn fastcall_fn_8(a: S3, b: S3); fn fastcall_fn_9(x: u8, y: f64); + #[link_name = "fastcall_fn_10"] + fn fastcall_fn_10_renamed(i: i32); } #[cfg(target_env = "msvc")] @@ -59,6 +63,8 @@ extern "vectorcall" { fn vectorcall_fn_7(a: S2, b: i32); fn vectorcall_fn_8(a: S3, b: S3); fn vectorcall_fn_9(x: u8, y: f64); + #[link_name = "vectorcall_fn_10"] + fn vectorcall_fn_10_renamed(i: i32); } pub fn library_function(run_msvc_only: bool) { @@ -73,6 +79,7 @@ pub fn library_function(run_msvc_only: bool) { stdcall_fn_7(S2 { x: 15, y: 16 }, 3); stdcall_fn_8(S3 { x: [1, 2, 3, 4, 5] }, S3 { x: [6, 7, 8, 9, 10] }); stdcall_fn_9(1, 3.0); + stdcall_fn_10_renamed(19); fastcall_fn_1(14); fastcall_fn_2(16, 3.5); @@ -81,6 +88,7 @@ pub fn library_function(run_msvc_only: bool) { fastcall_fn_6(Some(&S { x: 10, y: 12 })); fastcall_fn_8(S3 { x: [1, 2, 3, 4, 5] }, S3 { x: [6, 7, 8, 9, 10] }); fastcall_fn_9(1, 3.0); + fastcall_fn_10_renamed(19); } else { // FIXME: 91167 // rustc generates incorrect code for the calls to fastcall_fn_5 and fastcall_fn_7 @@ -100,6 +108,7 @@ pub fn library_function(run_msvc_only: bool) { vectorcall_fn_7(S2 { x: 15, y: 16 }, 3); vectorcall_fn_8(S3 { x: [1, 2, 3, 4, 5] }, S3 { x: [6, 7, 8, 9, 10] }); vectorcall_fn_9(1, 3.0); + vectorcall_fn_10_renamed(19); } } } diff --git a/src/test/run-make/raw-dylib-alt-calling-convention/output.msvc.txt b/src/test/run-make/raw-dylib-alt-calling-convention/output.msvc.txt index 9ddd1b110..a216835c4 100644 --- a/src/test/run-make/raw-dylib-alt-calling-convention/output.msvc.txt +++ b/src/test/run-make/raw-dylib-alt-calling-convention/output.msvc.txt @@ -9,3 +9,4 @@ vectorcall_fn_6(S { x: 10, y: 12 }) vectorcall_fn_7(S2 { x: 15, y: 16 }, 3) vectorcall_fn_8(S3 { x: [1, 2, 3, 4, 5] }, S3 { x: [6, 7, 8, 9, 10] }) vectorcall_fn_9(1, 3.0) +vectorcall_fn_10(19) diff --git a/src/test/run-make/raw-dylib-alt-calling-convention/output.txt b/src/test/run-make/raw-dylib-alt-calling-convention/output.txt index 348bad63e..7622d3161 100644 --- a/src/test/run-make/raw-dylib-alt-calling-convention/output.txt +++ b/src/test/run-make/raw-dylib-alt-calling-convention/output.txt @@ -7,6 +7,7 @@ stdcall_fn_6(S { x: 10, y: 12 }) stdcall_fn_7(S2 { x: 15, y: 16 }, 3) stdcall_fn_8(S3 { x: [1, 2, 3, 4, 5] }, S3 { x: [6, 7, 8, 9, 10] }) stdcall_fn_9(1, 3.0) +stdcall_fn_10(19) fastcall_fn_1(14) fastcall_fn_2(16, 3.5) fastcall_fn_3(3.5) @@ -14,3 +15,4 @@ fastcall_fn_4(1, 2, 3.0) fastcall_fn_6(S { x: 10, y: 12 }) fastcall_fn_8(S3 { x: [1, 2, 3, 4, 5] }, S3 { x: [6, 7, 8, 9, 10] }) fastcall_fn_9(1, 3.0) +fastcall_fn_10(19) diff --git a/src/test/run-make/raw-dylib-c/Makefile b/src/test/run-make/raw-dylib-c/Makefile index 713f66507..f47ab24f4 100644 --- a/src/test/run-make/raw-dylib-c/Makefile +++ b/src/test/run-make/raw-dylib-c/Makefile @@ -2,7 +2,7 @@ # only-windows --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs diff --git a/src/test/run-make/raw-dylib-c/extern_1.c b/src/test/run-make/raw-dylib-c/extern_1.c index 72737c086..5d695547d 100644 --- a/src/test/run-make/raw-dylib-c/extern_1.c +++ b/src/test/run-make/raw-dylib-c/extern_1.c @@ -1,5 +1,7 @@ #include <stdio.h> +__declspec(dllexport) int extern_variable = 0; + __declspec(dllexport) void extern_fn_1() { printf("extern_fn_1\n"); fflush(stdout); @@ -10,7 +12,17 @@ __declspec(dllexport) void extern_fn_2() { fflush(stdout); } +__declspec(dllexport) void print_extern_variable() { + printf("extern_variable value: %d\n", extern_variable); + fflush(stdout); +} + __declspec(dllexport) void extern_fn_with_long_name() { printf("extern_fn_with_long_name; got the rename\n"); fflush(stdout); } + +__declspec(dllexport) void extern_fn_4() { + printf("extern_fn_4\n"); + fflush(stdout); +} diff --git a/src/test/run-make/raw-dylib-c/lib.rs b/src/test/run-make/raw-dylib-c/lib.rs index 58f7ccb38..005ffcdda 100644 --- a/src/test/run-make/raw-dylib-c/lib.rs +++ b/src/test/run-make/raw-dylib-c/lib.rs @@ -12,12 +12,23 @@ extern { pub fn library_function() { #[link(name = "extern_1", kind = "raw-dylib")] - extern { fn extern_fn_2(); } + extern { + fn extern_fn_2(); + fn print_extern_variable(); + static mut extern_variable: i32; + #[link_name = "extern_fn_4"] + fn extern_fn_4_renamed(); + } unsafe { extern_fn_1(); extern_fn_2(); extern_fn_3(); + extern_fn_4_renamed(); + extern_variable = 42; + print_extern_variable(); + extern_variable = -42; + print_extern_variable(); } } diff --git a/src/test/run-make/raw-dylib-c/output.txt b/src/test/run-make/raw-dylib-c/output.txt index 7800cba18..cc970cef7 100644 --- a/src/test/run-make/raw-dylib-c/output.txt +++ b/src/test/run-make/raw-dylib-c/output.txt @@ -1,3 +1,6 @@ extern_fn_1 extern_fn_2; didn't get the rename extern_fn_3 +extern_fn_4 +extern_variable value: 42 +extern_variable value: -42 diff --git a/src/test/run-make/raw-dylib-import-name-type/Makefile b/src/test/run-make/raw-dylib-import-name-type/Makefile new file mode 100644 index 000000000..fcc60e88e --- /dev/null +++ b/src/test/run-make/raw-dylib-import-name-type/Makefile @@ -0,0 +1,22 @@ +# Test the behavior of #[link(.., kind = "raw-dylib")] with alternative calling conventions. + +# only-x86 +# only-windows + +-include ../../run-make-fulldeps/tools.mk + +all: + $(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)" + $(call COMPILE_OBJ,"$(TMPDIR)"/extern.obj,extern.c) +ifdef IS_MSVC + $(CC) "$(TMPDIR)"/extern.obj extern.msvc.def -link -dll -out:"$(TMPDIR)"/extern.dll -noimplib +else + $(CC) "$(TMPDIR)"/extern.obj extern.gnu.def --no-leading-underscore -shared -o "$(TMPDIR)"/extern.dll +endif + "$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt + +ifdef RUSTC_BLESS_TEST + cp "$(TMPDIR)"/output.txt output.txt +else + $(DIFF) output.txt "$(TMPDIR)"/output.txt +endif diff --git a/src/test/run-make/raw-dylib-import-name-type/driver.rs b/src/test/run-make/raw-dylib-import-name-type/driver.rs new file mode 100644 index 000000000..a38849fc8 --- /dev/null +++ b/src/test/run-make/raw-dylib-import-name-type/driver.rs @@ -0,0 +1,125 @@ +#![feature(raw_dylib)] +#![feature(abi_vectorcall)] + +#[link(name = "extern", kind = "raw-dylib", import_name_type = "undecorated")] +extern "C" { + fn cdecl_fn_undecorated(i: i32); + #[link_name = "cdecl_fn_undecorated2"] + fn cdecl_fn_undecorated_renamed(i: i32); + static mut extern_variable_undecorated: i32; +} + +#[link(name = "extern", kind = "raw-dylib", import_name_type = "noprefix")] +extern "C" { + fn cdecl_fn_noprefix(i: i32); + static mut extern_variable_noprefix: i32; +} + +#[link(name = "extern", kind = "raw-dylib", import_name_type = "decorated")] +extern "C" { + fn cdecl_fn_decorated(i: i32); + static mut extern_variable_decorated: i32; +} + +#[link(name = "extern", kind = "raw-dylib", import_name_type = "undecorated")] +extern "stdcall" { + fn stdcall_fn_undecorated(i: i32); + #[link_name = "stdcall_fn_undecorated2"] + fn stdcall_fn_undecorated_renamed(i: i32); +} + +#[link(name = "extern", kind = "raw-dylib", import_name_type = "noprefix")] +extern "stdcall" { + fn stdcall_fn_noprefix(i: i32); +} + +#[link(name = "extern", kind = "raw-dylib", import_name_type = "decorated")] +extern "stdcall" { + fn stdcall_fn_decorated(i: i32); +} + +#[link(name = "extern", kind = "raw-dylib", import_name_type = "undecorated")] +extern "fastcall" { + fn fastcall_fn_undecorated(i: i32); + #[link_name = "fastcall_fn_undecorated2"] + fn fastcall_fn_undecorated_renamed(i: i32); +} + +#[link(name = "extern", kind = "raw-dylib", import_name_type = "noprefix")] +extern "fastcall" { + fn fastcall_fn_noprefix(i: i32); +} + +#[link(name = "extern", kind = "raw-dylib", import_name_type = "decorated")] +extern "fastcall" { + fn fastcall_fn_decorated(i: i32); +} + +#[cfg(target_env = "msvc")] +#[link(name = "extern", kind = "raw-dylib", import_name_type = "undecorated")] +extern "vectorcall" { + fn vectorcall_fn_undecorated(i: i32); + #[link_name = "vectorcall_fn_undecorated2"] + fn vectorcall_fn_undecorated_renamed(i: i32); +} + +#[cfg(target_env = "msvc")] +#[link(name = "extern", kind = "raw-dylib", import_name_type = "noprefix")] +extern "vectorcall" { + fn vectorcall_fn_noprefix(i: i32); +} + +#[cfg(target_env = "msvc")] +#[link(name = "extern", kind = "raw-dylib", import_name_type = "decorated")] +extern "vectorcall" { + fn vectorcall_fn_decorated(i: i32); +} + +#[link(name = "extern", kind = "raw-dylib")] +extern { + fn print_extern_variable_undecorated(); + fn print_extern_variable_noprefix(); + fn print_extern_variable_decorated(); +} + +pub fn main() { + unsafe { + cdecl_fn_undecorated(1); + cdecl_fn_undecorated_renamed(10); + cdecl_fn_noprefix(2); + cdecl_fn_decorated(3); + + stdcall_fn_undecorated(4); + stdcall_fn_undecorated_renamed(14); + stdcall_fn_noprefix(5); + stdcall_fn_decorated(6); + + fastcall_fn_undecorated(7); + fastcall_fn_undecorated_renamed(17); + fastcall_fn_noprefix(8); + fastcall_fn_decorated(9); + + extern_variable_undecorated = 42; + print_extern_variable_undecorated(); + extern_variable_noprefix = 43; + print_extern_variable_noprefix(); + extern_variable_decorated = 44; + print_extern_variable_decorated(); + + // GCC doesn't support vectorcall: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89485 + #[cfg(target_env = "msvc")] + { + vectorcall_fn_undecorated(10); + vectorcall_fn_undecorated_renamed(20); + vectorcall_fn_noprefix(11); + vectorcall_fn_decorated(12); + } + #[cfg(not(target_env = "msvc"))] + { + println!("vectorcall_fn_undecorated(10)"); + println!("vectorcall_fn_undecorated2(20)"); + println!("vectorcall_fn_noprefix(11)"); + println!("vectorcall_fn_decorated(12)"); + } + } +} diff --git a/src/test/run-make/raw-dylib-import-name-type/extern.c b/src/test/run-make/raw-dylib-import-name-type/extern.c new file mode 100644 index 000000000..195126d51 --- /dev/null +++ b/src/test/run-make/raw-dylib-import-name-type/extern.c @@ -0,0 +1,103 @@ +#include <stdio.h> +#include <stdint.h> + +void _cdecl cdecl_fn_undecorated(int i) { + printf("cdecl_fn_undecorated(%d)\n", i); + fflush(stdout); +} + +void _cdecl cdecl_fn_undecorated2(int i) { + printf("cdecl_fn_undecorated2(%d)\n", i); + fflush(stdout); +} + +void _cdecl cdecl_fn_noprefix(int i) { + printf("cdecl_fn_noprefix(%d)\n", i); + fflush(stdout); +} + +void _cdecl cdecl_fn_decorated(int i) { + printf("cdecl_fn_decorated(%d)\n", i); + fflush(stdout); +} + +void __stdcall stdcall_fn_undecorated(int i) { + printf("stdcall_fn_undecorated(%d)\n", i); + fflush(stdout); +} + +void __stdcall stdcall_fn_undecorated2(int i) { + printf("stdcall_fn_undecorated2(%d)\n", i); + fflush(stdout); +} + +void __stdcall stdcall_fn_noprefix(int i) { + printf("stdcall_fn_noprefix(%d)\n", i); + fflush(stdout); +} + +void __stdcall stdcall_fn_decorated(int i) { + printf("stdcall_fn_decorated(%d)\n", i); + fflush(stdout); +} + +void __fastcall fastcall_fn_undecorated(int i) { + printf("fastcall_fn_undecorated(%d)\n", i); + fflush(stdout); +} + +void __fastcall fastcall_fn_undecorated2(int i) { + printf("fastcall_fn_undecorated2(%d)\n", i); + fflush(stdout); +} + +void __fastcall fastcall_fn_noprefix(int i) { + printf("fastcall_fn_noprefix(%d)\n", i); + fflush(stdout); +} + +void __fastcall fastcall_fn_decorated(int i) { + printf("fastcall_fn_decorated(%d)\n", i); + fflush(stdout); +} + +int extern_variable_undecorated = 0; +__declspec(dllexport) void print_extern_variable_undecorated() { + printf("extern_variable_undecorated value: %d\n", extern_variable_undecorated); + fflush(stdout); +} + +int extern_variable_noprefix = 0; +__declspec(dllexport) void print_extern_variable_noprefix() { + printf("extern_variable_noprefix value: %d\n", extern_variable_noprefix); + fflush(stdout); +} + +int extern_variable_decorated = 0; +__declspec(dllexport) void print_extern_variable_decorated() { + printf("extern_variable_decorated value: %d\n", extern_variable_decorated); + fflush(stdout); +} + +// GCC doesn't support vectorcall: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89485 +#ifdef _MSC_VER +void __vectorcall vectorcall_fn_undecorated(int i) { + printf("vectorcall_fn_undecorated(%d)\n", i); + fflush(stdout); +} + +void __vectorcall vectorcall_fn_undecorated2(int i) { + printf("vectorcall_fn_undecorated2(%d)\n", i); + fflush(stdout); +} + +void __vectorcall vectorcall_fn_noprefix(int i) { + printf("vectorcall_fn_noprefix(%d)\n", i); + fflush(stdout); +} + +void __vectorcall vectorcall_fn_decorated(int i) { + printf("vectorcall_fn_decorated(%d)\n", i); + fflush(stdout); +} +#endif diff --git a/src/test/run-make/raw-dylib-import-name-type/extern.gnu.def b/src/test/run-make/raw-dylib-import-name-type/extern.gnu.def new file mode 100644 index 000000000..a523c959a --- /dev/null +++ b/src/test/run-make/raw-dylib-import-name-type/extern.gnu.def @@ -0,0 +1,21 @@ +LIBRARY extern +EXPORTS + cdecl_fn_undecorated + cdecl_fn_undecorated2 + cdecl_fn_noprefix + cdecl_fn_decorated + stdcall_fn_undecorated + stdcall_fn_undecorated2 + stdcall_fn_noprefix@4 + fastcall_fn_undecorated + fastcall_fn_undecorated2 + @fastcall_fn_decorated@4 + + ;ld doesn't handle fully-decorated stdcall, or no-prefix fastcall + _stdcall_fn_decorated@4=stdcall_fn_decorated@4 + fastcall_fn_noprefix@4=@fastcall_fn_noprefix@4 + + ;Variables are never decorated + extern_variable_undecorated + extern_variable_noprefix + extern_variable_decorated diff --git a/src/test/run-make/raw-dylib-import-name-type/extern.msvc.def b/src/test/run-make/raw-dylib-import-name-type/extern.msvc.def new file mode 100644 index 000000000..dbff32d4c --- /dev/null +++ b/src/test/run-make/raw-dylib-import-name-type/extern.msvc.def @@ -0,0 +1,25 @@ +LIBRARY extern +EXPORTS + cdecl_fn_undecorated + cdecl_fn_undecorated2 + cdecl_fn_noprefix + cdecl_fn_decorated + stdcall_fn_undecorated + stdcall_fn_undecorated2 + _stdcall_fn_decorated@4 + fastcall_fn_undecorated + fastcall_fn_undecorated2 + @fastcall_fn_decorated@4 + vectorcall_fn_undecorated + vectorcall_fn_undecorated2 + vectorcall_fn_decorated@@4 + vectorcall_fn_noprefix@@4 + + ;MSVC doesn't seem to recognize the "no prefix" syntax. + stdcall_fn_noprefix@4=_stdcall_fn_noprefix@4 + fastcall_fn_noprefix@4=@fastcall_fn_noprefix@4 + + ;Variables are never decorated + extern_variable_undecorated + extern_variable_noprefix + extern_variable_decorated diff --git a/src/test/run-make/raw-dylib-import-name-type/output.txt b/src/test/run-make/raw-dylib-import-name-type/output.txt new file mode 100644 index 000000000..707faf403 --- /dev/null +++ b/src/test/run-make/raw-dylib-import-name-type/output.txt @@ -0,0 +1,19 @@ +cdecl_fn_undecorated(1) +cdecl_fn_undecorated2(10) +cdecl_fn_noprefix(2) +cdecl_fn_decorated(3) +stdcall_fn_undecorated(4) +stdcall_fn_undecorated2(14) +stdcall_fn_noprefix(5) +stdcall_fn_decorated(6) +fastcall_fn_undecorated(7) +fastcall_fn_undecorated2(17) +fastcall_fn_noprefix(8) +fastcall_fn_decorated(9) +extern_variable_undecorated value: 42 +extern_variable_noprefix value: 43 +extern_variable_decorated value: 44 +vectorcall_fn_undecorated(10) +vectorcall_fn_undecorated2(20) +vectorcall_fn_noprefix(11) +vectorcall_fn_decorated(12) diff --git a/src/test/run-make/raw-dylib-inline-cross-dylib/Makefile b/src/test/run-make/raw-dylib-inline-cross-dylib/Makefile new file mode 100644 index 000000000..9e603f958 --- /dev/null +++ b/src/test/run-make/raw-dylib-inline-cross-dylib/Makefile @@ -0,0 +1,31 @@ +# Regression test for calling an inline function that uses a raw-dylib function. + +# only-windows + +include ../../run-make-fulldeps/tools.mk + +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" + # 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" + $(call COMPILE_OBJ,"$(TMPDIR)"/extern_1.obj,extern_1.c) + $(call COMPILE_OBJ,"$(TMPDIR)"/extern_2.obj,extern_2.c) +ifdef IS_MSVC + $(CC) "$(TMPDIR)"/extern_1.obj -link -dll -out:"$(TMPDIR)"/extern_1.dll -noimplib + $(CC) "$(TMPDIR)"/extern_2.obj -link -dll -out:"$(TMPDIR)"/extern_2.dll -noimplib +else + $(CC) "$(TMPDIR)"/extern_1.obj -shared -o "$(TMPDIR)"/extern_1.dll + $(CC) "$(TMPDIR)"/extern_2.obj -shared -o "$(TMPDIR)"/extern_2.dll +endif + $(call RUN,driver) > "$(TMPDIR)"/output.txt + +ifdef RUSTC_BLESS_TEST + cp "$(TMPDIR)"/output.txt output.txt +else + $(DIFF) output.txt "$(TMPDIR)"/output.txt +endif diff --git a/src/test/run-make/raw-dylib-inline-cross-dylib/driver.rs b/src/test/run-make/raw-dylib-inline-cross-dylib/driver.rs new file mode 100644 index 000000000..f72ded7d9 --- /dev/null +++ b/src/test/run-make/raw-dylib-inline-cross-dylib/driver.rs @@ -0,0 +1,21 @@ +#![feature(raw_dylib)] + +extern crate raw_dylib_test; +extern crate raw_dylib_test_wrapper; + +#[link(name = "extern_2", kind = "raw-dylib")] +extern { + fn extern_fn_2(); +} + +fn main() { + // NOTE: The inlined call to `extern_fn_2` links against the function in extern_2.dll instead + // of extern_1.dll since raw-dylib symbols from the current crate are passed to the linker + // first, so any ambiguous names will prefer the current crate's definition. + raw_dylib_test::inline_library_function(); + raw_dylib_test::library_function(); + raw_dylib_test_wrapper::inline_library_function_calls_inline(); + unsafe { + extern_fn_2(); + } +} diff --git a/src/test/run-make/raw-dylib-inline-cross-dylib/extern_1.c b/src/test/run-make/raw-dylib-inline-cross-dylib/extern_1.c new file mode 100644 index 000000000..e5baaf5f0 --- /dev/null +++ b/src/test/run-make/raw-dylib-inline-cross-dylib/extern_1.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +__declspec(dllexport) void extern_fn_1() { + printf("extern_fn_1\n"); + fflush(stdout); +} + +__declspec(dllexport) void extern_fn_2() { + printf("extern_fn_2 in extern_1\n"); + fflush(stdout); +} diff --git a/src/test/run-make/raw-dylib-inline-cross-dylib/extern_2.c b/src/test/run-make/raw-dylib-inline-cross-dylib/extern_2.c new file mode 100644 index 000000000..30aa46922 --- /dev/null +++ b/src/test/run-make/raw-dylib-inline-cross-dylib/extern_2.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +__declspec(dllexport) void extern_fn_2() { + printf("extern_fn_2 in extern_2\n"); + fflush(stdout); +} diff --git a/src/test/run-make/raw-dylib-inline-cross-dylib/lib.rs b/src/test/run-make/raw-dylib-inline-cross-dylib/lib.rs new file mode 100644 index 000000000..00c2c1c42 --- /dev/null +++ b/src/test/run-make/raw-dylib-inline-cross-dylib/lib.rs @@ -0,0 +1,21 @@ +#![feature(raw_dylib)] + +#[link(name = "extern_1", kind = "raw-dylib")] +extern { + fn extern_fn_1(); + fn extern_fn_2(); +} + +#[inline] +pub fn inline_library_function() { + unsafe { + extern_fn_1(); + extern_fn_2(); + } +} + +pub fn library_function() { + unsafe { + extern_fn_2(); + } +} diff --git a/src/test/run-make/raw-dylib-inline-cross-dylib/lib_wrapper.rs b/src/test/run-make/raw-dylib-inline-cross-dylib/lib_wrapper.rs new file mode 100644 index 000000000..47191b8de --- /dev/null +++ b/src/test/run-make/raw-dylib-inline-cross-dylib/lib_wrapper.rs @@ -0,0 +1,6 @@ +extern crate raw_dylib_test; + +#[inline] +pub fn inline_library_function_calls_inline() { + raw_dylib_test::inline_library_function(); +} diff --git a/src/test/run-make/raw-dylib-inline-cross-dylib/output.txt b/src/test/run-make/raw-dylib-inline-cross-dylib/output.txt new file mode 100644 index 000000000..e7009baa0 --- /dev/null +++ b/src/test/run-make/raw-dylib-inline-cross-dylib/output.txt @@ -0,0 +1,6 @@ +extern_fn_1 +extern_fn_2 in extern_2 +extern_fn_2 in extern_1 +extern_fn_1 +extern_fn_2 in extern_2 +extern_fn_2 in extern_2 diff --git a/src/test/run-make/raw-dylib-link-ordinal/Makefile b/src/test/run-make/raw-dylib-link-ordinal/Makefile index c9baa3c1e..b55a94dbc 100644 --- a/src/test/run-make/raw-dylib-link-ordinal/Makefile +++ b/src/test/run-make/raw-dylib-link-ordinal/Makefile @@ -2,7 +2,7 @@ # only-windows --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs diff --git a/src/test/run-make/raw-dylib-link-ordinal/exporter.c b/src/test/run-make/raw-dylib-link-ordinal/exporter.c index a9dd6da66..aabf32ff1 100644 --- a/src/test/run-make/raw-dylib-link-ordinal/exporter.c +++ b/src/test/run-make/raw-dylib-link-ordinal/exporter.c @@ -3,3 +3,10 @@ void exported_function() { printf("exported_function\n"); } + +int exported_variable = 0; + +void print_exported_variable() { + printf("exported_variable value: %d\n", exported_variable); + fflush(stdout); +} diff --git a/src/test/run-make/raw-dylib-link-ordinal/exporter.def b/src/test/run-make/raw-dylib-link-ordinal/exporter.def index 1a4b4c941..5d87c580a 100644 --- a/src/test/run-make/raw-dylib-link-ordinal/exporter.def +++ b/src/test/run-make/raw-dylib-link-ordinal/exporter.def @@ -1,3 +1,5 @@ LIBRARY exporter EXPORTS exported_function @13 NONAME + exported_variable @5 NONAME + print_exported_variable @9 NONAME diff --git a/src/test/run-make/raw-dylib-link-ordinal/lib.rs b/src/test/run-make/raw-dylib-link-ordinal/lib.rs index 20609caa5..bb25ac64c 100644 --- a/src/test/run-make/raw-dylib-link-ordinal/lib.rs +++ b/src/test/run-make/raw-dylib-link-ordinal/lib.rs @@ -1,13 +1,21 @@ -#![feature(raw_dylib)] +#![cfg_attr(target_arch = "x86", feature(raw_dylib))] #[link(name = "exporter", kind = "raw-dylib")] extern { #[link_ordinal(13)] fn imported_function(); + #[link_ordinal(5)] + static mut imported_variable: i32; + #[link_ordinal(9)] + fn print_imported_variable(); } pub fn library_function() { unsafe { imported_function(); + imported_variable = 42; + print_imported_variable(); + imported_variable = -42; + print_imported_variable(); } } diff --git a/src/test/run-make/raw-dylib-link-ordinal/output.txt b/src/test/run-make/raw-dylib-link-ordinal/output.txt index 2d0ed60f2..a4b2031d9 100644 --- a/src/test/run-make/raw-dylib-link-ordinal/output.txt +++ b/src/test/run-make/raw-dylib-link-ordinal/output.txt @@ -1 +1,3 @@ exported_function +exported_variable value: 42 +exported_variable value: -42 diff --git a/src/test/run-make/raw-dylib-stdcall-ordinal/Makefile b/src/test/run-make/raw-dylib-stdcall-ordinal/Makefile index 3360a97b5..b9deb7729 100644 --- a/src/test/run-make/raw-dylib-stdcall-ordinal/Makefile +++ b/src/test/run-make/raw-dylib-stdcall-ordinal/Makefile @@ -3,7 +3,7 @@ # only-x86 # only-windows --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs diff --git a/src/test/run-make/raw-dylib-stdcall-ordinal/lib.rs b/src/test/run-make/raw-dylib-stdcall-ordinal/lib.rs index 07dd3d7be..b7921396a 100644 --- a/src/test/run-make/raw-dylib-stdcall-ordinal/lib.rs +++ b/src/test/run-make/raw-dylib-stdcall-ordinal/lib.rs @@ -1,4 +1,4 @@ -#![feature(raw_dylib)] +#![cfg_attr(target_arch = "x86", feature(raw_dylib))] #[link(name = "exporter", kind = "raw-dylib")] extern "stdcall" { diff --git a/src/test/run-make/remap-path-prefix-dwarf/Makefile b/src/test/run-make/remap-path-prefix-dwarf/Makefile index 561a343d6..fbaea7b68 100644 --- a/src/test/run-make/remap-path-prefix-dwarf/Makefile +++ b/src/test/run-make/remap-path-prefix-dwarf/Makefile @@ -6,7 +6,7 @@ SRC_DIR := $(abspath .) SRC_DIR_PARENT := $(abspath ..) --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: \ abs_input_outside_working_dir \ diff --git a/src/test/run-make/rlib-format-packed-bundled-libs-2/Makefile b/src/test/run-make/rlib-format-packed-bundled-libs-2/Makefile new file mode 100644 index 000000000..4574cf17f --- /dev/null +++ b/src/test/run-make/rlib-format-packed-bundled-libs-2/Makefile @@ -0,0 +1,22 @@ +-include ../../run-make-fulldeps/tools.mk + +# ignore-cross-compile + +# Make sure -Zpacked_bundled_libs is compatible with verbatim. + +# 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: + # Build strange-named dep. + $(RUSTC) native_dep.rs --crate-type=staticlib -o $(TMPDIR)/native_dep.ext + + $(RUSTC) rust_dep.rs --crate-type=rlib -Zpacked_bundled_libs + $(NM) $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "U.*native_f1" + $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) "native_dep.ext" + + # Make sure compiler doesn't use files, that it shouldn't know about. + rm $(TMPDIR)/native_dep.ext + + $(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep.rlib -Zpacked_bundled_libs diff --git a/src/test/run-make/rlib-format-packed-bundled-libs-2/main.rs b/src/test/run-make/rlib-format-packed-bundled-libs-2/main.rs new file mode 100644 index 000000000..8d2b8a285 --- /dev/null +++ b/src/test/run-make/rlib-format-packed-bundled-libs-2/main.rs @@ -0,0 +1,5 @@ +extern crate rust_dep; + +pub fn main() { + rust_dep::rust_dep(); +} diff --git a/src/test/run-make/rlib-format-packed-bundled-libs-2/native_dep.rs b/src/test/run-make/rlib-format-packed-bundled-libs-2/native_dep.rs new file mode 100644 index 000000000..321a8237e --- /dev/null +++ b/src/test/run-make/rlib-format-packed-bundled-libs-2/native_dep.rs @@ -0,0 +1,4 @@ +#[no_mangle] +pub fn native_f1() -> i32 { + return 1; +} diff --git a/src/test/run-make/rlib-format-packed-bundled-libs-2/rust_dep.rs b/src/test/run-make/rlib-format-packed-bundled-libs-2/rust_dep.rs new file mode 100644 index 000000000..d99dda05c --- /dev/null +++ b/src/test/run-make/rlib-format-packed-bundled-libs-2/rust_dep.rs @@ -0,0 +1,11 @@ +#![feature(native_link_modifiers_verbatim)] +#[link(name = "native_dep.ext", kind = "static", modifiers = "+verbatim")] +extern "C" { + fn native_f1() -> i32; +} + +pub fn rust_dep() { + unsafe { + assert!(native_f1() == 1); + } +} diff --git a/src/test/run-make/rlib-format-packed-bundled-libs/Makefile b/src/test/run-make/rlib-format-packed-bundled-libs/Makefile new file mode 100644 index 000000000..0b991ac42 --- /dev/null +++ b/src/test/run-make/rlib-format-packed-bundled-libs/Makefile @@ -0,0 +1,34 @@ +-include ../../run-make-fulldeps/tools.mk + +# ignore-cross-compile + +# Make sure rlib format with -Zpacked_bundled_libs is correct. + +# 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) + $(RUSTC) rust_dep_up.rs --crate-type=rlib -Zpacked_bundled_libs + $(NM) $(TMPDIR)/librust_dep_up.rlib | $(CGREP) -e "U.*native_f2" + $(NM) $(TMPDIR)/librust_dep_up.rlib | $(CGREP) -e "U.*native_f3" + $(NM) $(TMPDIR)/librust_dep_up.rlib | $(CGREP) -e "T.*rust_dep_up" + $(AR) t $(TMPDIR)/librust_dep_up.rlib | $(CGREP) "native_dep_2" + $(AR) t $(TMPDIR)/librust_dep_up.rlib | $(CGREP) "native_dep_3" + $(RUSTC) rust_dep_local.rs --extern rlib=$(TMPDIR)/librust_dep_up.rlib -Zpacked_bundled_libs --crate-type=rlib + $(NM) $(TMPDIR)/librust_dep_local.rlib | $(CGREP) -e "U.*native_f1" + $(NM) $(TMPDIR)/librust_dep_local.rlib | $(CGREP) -e "T.*rust_dep_local" + $(AR) t $(TMPDIR)/librust_dep_local.rlib | $(CGREP) "native_dep_1" + + # Make sure compiler doesn't use files, that it shouldn't know about. + rm $(TMPDIR)/*native_dep_* + + $(RUSTC) main.rs --extern lib=$(TMPDIR)/librust_dep_local.rlib -o $(TMPDIR)/main.exe -Zpacked_bundled_libs --print link-args | $(CGREP) -e "native_dep_1.*native_dep_2.*native_dep_3" + +ifndef IS_MSVC + $(NM) $(TMPDIR)/main.exe | $(CGREP) -e "T.*native_f1" + $(NM) $(TMPDIR)/main.exe | $(CGREP) -e "T.*native_f2" + $(NM) $(TMPDIR)/main.exe | $(CGREP) -e "T.*native_f3" + $(NM) $(TMPDIR)/main.exe | $(CGREP) -e "T.*rust_dep_local" + $(NM) $(TMPDIR)/main.exe | $(CGREP) -e "T.*rust_dep_up" +endif diff --git a/src/test/run-make/rlib-format-packed-bundled-libs/main.rs b/src/test/run-make/rlib-format-packed-bundled-libs/main.rs new file mode 100644 index 000000000..042a4879f --- /dev/null +++ b/src/test/run-make/rlib-format-packed-bundled-libs/main.rs @@ -0,0 +1,4 @@ +extern crate rust_dep_local; +pub fn main() { + rust_dep_local::rust_dep_local(); +} diff --git a/src/test/run-make/rlib-format-packed-bundled-libs/native_dep_1.c b/src/test/run-make/rlib-format-packed-bundled-libs/native_dep_1.c new file mode 100644 index 000000000..07be8562c --- /dev/null +++ b/src/test/run-make/rlib-format-packed-bundled-libs/native_dep_1.c @@ -0,0 +1 @@ +int native_f1() { return 1; } diff --git a/src/test/run-make/rlib-format-packed-bundled-libs/native_dep_2.c b/src/test/run-make/rlib-format-packed-bundled-libs/native_dep_2.c new file mode 100644 index 000000000..a1b94e40d --- /dev/null +++ b/src/test/run-make/rlib-format-packed-bundled-libs/native_dep_2.c @@ -0,0 +1 @@ +int native_f2() { return 2; } diff --git a/src/test/run-make/rlib-format-packed-bundled-libs/native_dep_3.c b/src/test/run-make/rlib-format-packed-bundled-libs/native_dep_3.c new file mode 100644 index 000000000..f81f397a4 --- /dev/null +++ b/src/test/run-make/rlib-format-packed-bundled-libs/native_dep_3.c @@ -0,0 +1 @@ +int native_f3() { return 3; } diff --git a/src/test/run-make/rlib-format-packed-bundled-libs/rust_dep_local.rs b/src/test/run-make/rlib-format-packed-bundled-libs/rust_dep_local.rs new file mode 100644 index 000000000..8280c7d6c --- /dev/null +++ b/src/test/run-make/rlib-format-packed-bundled-libs/rust_dep_local.rs @@ -0,0 +1,13 @@ +#[link(name = "native_dep_1", kind = "static")] +extern "C" { + fn native_f1() -> i32; +} + +extern crate rust_dep_up; + +pub fn rust_dep_local() { + unsafe { + assert!(native_f1() == 1); + } + rust_dep_up::rust_dep_up(); +} diff --git a/src/test/run-make/rlib-format-packed-bundled-libs/rust_dep_up.rs b/src/test/run-make/rlib-format-packed-bundled-libs/rust_dep_up.rs new file mode 100644 index 000000000..edcd7c521 --- /dev/null +++ b/src/test/run-make/rlib-format-packed-bundled-libs/rust_dep_up.rs @@ -0,0 +1,13 @@ +#[link(name = "native_dep_2", kind = "static")] +#[link(name = "native_dep_3", kind = "static")] +extern "C" { + fn native_f2() -> i32; + fn native_f3() -> i32; +} + +pub fn rust_dep_up() { + unsafe { + assert!(native_f2() == 2); + assert!(native_f3() == 3); + } +} diff --git a/src/test/run-make/rustc-macro-dep-files/Makefile b/src/test/run-make/rustc-macro-dep-files/Makefile index a08a63fb4..6ae659db2 100644 --- a/src/test/run-make/rustc-macro-dep-files/Makefile +++ b/src/test/run-make/rustc-macro-dep-files/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC` # instead of hardcoding them everywhere they're needed. diff --git a/src/test/run-make/rustdoc-scrape-examples-invalid-expr/Makefile b/src/test/run-make/rustdoc-scrape-examples-invalid-expr/Makefile index dce8b83ee..7786ff762 100644 --- a/src/test/run-make/rustdoc-scrape-examples-invalid-expr/Makefile +++ b/src/test/run-make/rustdoc-scrape-examples-invalid-expr/Makefile @@ -1,5 +1,5 @@ deps := ex --include ../rustdoc-scrape-examples-multiple/scrape.mk +include ../rustdoc-scrape-examples-multiple/scrape.mk all: scrape diff --git a/src/test/run-make/rustdoc-scrape-examples-multiple/Makefile b/src/test/run-make/rustdoc-scrape-examples-multiple/Makefile index 897805e44..453a7d4bc 100644 --- a/src/test/run-make/rustdoc-scrape-examples-multiple/Makefile +++ b/src/test/run-make/rustdoc-scrape-examples-multiple/Makefile @@ -1,5 +1,5 @@ deps := ex ex2 --include ./scrape.mk +include ./scrape.mk all: scrape diff --git a/src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk b/src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk index d49b6c1f2..7a28d2145 100644 --- a/src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk +++ b/src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk OUTPUT_DIR := "$(TMPDIR)/rustdoc" diff --git a/src/test/run-make/rustdoc-scrape-examples-ordering/Makefile b/src/test/run-make/rustdoc-scrape-examples-ordering/Makefile index 339d539bf..bf45b8148 100644 --- a/src/test/run-make/rustdoc-scrape-examples-ordering/Makefile +++ b/src/test/run-make/rustdoc-scrape-examples-ordering/Makefile @@ -1,5 +1,5 @@ deps := ex1 ex2 --include ../rustdoc-scrape-examples-multiple/scrape.mk +include ../rustdoc-scrape-examples-multiple/scrape.mk all: scrape diff --git a/src/test/run-make/rustdoc-scrape-examples-remap/Makefile b/src/test/run-make/rustdoc-scrape-examples-remap/Makefile index dce8b83ee..7786ff762 100644 --- a/src/test/run-make/rustdoc-scrape-examples-remap/Makefile +++ b/src/test/run-make/rustdoc-scrape-examples-remap/Makefile @@ -1,5 +1,5 @@ deps := ex --include ../rustdoc-scrape-examples-multiple/scrape.mk +include ../rustdoc-scrape-examples-multiple/scrape.mk all: scrape diff --git a/src/test/run-make/rustdoc-scrape-examples-test/Makefile b/src/test/run-make/rustdoc-scrape-examples-test/Makefile index 9f80a8d96..1235ead67 100644 --- a/src/test/run-make/rustdoc-scrape-examples-test/Makefile +++ b/src/test/run-make/rustdoc-scrape-examples-test/Makefile @@ -1,6 +1,6 @@ extra_flags := --scrape-tests deps := ex --include ../rustdoc-scrape-examples-multiple/scrape.mk +include ../rustdoc-scrape-examples-multiple/scrape.mk all: scrape diff --git a/src/test/run-make/rustdoc-scrape-examples-whitespace/Makefile b/src/test/run-make/rustdoc-scrape-examples-whitespace/Makefile index dce8b83ee..7786ff762 100644 --- a/src/test/run-make/rustdoc-scrape-examples-whitespace/Makefile +++ b/src/test/run-make/rustdoc-scrape-examples-whitespace/Makefile @@ -1,5 +1,5 @@ deps := ex --include ../rustdoc-scrape-examples-multiple/scrape.mk +include ../rustdoc-scrape-examples-multiple/scrape.mk all: scrape diff --git a/src/test/run-make/rustdoc-with-out-dir-option/Makefile b/src/test/run-make/rustdoc-with-out-dir-option/Makefile index f79fce8ee..b3c3f5230 100644 --- a/src/test/run-make/rustdoc-with-out-dir-option/Makefile +++ b/src/test/run-make/rustdoc-with-out-dir-option/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk OUTPUT_DIR := "$(TMPDIR)/rustdoc" diff --git a/src/test/run-make/rustdoc-with-output-option/Makefile b/src/test/run-make/rustdoc-with-output-option/Makefile index 654f96725..02093a35c 100644 --- a/src/test/run-make/rustdoc-with-output-option/Makefile +++ b/src/test/run-make/rustdoc-with-output-option/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk OUTPUT_DIR := "$(TMPDIR)/rustdoc" diff --git a/src/test/run-make/rustdoc-with-short-out-dir-option/Makefile b/src/test/run-make/rustdoc-with-short-out-dir-option/Makefile index 1e9ba71de..dc5056a86 100644 --- a/src/test/run-make/rustdoc-with-short-out-dir-option/Makefile +++ b/src/test/run-make/rustdoc-with-short-out-dir-option/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk OUTPUT_DIR := "$(TMPDIR)/rustdoc" diff --git a/src/test/run-make/static-pie/Makefile b/src/test/run-make/static-pie/Makefile index 945ec1724..e71770636 100644 --- a/src/test/run-make/static-pie/Makefile +++ b/src/test/run-make/static-pie/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-x86_64 # only-linux diff --git a/src/test/run-make/thumb-none-cortex-m/Makefile b/src/test/run-make/thumb-none-cortex-m/Makefile index 13385369e..aa046af95 100644 --- a/src/test/run-make/thumb-none-cortex-m/Makefile +++ b/src/test/run-make/thumb-none-cortex-m/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # How to run this # $ ./x.py clean diff --git a/src/test/run-make/thumb-none-qemu/Makefile b/src/test/run-make/thumb-none-qemu/Makefile index ab8b90e15..328758d41 100644 --- a/src/test/run-make/thumb-none-qemu/Makefile +++ b/src/test/run-make/thumb-none-qemu/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-thumb diff --git a/src/test/run-make/track-path-dep-info/Makefile b/src/test/run-make/track-path-dep-info/Makefile index 465d37447..ee853943f 100644 --- a/src/test/run-make/track-path-dep-info/Makefile +++ b/src/test/run-make/track-path-dep-info/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC` # instead of hardcoding them everywhere they're needed. diff --git a/src/test/run-make/track-pgo-dep-info/Makefile b/src/test/run-make/track-pgo-dep-info/Makefile new file mode 100644 index 000000000..60b59c04a --- /dev/null +++ b/src/test/run-make/track-pgo-dep-info/Makefile @@ -0,0 +1,26 @@ +# needs-profiler-support +# ignore-windows-gnu + +-include ../../run-make-fulldeps/tools.mk + +# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC` +# instead of hardcoding them everywhere they're needed. +ifeq ($(IS_MUSL_HOST),1) +ADDITIONAL_ARGS := $(RUSTFLAGS) +endif + +all: + # Generate PGO profiles + $(BARE_RUSTC) $(ADDITIONAL_ARGS) -Cprofile-generate=$(TMPDIR)/profiles --out-dir $(TMPDIR) main.rs + $(TMPDIR)/main + + # Merge profiles + "$(LLVM_BIN_DIR)/llvm-profdata" merge \ + -o "$(TMPDIR)/merged.profdata" \ + "$(TMPDIR)/profiles" || exit 1 + + # Use the profile + $(RUSTC) -Cprofile-use=$(TMPDIR)/merged.profdata --emit dep-info main.rs + + # Check that profile file is in depinfo + $(CGREP) "merged.profdata" < $(TMPDIR)/main.d diff --git a/src/test/run-make/track-pgo-dep-info/main.rs b/src/test/run-make/track-pgo-dep-info/main.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/src/test/run-make/track-pgo-dep-info/main.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/src/test/run-make/translation/Makefile b/src/test/run-make/translation/Makefile index bfff75e7a..20e86c7f9 100644 --- a/src/test/run-make/translation/Makefile +++ b/src/test/run-make/translation/Makefile @@ -9,16 +9,29 @@ FAKEROOT=$(TMPDIR)/fakeroot all: normal custom sysroot -normal: basic-translation.rs +# Check that the test works normally, using the built-in fallback bundle. +normal: test.rs $(RUSTC) $< 2>&1 | grep "struct literal body without path" -custom: basic-translation.rs basic-translation.ftl - $(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/basic-translation.ftl 2>&1 | grep "this is a test message" +# Check that a primary bundle can be loaded and will be preferentially used +# where possible. +custom: test.rs working.ftl + $(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/working.ftl 2>&1 | grep "this is a test message" + +# Check that a primary bundle with a broken message (e.g. a interpolated +# variable is missing) will use the fallback bundle. +missing: test.rs missing.ftl + $(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/missing.ftl 2>&1 | grep "struct literal body without path" + +# Check that a primary bundle without the desired message will use the fallback +# bundle. +broken: test.rs broken.ftl + $(RUSTC) $< -Ztranslate-additional-ftl=$(CURDIR)/broken.ftl 2>&1 | grep "struct literal body without path" # Check that a locale can be loaded from the sysroot given a language # identifier by making a local copy of the sysroot and adding the custom locale # to it. -sysroot: basic-translation.rs basic-translation.ftl +sysroot: test.rs working.ftl mkdir $(FAKEROOT) ln -s $(SYSROOT)/* $(FAKEROOT) rm -f $(FAKEROOT)/lib @@ -31,7 +44,7 @@ sysroot: basic-translation.rs basic-translation.ftl mkdir $(FAKEROOT)/lib/rustlib/src ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src mkdir -p $(FAKEROOT)/share/locale/zh-CN/ - ln -s $(CURDIR)/basic-translation.ftl $(FAKEROOT)/share/locale/zh-CN/basic-translation.ftl + ln -s $(CURDIR)/working.ftl $(FAKEROOT)/share/locale/zh-CN/basic-translation.ftl $(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | grep "this is a test message" # Check that the compiler errors out when the sysroot requested cannot be @@ -43,7 +56,7 @@ sysroot-missing: # 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. -sysroot-invalid: basic-translation.rs basic-translation.ftl +sysroot-invalid: test.rs working.ftl mkdir $(FAKEROOT) ln -s $(SYSROOT)/* $(FAKEROOT) rm -f $(FAKEROOT)/lib diff --git a/src/test/run-make/translation/basic-translation.ftl b/src/test/run-make/translation/basic-translation.ftl deleted file mode 100644 index 4681b879c..000000000 --- a/src/test/run-make/translation/basic-translation.ftl +++ /dev/null @@ -1,2 +0,0 @@ -parser-struct-literal-body-without-path = this is a test message - .suggestion = this is a test suggestion diff --git a/src/test/run-make/translation/broken.ftl b/src/test/run-make/translation/broken.ftl new file mode 100644 index 000000000..4e3585835 --- /dev/null +++ b/src/test/run-make/translation/broken.ftl @@ -0,0 +1,3 @@ +# `foo` isn't provided by this diagnostic so it is expected that the fallback message is used. +parser_struct_literal_body_without_path = this is a {$foo} message + .suggestion = this is a test suggestion diff --git a/src/test/run-make/translation/missing.ftl b/src/test/run-make/translation/missing.ftl new file mode 100644 index 000000000..77bbda357 --- /dev/null +++ b/src/test/run-make/translation/missing.ftl @@ -0,0 +1,3 @@ +# `parser_struct_literal_body_without_path` isn't provided by this resource at all, so the +# fallback should be used. +foo = bar diff --git a/src/test/run-make/translation/basic-translation.rs b/src/test/run-make/translation/test.rs index b8f5bff31..b8f5bff31 100644 --- a/src/test/run-make/translation/basic-translation.rs +++ b/src/test/run-make/translation/test.rs diff --git a/src/test/run-make/translation/working.ftl b/src/test/run-make/translation/working.ftl new file mode 100644 index 000000000..d5ea86738 --- /dev/null +++ b/src/test/run-make/translation/working.ftl @@ -0,0 +1,2 @@ +parser_struct_literal_body_without_path = this is a test message + .suggestion = this is a test suggestion diff --git a/src/test/run-make/unstable-flag-required/Makefile b/src/test/run-make/unstable-flag-required/Makefile index b8769d5f6..d3a734fae 100644 --- a/src/test/run-make/unstable-flag-required/Makefile +++ b/src/test/run-make/unstable-flag-required/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk all: $(RUSTDOC) --output-format=json x.html 2>&1 | diff - output-format-json.stderr diff --git a/src/test/run-make/wasm-abi/Makefile b/src/test/run-make/wasm-abi/Makefile index 61fc4e8f5..e713ca187 100644 --- a/src/test/run-make/wasm-abi/Makefile +++ b/src/test/run-make/wasm-abi/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-wasm32-bare diff --git a/src/test/run-make/wasm-custom-section/Makefile b/src/test/run-make/wasm-custom-section/Makefile index 2f48b8525..92b0802e3 100644 --- a/src/test/run-make/wasm-custom-section/Makefile +++ b/src/test/run-make/wasm-custom-section/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-wasm32-bare diff --git a/src/test/run-make/wasm-custom-sections-opt/Makefile b/src/test/run-make/wasm-custom-sections-opt/Makefile index 76698c0aa..e5b45d963 100644 --- a/src/test/run-make/wasm-custom-sections-opt/Makefile +++ b/src/test/run-make/wasm-custom-sections-opt/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-wasm32-bare diff --git a/src/test/run-make/wasm-export-all-symbols/Makefile b/src/test/run-make/wasm-export-all-symbols/Makefile index 7e47ba485..834f4d258 100644 --- a/src/test/run-make/wasm-export-all-symbols/Makefile +++ b/src/test/run-make/wasm-export-all-symbols/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-wasm32-bare diff --git a/src/test/run-make/wasm-import-module/Makefile b/src/test/run-make/wasm-import-module/Makefile index fe63e66f2..18cef16aa 100644 --- a/src/test/run-make/wasm-import-module/Makefile +++ b/src/test/run-make/wasm-import-module/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-wasm32-bare diff --git a/src/test/run-make/wasm-panic-small/Makefile b/src/test/run-make/wasm-panic-small/Makefile index 68397e4bc..2af9f7135 100644 --- a/src/test/run-make/wasm-panic-small/Makefile +++ b/src/test/run-make/wasm-panic-small/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-wasm32-bare diff --git a/src/test/run-make/wasm-spurious-import/Makefile b/src/test/run-make/wasm-spurious-import/Makefile index 1bb59dc1b..6f50e6e55 100644 --- a/src/test/run-make/wasm-spurious-import/Makefile +++ b/src/test/run-make/wasm-spurious-import/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-wasm32-bare diff --git a/src/test/run-make/wasm-stringify-ints-small/Makefile b/src/test/run-make/wasm-stringify-ints-small/Makefile index 01e1c6b0c..2fa2c954d 100644 --- a/src/test/run-make/wasm-stringify-ints-small/Makefile +++ b/src/test/run-make/wasm-stringify-ints-small/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk ifeq ($(TARGET),wasm32-unknown-unknown) all: diff --git a/src/test/run-make/wasm-symbols-different-module/Makefile b/src/test/run-make/wasm-symbols-different-module/Makefile index bb6a5d3c9..9e657222d 100644 --- a/src/test/run-make/wasm-symbols-different-module/Makefile +++ b/src/test/run-make/wasm-symbols-different-module/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-wasm32-bare diff --git a/src/test/run-make/wasm-symbols-not-exported/Makefile b/src/test/run-make/wasm-symbols-not-exported/Makefile index 62bd0f087..60b0dee00 100644 --- a/src/test/run-make/wasm-symbols-not-exported/Makefile +++ b/src/test/run-make/wasm-symbols-not-exported/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-wasm32-bare diff --git a/src/test/run-make/wasm-symbols-not-imported/Makefile b/src/test/run-make/wasm-symbols-not-imported/Makefile index 7a923375c..dc7618c19 100644 --- a/src/test/run-make/wasm-symbols-not-imported/Makefile +++ b/src/test/run-make/wasm-symbols-not-imported/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk # only-wasm32-bare diff --git a/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile b/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile index 6a04d3439..84dcd2393 100644 --- a/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile +++ b/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile @@ -1,4 +1,4 @@ --include ../../run-make-fulldeps/tools.mk +include ../../run-make-fulldeps/tools.mk #only-x86_64-fortanix-unknown-sgx diff --git a/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh b/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh index 54645e9e2..944343df6 100644 --- a/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh +++ b/src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh @@ -45,7 +45,7 @@ check cc_plus_one_cxx cc_plus_one_cxx.checks check cc_plus_one_cxx_asm cc_plus_one_cxx_asm.checks check cc_plus_one_asm cc_plus_one_asm.checks \ || echo "warning: the cc crate forwards assembly files to the CC compiler." \ - "Clang uses its own intergrated assembler, which does not include the LVI passes." + "Clang uses its own integrated assembler, which does not include the LVI passes." check cmake_plus_one_c cmake_plus_one_c.checks check cmake_plus_one_c_asm cmake_plus_one_c_asm.checks |