diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 1d19c985f23..df108f5e0e4 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -3766,7 +3766,7 @@ impl fmt::Debug for AtomicPtr { #[stable(feature = "atomic_pointer", since = "1.24.0")] impl fmt::Pointer for AtomicPtr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Pointer::fmt(&self.load(Ordering::SeqCst), f) + fmt::Pointer::fmt(&self.load(Ordering::Relaxed), f) } } diff --git a/library/core/src/time.rs b/library/core/src/time.rs index bc0fa3f0968..73c556249be 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -842,7 +842,7 @@ impl Duration { /// Returns the number of seconds contained by this `Duration` as `f64`. /// - /// The returned value does include the fractional (nanosecond) part of the duration. + /// The returned value includes the fractional (nanosecond) part of the duration. /// /// # Examples /// ``` @@ -861,7 +861,7 @@ impl Duration { /// Returns the number of seconds contained by this `Duration` as `f32`. /// - /// The returned value does include the fractional (nanosecond) part of the duration. + /// The returned value includes the fractional (nanosecond) part of the duration. /// /// # Examples /// ``` @@ -880,7 +880,7 @@ impl Duration { /// Returns the number of milliseconds contained by this `Duration` as `f64`. /// - /// The returned value does include the fractional (nanosecond) part of the duration. + /// The returned value includes the fractional (nanosecond) part of the duration. /// /// # Examples /// ``` @@ -901,7 +901,7 @@ impl Duration { /// Returns the number of milliseconds contained by this `Duration` as `f32`. /// - /// The returned value does include the fractional (nanosecond) part of the duration. + /// The returned value includes the fractional (nanosecond) part of the duration. /// /// # Examples /// ``` diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index d891a52f1ef..1460a229019 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1817,23 +1817,25 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the cmd.arg("--gdb").arg(gdb); } - let run = |cmd: &mut Command| { - cmd.output().map(|output| { - String::from_utf8_lossy(&output.stdout) - .lines() - .next() - .unwrap_or_else(|| panic!("{:?} failed {:?}", cmd, output)) - .to_string() - }) - }; - let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb")); let lldb_version = Command::new(&lldb_exe) .arg("--version") .output() - .map(|output| String::from_utf8_lossy(&output.stdout).to_string()) - .ok(); + .map(|output| { + (String::from_utf8_lossy(&output.stdout).to_string(), output.status.success()) + }) + .ok() + .and_then(|(output, success)| if success { Some(output) } else { None }); if let Some(ref vers) = lldb_version { + let run = |cmd: &mut Command| { + cmd.output().map(|output| { + String::from_utf8_lossy(&output.stdout) + .lines() + .next() + .unwrap_or_else(|| panic!("{:?} failed {:?}", cmd, output)) + .to_string() + }) + }; cmd.arg("--lldb-version").arg(vers); let lldb_python_dir = run(Command::new(&lldb_exe).arg("-P")).ok(); if let Some(ref dir) = lldb_python_dir { diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 73ef7c5ba25..b9c214da330 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -82,7 +82,6 @@ run-make/jobserver-error/Makefile run-make/libs-through-symlinks/Makefile run-make/libtest-json/Makefile run-make/libtest-junit/Makefile -run-make/libtest-padding/Makefile run-make/libtest-thread-limit/Makefile run-make/link-cfg/Makefile run-make/link-framework/Makefile @@ -100,8 +99,6 @@ run-make/macos-fat-archive/Makefile run-make/manual-link/Makefile run-make/metadata-dep-info/Makefile run-make/min-global-align/Makefile -run-make/mingw-export-call-convention/Makefile -run-make/mismatching-target-triples/Makefile run-make/missing-crate-dependency/Makefile run-make/mixing-libs/Makefile run-make/msvc-opt-minsize/Makefile @@ -114,13 +111,11 @@ run-make/obey-crate-type-flag/Makefile run-make/optimization-remarks-dir-pgo/Makefile run-make/optimization-remarks-dir/Makefile run-make/output-type-permutations/Makefile -run-make/override-aliased-flags/Makefile run-make/panic-abort-eh_frame/Makefile run-make/pass-linker-flags-flavor/Makefile run-make/pass-linker-flags-from-dep/Makefile run-make/pass-linker-flags/Makefile run-make/pass-non-c-like-enum-to-c/Makefile -run-make/pdb-alt-path/Makefile run-make/pdb-buildinfo-cl-cmd/Makefile run-make/pgo-gen-lto/Makefile run-make/pgo-gen-no-imp-symbols/Makefile @@ -128,8 +123,6 @@ run-make/pgo-gen/Makefile run-make/pgo-indirect-call-promotion/Makefile run-make/pgo-use/Makefile run-make/pointer-auth-link-with-c/Makefile -run-make/pretty-print-to-file/Makefile -run-make/pretty-print-with-dep-file/Makefile run-make/print-calling-conventions/Makefile run-make/print-target-list/Makefile run-make/profile/Makefile @@ -147,7 +140,6 @@ run-make/remap-path-prefix/Makefile run-make/reproducible-build-2/Makefile run-make/reproducible-build/Makefile run-make/return-non-c-like-enum-from-c/Makefile -run-make/return-non-c-like-enum/Makefile run-make/rlib-chain/Makefile run-make/rlib-format-packed-bundled-libs-2/Makefile run-make/rlib-format-packed-bundled-libs-3/Makefile diff --git a/tests/run-make/libtest-padding/Makefile b/tests/run-make/libtest-padding/Makefile deleted file mode 100644 index c8e2fc01f67..00000000000 --- a/tests/run-make/libtest-padding/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# ignore-cross-compile because we run the compiled code -# needs-unwind because #[bench] and -Cpanic=abort requires -Zpanic-abort-tests -include ../tools.mk - -NORMALIZE=sed 's%[0-9,\.]\{1,\} ns/iter (+/- [0-9,\.]\{1,\})%?? ns/iter (+/- ??)%' | sed 's%finished in [0-9\.]\{1,\}%finished in ??%' - -all: - $(RUSTC) --test tests.rs - - $(call RUN,tests) --test-threads=1 | $(NORMALIZE) > "$(TMPDIR)"/test.stdout - $(RUSTC_TEST_OP) "$(TMPDIR)"/test.stdout test.stdout - - $(call RUN,tests) --test-threads=1 --bench | $(NORMALIZE) > "$(TMPDIR)"/bench.stdout - $(RUSTC_TEST_OP) "$(TMPDIR)"/bench.stdout bench.stdout diff --git a/tests/run-make/libtest-padding/rmake.rs b/tests/run-make/libtest-padding/rmake.rs new file mode 100644 index 00000000000..4b17ba19bf7 --- /dev/null +++ b/tests/run-make/libtest-padding/rmake.rs @@ -0,0 +1,46 @@ +// Benchmarks, when ran as tests, would cause strange indentations +// to appear in the output. This was because padding formatting was +// applied before the conversion from bench to test, and not afterwards. +// Now that this bug has been fixed in #118548, this test checks that it +// does not make a resurgence by comparing the output of --bench with an +// example stdout file. +// See https://github.com/rust-lang/rust/issues/104092 + +//@ ignore-cross-compile +// Reason: the compiled code is ran +//@ needs-unwind +// Reason: #[bench] requires -Z panic-abort-tests + +use run_make_support::{diff, run_with_args, rustc}; + +fn main() { + rustc().arg("--test").input("tests.rs").run(); + let out = run_with_args("tests", &["--test-threads=1"]).stdout_utf8(); + diff() + .expected_file("test.stdout") + .actual_text("actual-test-stdout", out) + .normalize( + // Replace all instances of (arbitrary numbers) + // [1.2345 ns/iter (+/- 0.1234)] + // with + // [?? ns/iter (+/- ??)] + r#"(\d+(?:[.,]\d+)*)\s*ns/iter\s*\(\+/-\s*(\d+(?:[.,]\d+)*)\)"#, + "?? ns/iter (+/- ??)", + ) + // Replace all instances of (arbitrary numbers) + // finished in 8.0000 s + // with + // finished in ?? + .normalize(r#"finished\s+in\s+(\d+(?:\.\d+)*)"#, "finished in ??") + .run(); + let out = run_with_args("tests", &["--test-threads=1", "--bench"]).stdout_utf8(); + diff() + .expected_file("bench.stdout") + .actual_text("actual-bench-stdout", out) + .normalize( + r#"(\d+(?:[.,]\d+)*)\s*ns/iter\s*\(\+/-\s*(\d+(?:[.,]\d+)*)\)"#, + "?? ns/iter (+/- ??)", + ) + .normalize(r#"finished\s+in\s+(\d+(?:\.\d+)*)"#, "finished in ??") + .run(); +} diff --git a/tests/run-make/mingw-export-call-convention/Makefile b/tests/run-make/mingw-export-call-convention/Makefile deleted file mode 100644 index 4a60059cc54..00000000000 --- a/tests/run-make/mingw-export-call-convention/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../tools.mk - -# only-windows-gnu - -all: - $(RUSTC) foo.rs - # FIXME: we should make sure __stdcall calling convention is used here - # but that only works with LLD right now - nm -g "$(call IMPLIB,foo)" | $(CGREP) bar diff --git a/tests/run-make/mingw-export-call-convention/rmake.rs b/tests/run-make/mingw-export-call-convention/rmake.rs new file mode 100644 index 00000000000..d1fb745a64d --- /dev/null +++ b/tests/run-make/mingw-export-call-convention/rmake.rs @@ -0,0 +1,13 @@ +// On windows-gnu, symbol exporting used to fail to export names +// with no_mangle. #72049 brought this feature up to par with msvc, +// and this test checks that the symbol "bar" is successfully exported. +// See https://github.com/rust-lang/rust/issues/50176 + +//@ only-x86_64-pc-windows-gnu + +use run_make_support::{llvm_readobj, rustc}; + +fn main() { + rustc().input("foo.rs").run(); + llvm_readobj().arg("--all").input("libfoo.dll.a").run().assert_stdout_contains("bar"); +} diff --git a/tests/run-make/mismatching-target-triples/Makefile b/tests/run-make/mismatching-target-triples/Makefile deleted file mode 100644 index 409388e0414..00000000000 --- a/tests/run-make/mismatching-target-triples/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -include ../tools.mk - -# Issue #10814 -# -# these are no_std to avoid having to have the standard library or any -# linkers/assemblers for the relevant platform - -all: - $(RUSTC) foo.rs --target=i686-unknown-linux-gnu - $(RUSTC) bar.rs --target=x86_64-unknown-linux-gnu 2>&1 \ - | $(CGREP) 'couldn'"'"'t find crate `foo` with expected target triple x86_64-unknown-linux-gnu' diff --git a/tests/run-make/mismatching-target-triples/rmake.rs b/tests/run-make/mismatching-target-triples/rmake.rs new file mode 100644 index 00000000000..6f41eac8cda --- /dev/null +++ b/tests/run-make/mismatching-target-triples/rmake.rs @@ -0,0 +1,15 @@ +// In this test, foo links against 32-bit architecture, and then, bar, which depends +// on foo, links against 64-bit architecture, causing a metadata mismatch due to the +// differences in target architectures. This used to cause an internal compiler error, +// now replaced by a clearer normal error message. This test checks that this aforementioned +// error message is used. +// See https://github.com/rust-lang/rust/issues/10814 + +use run_make_support::rustc; + +fn main() { + rustc().input("foo.rs").target("i686-unknown-linux-gnu").run(); + rustc().input("bar.rs").target("x86_64-unknown-linux-gnu").run_fail().assert_stderr_contains( + r#"couldn't find crate `foo` with expected target triple x86_64-unknown-linux-gnu"#, + ); +} diff --git a/tests/run-make/override-aliased-flags/Makefile b/tests/run-make/override-aliased-flags/Makefile deleted file mode 100644 index db1ff1ff981..00000000000 --- a/tests/run-make/override-aliased-flags/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# FIXME: it would be good to check that it's actually the rightmost flags -# that are used when multiple flags are specified, but I can't think of a -# reliable way to check this. - -all: - # Test that `-O` and `-C opt-level` can be specified multiple times. - # The rightmost flag will be used over any previous flags. - $(RUSTC) -O -O main.rs - $(RUSTC) -O -C opt-level=0 main.rs - $(RUSTC) -C opt-level=0 -O main.rs - $(RUSTC) -C opt-level=0 -C opt-level=2 main.rs - $(RUSTC) -C opt-level=2 -C opt-level=0 main.rs - - # Test that `-g` and `-C debuginfo` can be specified multiple times. - # The rightmost flag will be used over any previous flags. - $(RUSTC) -g -g main.rs - $(RUSTC) -g -C debuginfo=0 main.rs - $(RUSTC) -C debuginfo=0 -g main.rs - $(RUSTC) -C debuginfo=0 -C debuginfo=2 main.rs - $(RUSTC) -C debuginfo=2 -C debuginfo=0 main.rs diff --git a/tests/run-make/override-aliased-flags/rmake.rs b/tests/run-make/override-aliased-flags/rmake.rs new file mode 100644 index 00000000000..e610c04651e --- /dev/null +++ b/tests/run-make/override-aliased-flags/rmake.rs @@ -0,0 +1,24 @@ +//@ ignore-cross-compile + +use run_make_support::rustc; + +// FIXME: it would be good to check that it's actually the rightmost flags +// that are used when multiple flags are specified, but I can't think of a +// reliable way to check this. +fn main() { + // Test that `-O` and `-C opt-level` can be specified multiple times. + // The rightmost flag will be used over any previous flags. + rustc().arg("-O").arg("-O").input("main.rs").run(); + rustc().arg("-O").arg("-C").arg("opt-level=0").input("main.rs").run(); + rustc().arg("-C").arg("opt-level=0").arg("-O").input("main.rs").run(); + rustc().arg("-C").arg("opt-level=0").arg("-C").arg("opt-level=2").input("main.rs").run(); + rustc().arg("-C").arg("opt-level=2").arg("-C").arg("opt-level=0").input("main.rs").run(); + + // Test that `-g` and `-C debuginfo` can be specified multiple times. + // The rightmost flag will be used over any previous flags. + rustc().arg("-g").arg("-g").input("main.rs").run(); + rustc().arg("-g").arg("-C").arg("debuginfo=0").input("main.rs").run(); + rustc().arg("-C").arg("debuginfo=0").arg("-g").input("main.rs").run(); + rustc().arg("-C").arg("debuginfo=0").arg("-C").arg("debuginfo=2").input("main.rs").run(); + rustc().arg("-C").arg("debuginfo=2").arg("-C").arg("debuginfo=0").input("main.rs").run(); +} diff --git a/tests/run-make/pdb-alt-path/Makefile b/tests/run-make/pdb-alt-path/Makefile deleted file mode 100644 index 7a0ae3bf2ef..00000000000 --- a/tests/run-make/pdb-alt-path/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -include ../tools.mk - -# only-windows-msvc - -all: - # Test that we don't have the full path to the PDB file in the binary - $(RUSTC) main.rs -g --crate-name my_crate_name --crate-type bin -Cforce-frame-pointers - $(CGREP) "my_crate_name.pdb" < $(TMPDIR)/my_crate_name.exe - $(CGREP) -v "\\my_crate_name.pdb" < $(TMPDIR)/my_crate_name.exe - - # Test that backtraces still can find debuginfo by checking that they contain symbol names and - # source locations. - $(TMPDIR)/my_crate_name.exe &> $(TMPDIR)/backtrace.txt - $(CGREP) "my_crate_name::fn_in_backtrace" < $(TMPDIR)/backtrace.txt - $(CGREP) "main.rs:15" < $(TMPDIR)/backtrace.txt - - # Test that explicitly passed `-Clink-arg=/PDBALTPATH:...` is respected - $(RUSTC) main.rs -g --crate-name my_crate_name --crate-type bin -Clink-arg=/PDBALTPATH:abcdefg.pdb -Cforce-frame-pointers - $(CGREP) "abcdefg.pdb" < $(TMPDIR)/my_crate_name.exe - $(CGREP) -v "my_crate_name.pdb" < $(TMPDIR)/my_crate_name.exe diff --git a/tests/run-make/pdb-alt-path/rmake.rs b/tests/run-make/pdb-alt-path/rmake.rs new file mode 100644 index 00000000000..6311d6d9ed7 --- /dev/null +++ b/tests/run-make/pdb-alt-path/rmake.rs @@ -0,0 +1,39 @@ +// The information inside a .exe file contains a string of the PDB file name. +// This could be a security concern if the full path was exposed, as it could +// reveal information about the filesystem where the bin was first compiled. +// This should only be overridden by `-Clink-arg=/PDBALTPATH:...` - this test +// checks that no full file paths are exposed and that the override flag is respected. +// See https://github.com/rust-lang/rust/pull/121297 + +//@ only-x86_64-pc-windows-msvc + +use run_make_support::{bin_name, invalid_utf8_contains, invalid_utf8_not_contains, run, rustc}; + +fn main() { + // Test that we don't have the full path to the PDB file in the binary + rustc() + .input("main.rs") + .arg("-g") + .crate_name("my_crate_name") + .crate_type("bin") + .arg("-Cforce-frame-pointers") + .run(); + invalid_utf8_contains(&bin_name("my_crate_name"), "my_crate_name.pdb"); + invalid_utf8_not_contains(&bin_name("my_crate_name"), r#"\my_crate_name.pdb"#); + // Test that backtraces still can find debuginfo by checking that they contain symbol names and + // source locations. + let out = run(&bin_name("my_crate_name")); + out.assert_stdout_contains("my_crate_name::fn_in_backtrace"); + out.assert_stdout_contains("main.rs:15"); + // Test that explicitly passed `-Clink-arg=/PDBALTPATH:...` is respected + rustc() + .input("main.rs") + .arg("-g") + .crate_name("my_crate_name") + .crate_type("bin") + .link_arg("/PDBALTPATH:abcdefg.pdb") + .arg("-Cforce-frame-pointers") + .run(); + invalid_utf8_contains(&bin_name("my_crate_name"), "abcdefg.pdb"); + invalid_utf8_not_contains(&bin_name("my_crate_name"), "my_crate_name.pdb"); +} diff --git a/tests/run-make/pretty-print-to-file/Makefile b/tests/run-make/pretty-print-to-file/Makefile deleted file mode 100644 index ca11b8c47f0..00000000000 --- a/tests/run-make/pretty-print-to-file/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) -o $(TMPDIR)/input.out -Zunpretty=normal input.rs - diff -u $(TMPDIR)/input.out input.pp diff --git a/tests/run-make/pretty-print-to-file/rmake.rs b/tests/run-make/pretty-print-to-file/rmake.rs new file mode 100644 index 00000000000..c23514ae849 --- /dev/null +++ b/tests/run-make/pretty-print-to-file/rmake.rs @@ -0,0 +1,12 @@ +// The "pretty-printer" of rustc translates source code into other formats, +// which is useful for debugging. This test checks the "normal" version of +// -Zunpretty, which should format the poorly formatted input.rs into a one-line +// function identical to the one in input.pp. +// See https://github.com/rust-lang/rust/commit/da25539c1ab295ec40261109557dd4526923928c + +use run_make_support::{diff, rustc}; + +fn main() { + rustc().output("input.out").arg("-Zunpretty=normal").input("input.rs").run(); + diff().expected_file("input.out").actual_file("input.pp").run(); +} diff --git a/tests/run-make/pretty-print-with-dep-file/Makefile b/tests/run-make/pretty-print-with-dep-file/Makefile deleted file mode 100644 index fa8089eb6a5..00000000000 --- a/tests/run-make/pretty-print-with-dep-file/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) --emit=dep-info -Zunpretty=expanded with-dep.rs - $(CGREP) "with-dep.rs" < $(TMPDIR)/with-dep.d - -rm $(TMPDIR)/with-dep.d - - $(RUSTC) --emit=dep-info -Zunpretty=normal with-dep.rs - ! test -f $(TMPDIR)/with-dep.d diff --git a/tests/run-make/pretty-print-with-dep-file/rmake.rs b/tests/run-make/pretty-print-with-dep-file/rmake.rs new file mode 100644 index 00000000000..859a9781bb6 --- /dev/null +++ b/tests/run-make/pretty-print-with-dep-file/rmake.rs @@ -0,0 +1,17 @@ +// Passing --emit=dep-info to the Rust compiler should create a .d file... +// but it failed to do so in Rust 1.69.0 when combined with -Z unpretty=expanded +// due to a bug. This test checks that -Z unpretty=expanded does not prevent the +// generation of the dep-info file, and that its -Z unpretty=normal counterpart +// does not get an unexpected dep-info file. +// See https://github.com/rust-lang/rust/issues/112898 + +use run_make_support::{fs_wrapper, invalid_utf8_contains, rustc}; +use std::path::Path; + +fn main() { + rustc().emit("dep-info").arg("-Zunpretty=expanded").input("with-dep.rs").run(); + invalid_utf8_contains("with-dep.d", "with-dep.rs"); + fs_wrapper::remove_file("with-dep.d"); + rustc().emit("dep-info").arg("-Zunpretty=normal").input("with-dep.rs").run(); + assert!(!Path::new("with-dep.d").exists()); +} diff --git a/tests/run-make/return-non-c-like-enum/Makefile b/tests/run-make/return-non-c-like-enum/Makefile deleted file mode 100644 index 0c8d8bf3acc..00000000000 --- a/tests/run-make/return-non-c-like-enum/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) --crate-type=staticlib nonclike.rs - $(CC) test.c $(call STATICLIB,nonclike) $(call OUT_EXE,test) \ - $(EXTRACFLAGS) $(EXTRACXXFLAGS) - $(call RUN,test) diff --git a/tests/run-make/return-non-c-like-enum/rmake.rs b/tests/run-make/return-non-c-like-enum/rmake.rs new file mode 100644 index 00000000000..e698790b43c --- /dev/null +++ b/tests/run-make/return-non-c-like-enum/rmake.rs @@ -0,0 +1,18 @@ +// Check that we treat enum variants like union members in call ABIs. +// Added in #68443. +// Original issue: #68190. + +//@ ignore-cross-compile + +use run_make_support::{cc, extra_c_flags, extra_cxx_flags, run, rustc, static_lib_name}; + +fn main() { + rustc().crate_type("staticlib").input("nonclike.rs").run(); + cc().input("test.c") + .arg(&static_lib_name("nonclike")) + .out_exe("test") + .args(&extra_c_flags()) + .args(&extra_cxx_flags()) + .run(); + run("test"); +}