From 37599b2072cba572ae9dcf7d1be1445f46f8125c Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 9 Jul 2024 16:13:45 -0400 Subject: [PATCH 1/3] rewrite and rename issue-83112-incr-test-moved-file to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../main.rs | 0 tests/run-make/incr-test-moved-file/rmake.rs | 27 +++++++++++++++++++ .../issue-83112-incr-test-moved-file/Makefile | 25 ----------------- 4 files changed, 27 insertions(+), 26 deletions(-) rename tests/run-make/{issue-83112-incr-test-moved-file => incr-test-moved-file}/main.rs (100%) create mode 100644 tests/run-make/incr-test-moved-file/rmake.rs delete mode 100644 tests/run-make/issue-83112-incr-test-moved-file/Makefile diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index d26d6fe360dc7..f71992cad233f 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -62,7 +62,6 @@ run-make/issue-36710/Makefile run-make/issue-47551/Makefile run-make/issue-69368/Makefile run-make/issue-83045/Makefile -run-make/issue-83112-incr-test-moved-file/Makefile run-make/issue-84395-lto-embed-bitcode/Makefile run-make/issue-85019-moved-src-dir/Makefile run-make/issue-85401-static-mir/Makefile diff --git a/tests/run-make/issue-83112-incr-test-moved-file/main.rs b/tests/run-make/incr-test-moved-file/main.rs similarity index 100% rename from tests/run-make/issue-83112-incr-test-moved-file/main.rs rename to tests/run-make/incr-test-moved-file/main.rs diff --git a/tests/run-make/incr-test-moved-file/rmake.rs b/tests/run-make/incr-test-moved-file/rmake.rs new file mode 100644 index 0000000000000..ae142a0d22e86 --- /dev/null +++ b/tests/run-make/incr-test-moved-file/rmake.rs @@ -0,0 +1,27 @@ +// The generated test harness code contains spans with a dummy location, +// but a non-dummy SyntaxContext. Previously, the incremental cache was encoding +// these spans as a full span (with a source file index), instead of skipping +// the encoding of the location information. If the file gest moved, the hash +// of the span will be unchanged (since it has a dummy location), so the incr +// cache would end up try to load a non-existent file using the previously +// enccoded source file id. +// This test reproduces the steps that used to trigger this bug, and checks +// for successful compilation. +// See https://github.com/rust-lang/rust/issues/83112 + +//@ ignore-none +// Reason: no-std is not supported +//@ ignore-nvptx64-nvidia-cuda +// FIXME: can't find crate for 'std' + +use run_make_support::{fs_wrapper, rust_lib_name, rustc}; + +fn main() { + fs_wrapper::create_dir("incr"); + fs_wrapper::create_dir("src"); + fs_wrapper::create_dir("src/mydir"); + fs_wrapper::copy("main.rs", "src/main.rs"); + rustc().input("src/main.rs").incremental("incr").arg("--test").run(); + fs_wrapper::rename("src/main.rs", "src/mydir/main.rs"); + rustc().input("src/mydir/main.rs").incremental("incr").arg("--test").run(); +} diff --git a/tests/run-make/issue-83112-incr-test-moved-file/Makefile b/tests/run-make/issue-83112-incr-test-moved-file/Makefile deleted file mode 100644 index a00088cd9d61b..0000000000000 --- a/tests/run-make/issue-83112-incr-test-moved-file/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -include ../tools.mk - -# ignore-none no-std is not supported -# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for 'std' - -# Regression test for issue #83112 -# The generated test harness code contains spans with a dummy location, -# but a non-dummy SyntaxContext. Previously, the incremental cache was encoding -# these spans as a full span (with a source file index), instead of skipping -# the encoding of the location information. If the file gest moved, the hash -# of the span will be unchanged (since it has a dummy location), so the incr -# cache would end up try to load a non-existent file using the previously -# enccoded source file id. - -SRC=$(TMPDIR)/src -INCR=$(TMPDIR)/incr - -all: - mkdir $(SRC) - mkdir $(SRC)/mydir - mkdir $(INCR) - cp main.rs $(SRC)/main.rs - $(RUSTC) --test -C incremental=$(INCR) $(SRC)/main.rs --target $(TARGET) - mv $(SRC)/main.rs $(SRC)/mydir/main.rs - $(RUSTC) --test -C incremental=$(INCR) $(SRC)/mydir/main.rs --target $(TARGET) From 80fb4cab4e831f8c2bc735b71c351a198e17c9c9 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 9 Jul 2024 16:34:22 -0400 Subject: [PATCH 2/3] rewrite type-mismatch-same-crate-name to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../type-mismatch-same-crate-name/Makefile | 19 ------------ .../type-mismatch-same-crate-name/rmake.rs | 29 +++++++++++++++++++ 3 files changed, 29 insertions(+), 20 deletions(-) delete mode 100644 tests/run-make/type-mismatch-same-crate-name/Makefile create mode 100644 tests/run-make/type-mismatch-same-crate-name/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 f71992cad233f..52410382828ce 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -142,6 +142,5 @@ run-make/test-benches/Makefile run-make/thumb-none-cortex-m/Makefile run-make/thumb-none-qemu/Makefile run-make/translation/Makefile -run-make/type-mismatch-same-crate-name/Makefile run-make/unstable-flag-required/Makefile run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile diff --git a/tests/run-make/type-mismatch-same-crate-name/Makefile b/tests/run-make/type-mismatch-same-crate-name/Makefile deleted file mode 100644 index a2a2a41c7a5a1..0000000000000 --- a/tests/run-make/type-mismatch-same-crate-name/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -include ../tools.mk - -all: - # compile two different versions of crateA - $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-1 -C extra-filename=-1 - $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-2 -C extra-filename=-2 - # make crateB depend on version 1 of crateA - $(RUSTC) --crate-type=rlib crateB.rs --extern crateA=$(TMPDIR)/libcrateA-1.rlib - # make crateC depend on version 2 of crateA - $(RUSTC) crateC.rs --extern crateA=$(TMPDIR)/libcrateA-2.rlib 2>&1 | \ - tr -d '\r\n' | $(CGREP) -e \ - "mismatched types.*\ - crateB::try_foo\(foo2\);.*\ - expected \`crateA::foo::Foo\`, found \`Foo\`.*\ - different versions of crate \`crateA\`.*\ - mismatched types.*\ - crateB::try_bar\(bar2\);.*\ - expected trait \`crateA::bar::Bar\`, found trait \`Bar\`.*\ - different versions of crate \`crateA\`" diff --git a/tests/run-make/type-mismatch-same-crate-name/rmake.rs b/tests/run-make/type-mismatch-same-crate-name/rmake.rs new file mode 100644 index 0000000000000..ecf80d88d51c1 --- /dev/null +++ b/tests/run-make/type-mismatch-same-crate-name/rmake.rs @@ -0,0 +1,29 @@ +// When a compilation failure deals with seemingly identical types, some helpful +// errors should be printed. +// The main use case of this error is when there are two crates +// (generally different versions of the same crate) with the same name +// causing a type mismatch. In this test, one of the crates +// is only introduced as an indirect dependency and the type is accessed via a reexport. +// See https://github.com/rust-lang/rust/pull/42826 + +use run_make_support::{rust_lib_name, rustc}; + +fn main() { + rustc().crate_type("rlib").input("crateA.rs").metadata("-1").extra_filename("-1").run(); + rustc().crate_type("rlib").input("crateA.rs").metadata("-2").extra_filename("-2").run(); + rustc() + .crate_type("rlib") + .input("crateB.rs") + .extern_("crateA", rust_lib_name("crateA-1")) + .run(); + rustc() + .input("crateC.rs") + .extern_("crateA", rust_lib_name("crateA-2")) + .run_fail() + .assert_stderr_contains("mismatched types") + .assert_stderr_contains("crateB::try_foo(foo2);") + .assert_stderr_contains("different versions of crate `crateA`") + .assert_stderr_contains("crateB::try_bar(bar2);") + .assert_stderr_contains("expected trait `crateA::bar::Bar`, found trait `Bar`") + .assert_stderr_contains("different versions of crate `crateA`"); +} From 2adfa147d7cf07810f2d1658b482b8e44bef7e5b Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 9 Jul 2024 16:47:52 -0400 Subject: [PATCH 3/3] rewrite issue-109934-lto-debuginfo as an ui test --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../issue-109934-lto-debuginfo/Makefile | 12 ---------- .../issue-109934-lto-debuginfo/lib.rs | 9 -------- tests/ui/lto/debuginfo-lto-alloc.rs | 22 +++++++++++++++++++ 4 files changed, 22 insertions(+), 22 deletions(-) delete mode 100644 tests/run-make/issue-109934-lto-debuginfo/Makefile delete mode 100644 tests/run-make/issue-109934-lto-debuginfo/lib.rs create mode 100644 tests/ui/lto/debuginfo-lto-alloc.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 52410382828ce..fa41547d060e7 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -48,7 +48,6 @@ run-make/incr-add-rust-src-component/Makefile run-make/incr-foreign-head-span/Makefile run-make/interdependent-c-libraries/Makefile run-make/issue-107094/Makefile -run-make/issue-109934-lto-debuginfo/Makefile run-make/issue-14698/Makefile run-make/issue-15460/Makefile run-make/issue-18943/Makefile diff --git a/tests/run-make/issue-109934-lto-debuginfo/Makefile b/tests/run-make/issue-109934-lto-debuginfo/Makefile deleted file mode 100644 index 3b7a99d3dbc62..0000000000000 --- a/tests/run-make/issue-109934-lto-debuginfo/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# With the upgrade to LLVM 16, this was getting: -# -# error: Cannot represent a difference across sections -# -# The error stemmed from DI function definitions under type scopes, fixed by -# only declaring in type scope and defining the subprogram elsewhere. - -all: - $(RUSTC) lib.rs --test -C lto=fat -C debuginfo=2 -C incremental=$(TMPDIR)/inc-fat diff --git a/tests/run-make/issue-109934-lto-debuginfo/lib.rs b/tests/run-make/issue-109934-lto-debuginfo/lib.rs deleted file mode 100644 index c405928bd1824..0000000000000 --- a/tests/run-make/issue-109934-lto-debuginfo/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -extern crate alloc; - -#[cfg(test)] -mod tests { - #[test] - fn something_alloc() { - assert_eq!(Vec::::new(), Vec::::new()); - } -} diff --git a/tests/ui/lto/debuginfo-lto-alloc.rs b/tests/ui/lto/debuginfo-lto-alloc.rs new file mode 100644 index 0000000000000..459103c354c1c --- /dev/null +++ b/tests/ui/lto/debuginfo-lto-alloc.rs @@ -0,0 +1,22 @@ +// With the upgrade to LLVM 16, the following error appeared when using +// link-time-optimization (LTO) alloc and debug compilation mode simultaneously: +// +// error: Cannot represent a difference across sections +// +// The error stemmed from DI function definitions under type scopes, fixed by +// only declaring in type scope and defining the subprogram elsewhere. +// This test reproduces the circumstances that caused the error to appear, and checks +// that compilation is successful. + +//@ check-pass +//@ compile-flags: --test -C debuginfo=2 -C lto=fat -C incremental=inc-fat + +extern crate alloc; + +#[cfg(test)] +mod tests { + #[test] + fn something_alloc() { + assert_eq!(Vec::::new(), Vec::::new()); + } +}