Merge from rustc

This commit is contained in:
Ralf Jung 2024-03-25 17:17:57 +01:00
commit d8be714fee
168 changed files with 1782 additions and 746 deletions

View file

@ -1289,9 +1289,9 @@ macro_rules! test_definitions {
/// Adapted from [`test_definitions`].
macro_rules! coverage_test_alias {
($name:ident {
alias_and_mode: $alias_and_mode:expr,
default: $default:expr,
only_hosts: $only_hosts:expr $(,)?
alias_and_mode: $alias_and_mode:expr, // &'static str
default: $default:expr, // bool
only_hosts: $only_hosts:expr $(,)? // bool
}) => {
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct $name {
@ -1309,6 +1309,8 @@ macro_rules! coverage_test_alias {
const ONLY_HOSTS: bool = $only_hosts;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
// Register the mode name as a command-line alias.
// This allows `x test coverage-map` and `x test coverage-run`.
run.alias($alias_and_mode)
}
@ -1319,8 +1321,7 @@ macro_rules! coverage_test_alias {
}
fn run(self, builder: &Builder<'_>) {
Coverage { compiler: self.compiler, target: self.target }
.run_unified_suite(builder, Self::MODE)
Coverage::run_coverage_tests(builder, self.compiler, self.target, Self::MODE);
}
}
};
@ -1449,11 +1450,20 @@ host_test!(RunMakeFullDeps {
default_test!(Assembly { path: "tests/assembly", mode: "assembly", suite: "assembly" });
/// Custom test step that is responsible for running the coverage tests
/// in multiple different modes.
/// Coverage tests are a bit more complicated than other test suites, because
/// we want to run the same set of test files in multiple different modes,
/// in a way that's convenient and flexible when invoked manually.
///
/// Each individual mode also has its own alias that will run the tests in
/// just that mode.
/// This combined step runs the specified tests (or all of `tests/coverage`)
/// in both "coverage-map" and "coverage-run" modes.
///
/// Used by:
/// - `x test coverage`
/// - `x test tests/coverage`
/// - `x test tests/coverage/trivial.rs` (etc)
///
/// (Each individual mode also has its own step that will run the tests in
/// just that mode.)
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Coverage {
pub compiler: Compiler,
@ -1464,24 +1474,41 @@ impl Coverage {
const PATH: &'static str = "tests/coverage";
const SUITE: &'static str = "coverage";
fn run_unified_suite(&self, builder: &Builder<'_>, mode: &'static str) {
/// Runs the coverage test suite (or a user-specified subset) in one mode.
///
/// This same function is used by the multi-mode step ([`Coverage`]) and by
/// the single-mode steps ([`CoverageMap`] and [`CoverageRun`]), to help
/// ensure that they all behave consistently with each other, regardless of
/// how the coverage tests have been invoked.
fn run_coverage_tests(
builder: &Builder<'_>,
compiler: Compiler,
target: TargetSelection,
mode: &'static str,
) {
// Like many other test steps, we delegate to a `Compiletest` step to
// actually run the tests. (See `test_definitions!`.)
builder.ensure(Compiletest {
compiler: self.compiler,
target: self.target,
compiler,
target,
mode,
suite: Self::SUITE,
path: Self::PATH,
compare_mode: None,
})
});
}
}
impl Step for Coverage {
type Output = ();
// We rely on the individual CoverageMap/CoverageRun steps to run themselves.
const DEFAULT: bool = false;
// When manually invoked, try to run as much as possible.
// Compiletest will automatically skip the "coverage-run" tests if necessary.
const ONLY_HOSTS: bool = false;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
// Take responsibility for command-line paths within `tests/coverage`.
run.suite_path(Self::PATH)
}
@ -1492,20 +1519,26 @@ impl Step for Coverage {
}
fn run(self, builder: &Builder<'_>) {
self.run_unified_suite(builder, CoverageMap::MODE);
self.run_unified_suite(builder, CoverageRun::MODE);
// Run the specified coverage tests (possibly all of them) in both modes.
Self::run_coverage_tests(builder, self.compiler, self.target, CoverageMap::MODE);
Self::run_coverage_tests(builder, self.compiler, self.target, CoverageRun::MODE);
}
}
// Aliases for running the coverage tests in only one mode.
// Runs `tests/coverage` in "coverage-map" mode only.
// Used by `x test` and `x test coverage-map`.
coverage_test_alias!(CoverageMap {
alias_and_mode: "coverage-map",
default: true,
only_hosts: false,
});
// Runs `tests/coverage` in "coverage-run" mode only.
// Used by `x test` and `x test coverage-run`.
coverage_test_alias!(CoverageRun {
alias_and_mode: "coverage-run",
default: true,
// Compiletest knows how to automatically skip these tests when cross-compiling,
// but skipping the whole step here makes it clearer that they haven't run at all.
only_hosts: true,
});

View file

@ -1,5 +1,10 @@
#!/usr/bin/env bash
GIT_REPO="https://github.com/rust-lang/gcc"
# This commit hash needs to be updated to use a more recent gcc fork version.
GIT_COMMIT="78dc50f0e50e6cd1433149520bd512a4e0eaa1bc"
set -ex
cd $1
@ -7,13 +12,11 @@ cd $1
source shared.sh
# Setting up folders for GCC
git clone https://github.com/antoyo/gcc gcc-src
cd gcc-src
# This commit hash needs to be updated to use a more recent gcc fork version.
git checkout 78dc50f0e50e6cd1433149520bd512a4e0eaa1bc
curl -L "$GIT_REPO/archive/$GIT_COMMIT.tar.gz" |
tar -xz --transform "s/gcc-$GIT_COMMIT/gcc-src/"
mkdir ../gcc-build ../gcc-install
cd ../gcc-build
mkdir gcc-build gcc-install
pushd gcc-build
# Building GCC.
hide_output \
@ -28,6 +31,7 @@ hide_output \
hide_output make -j$(nproc)
hide_output make install
rm -rf ../gcc-src
popd
rm -rf gcc-src gcc-build
ln -s /scripts/gcc-install/lib/libgccjit.so /usr/lib/x86_64-linux-gnu/libgccjit.so
ln -s /scripts/gcc-install/lib/libgccjit.so /usr/lib/x86_64-linux-gnu/libgccjit.so.0

View file

@ -261,7 +261,7 @@ x--expand-yaml-anchors--remove:
<<: *step
- name: upload artifacts to github
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
# name is set in previous step
name: ${{ env.DOC_ARTIFACT_NAME }}

View file

@ -67,9 +67,6 @@ pub(crate) fn generate_args_file(file_path: &Path, options: &RustdocOptions) ->
}
}
if let Some(sysroot) = &options.maybe_sysroot {
content.push(format!("--sysroot={}", sysroot.display()));
}
for lib_str in &options.lib_strs {
content.push(format!("-L{lib_str}"));
}
@ -411,6 +408,10 @@ fn run_test(
compiler.arg(&format!("@{}", rustdoc_options.arg_file.display()));
if let Some(sysroot) = &rustdoc_options.maybe_sysroot {
compiler.arg(format!("--sysroot={}", sysroot.display()));
}
compiler.arg("--edition").arg(&edition.to_string());
compiler.env("UNSTABLE_RUSTDOC_TEST_PATH", path);
compiler.env("UNSTABLE_RUSTDOC_TEST_LINE", format!("{}", line as isize - line_offset as isize));
@ -950,6 +951,7 @@ pub(crate) struct IndividualTestOptions {
runtool_args: Vec<String>,
target: TargetTriple,
test_id: String,
maybe_sysroot: Option<PathBuf>,
}
impl IndividualTestOptions {
@ -982,6 +984,7 @@ impl IndividualTestOptions {
runtool_args: options.runtool_args.clone(),
target: options.target.clone(),
test_id,
maybe_sysroot: options.maybe_sysroot.clone(),
}
}
}

View file

@ -609,6 +609,8 @@ fn common_inputs_stamp(config: &Config) -> Stamp {
stamp.add_path(&rust_src_dir.join("src/etc/htmldocck.py"));
}
stamp.add_dir(&rust_src_dir.join("src/tools/run-make-support"));
// Compiletest itself.
stamp.add_dir(&rust_src_dir.join("src/tools/compiletest/"));

View file

@ -457,7 +457,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let bitmask_len = u32::try_from(bitmask_len).unwrap();
// To read the mask, we transmute it to an integer.
// That does the right thing wrt endianess.
// That does the right thing wrt endianness.
let mask_ty = this.machine.layouts.uint(mask.layout.size).unwrap();
let mask = mask.transmute(mask_ty, this)?;
let mask: u64 = this.read_scalar(&mask)?.to_bits(mask_ty.size)?.try_into().unwrap();
@ -509,7 +509,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
}
}
// We have to change the type of the place to be able to write `res` into it. This
// transmutes the integer to an array, which does the right thing wrt endianess.
// transmutes the integer to an array, which does the right thing wrt endianness.
let dest =
dest.transmute(this.machine.layouts.uint(dest.layout.size).unwrap(), this)?;
this.write_int(res, &dest)?;

View file

@ -38,7 +38,7 @@ impl FileDescriptor for Event {
}
/// A write call adds the 8-byte integer value supplied in
/// its buffer (in native endianess) to the counter. The maximum value that may be
/// its buffer (in native endianness) to the counter. The maximum value that may be
/// stored in the counter is the largest unsigned 64-bit value
/// minus 1 (i.e., 0xfffffffffffffffe). If the addition would
/// cause the counter's value to exceed the maximum, then the
@ -57,7 +57,7 @@ impl FileDescriptor for Event {
) -> InterpResult<'tcx, io::Result<usize>> {
let v1 = self.val.get();
let bytes: [u8; 8] = bytes.try_into().unwrap(); // FIXME fail gracefully when this has the wrong size
// Convert from target endianess to host endianess.
// Convert from target endianness to host endianness.
let num = match tcx.sess.target.endian {
Endian::Little => u64::from_le_bytes(bytes),
Endian::Big => u64::from_be_bytes(bytes),

View file

@ -121,6 +121,7 @@ fn default_dcx(
fallback_bundle,
fatal_dcx: DiagCtxt::new(emitter),
fatal_note: None,
emit_fatal_diagnostic: false,
})
} else {
emitter
@ -209,7 +210,7 @@ impl ParseSess {
rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
false,
);
self.raw_psess.dcx.make_silent(fallback_bundle, None);
self.raw_psess.dcx.make_silent(fallback_bundle, None, false);
}
pub(crate) fn span_to_filename(&self, span: Span) -> FileName {