Skip to content

Commit 20c909f

Browse files
committed
Auto merge of rust-lang#132401 - matthiaskrgr:rollup-599ieqr, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#130693 (Add `minicore` test auxiliary and support `//@ add-core-stubs` directive in ui/assembly/codegen tests) - rust-lang#132316 (CI: use free runners for 3 fast windows jobs) - rust-lang#132354 (Add `lp64e` RISC-V ABI) - rust-lang#132395 (coverage: Avoid ICE when `coverage_cx` is unexpectedly unavailable) - rust-lang#132396 (CI: use free runners for x86_64-gnu-tools and x86_64-rust-for-linux) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9ccfedf + c9584b7 commit 20c909f

File tree

19 files changed

+283
-96
lines changed

19 files changed

+283
-96
lines changed

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
554554

555555
/// Extra state that is only available when coverage instrumentation is enabled.
556556
#[inline]
557+
#[track_caller]
557558
pub(crate) fn coverage_cx(&self) -> &coverageinfo::CrateCoverageContext<'ll, 'tcx> {
558559
self.coverage_cx.as_ref().expect("only called when coverage instrumentation is enabled")
559560
}

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ pub(crate) fn finalize(cx: &CodegenCx<'_, '_>) {
5454
add_unused_functions(cx);
5555
}
5656

57-
let function_coverage_map = cx.coverage_cx().take_function_coverage_map();
57+
// FIXME(#132395): Can this be none even when coverage is enabled?
58+
let function_coverage_map = match cx.coverage_cx {
59+
Some(ref cx) => cx.take_function_coverage_map(),
60+
None => return,
61+
};
5862
if function_coverage_map.is_empty() {
5963
// This module has no functions with coverage instrumentation
6064
return;

compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,12 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
152152
return;
153153
};
154154

155-
let mut coverage_map = bx.coverage_cx().function_coverage_map.borrow_mut();
155+
// FIXME(#132395): Unwrapping `coverage_cx` here has led to ICEs in the
156+
// wild, so keep this early-return until we understand why.
157+
let mut coverage_map = match bx.coverage_cx {
158+
Some(ref cx) => cx.function_coverage_map.borrow_mut(),
159+
None => return,
160+
};
156161
let func_coverage = coverage_map
157162
.entry(instance)
158163
.or_insert_with(|| FunctionCoverageCollector::new(instance, function_coverage_info));

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
325325
"" | "ilp32" | "lp64" => (),
326326
"ilp32f" | "lp64f" => e_flags |= elf::EF_RISCV_FLOAT_ABI_SINGLE,
327327
"ilp32d" | "lp64d" => e_flags |= elf::EF_RISCV_FLOAT_ABI_DOUBLE,
328-
"ilp32e" => e_flags |= elf::EF_RISCV_RVE,
328+
// Note that the `lp64e` is still unstable as it's not (yet) part of the ELF psABI.
329+
"ilp32e" | "lp64e" => e_flags |= elf::EF_RISCV_RVE,
329330
_ => bug!("unknown RISC-V ABI name"),
330331
}
331332

compiler/rustc_target/src/spec/tests/tests_impl.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ impl Target {
165165
assert_matches!(&*self.llvm_abiname, "ilp32" | "ilp32f" | "ilp32d" | "ilp32e")
166166
}
167167
"riscv64" => {
168-
assert_matches!(&*self.llvm_abiname, "lp64" | "lp64f" | "lp64d" | "lp64q")
168+
// Note that the `lp64e` is still unstable as it's not (yet) part of the ELF psABI.
169+
assert_matches!(&*self.llvm_abiname, "lp64" | "lp64f" | "lp64d" | "lp64q" | "lp64e")
169170
}
170171
_ => {}
171172
}

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,6 +1725,11 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17251725
cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
17261726
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
17271727

1728+
// Minicore auxiliary lib for `no_core` tests that need `core` stubs in cross-compilation
1729+
// scenarios.
1730+
cmd.arg("--minicore-path")
1731+
.arg(builder.src.join("tests").join("auxiliary").join("minicore.rs"));
1732+
17281733
let is_rustdoc = suite.ends_with("rustdoc-ui") || suite.ends_with("rustdoc-js");
17291734

17301735
if mode == "run-make" {

src/ci/github-actions/jobs.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ auto:
232232
# Tests integration with Rust for Linux.
233233
# Builds stage 1 compiler and tries to compile a few RfL examples with it.
234234
- image: x86_64-rust-for-linux
235-
<<: *job-linux-8c
235+
<<: *job-linux-4c
236236

237237
- image: x86_64-gnu
238238
<<: *job-linux-4c
@@ -280,7 +280,7 @@ auto:
280280
- image: x86_64-gnu-tools
281281
env:
282282
DEPLOY_TOOLSTATES_JSON: toolstates-linux.json
283-
<<: *job-linux-8c
283+
<<: *job-linux-4c
284284

285285
####################
286286
# macOS Builders #
@@ -488,7 +488,7 @@ auto:
488488
SCRIPT: python x.py dist bootstrap --include-default-paths
489489
DIST_REQUIRE_ALL_TOOLS: 1
490490
CODEGEN_BACKENDS: llvm,cranelift
491-
<<: *job-windows-8c
491+
<<: *job-windows
492492

493493
- image: dist-x86_64-mingw
494494
env:
@@ -501,10 +501,10 @@ auto:
501501
NO_DOWNLOAD_CI_LLVM: 1
502502
DIST_REQUIRE_ALL_TOOLS: 1
503503
CODEGEN_BACKENDS: llvm,cranelift
504-
<<: *job-windows-8c
504+
<<: *job-windows
505505

506506
- image: dist-x86_64-msvc-alt
507507
env:
508508
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-extended --enable-profiler
509509
SCRIPT: python x.py dist bootstrap --include-default-paths
510-
<<: *job-windows-8c
510+
<<: *job-windows

src/tools/compiletest/src/common.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@ pub struct Config {
392392

393393
/// Command for visual diff display, e.g. `diff-tool --color=always`.
394394
pub diff_command: Option<String>,
395+
396+
/// Path to minicore aux library, used for `no_core` tests that need `core` stubs in
397+
/// cross-compilation scenarios that do not otherwise want/need to `-Zbuild-std`. Used in e.g.
398+
/// ABI tests.
399+
pub minicore_path: PathBuf,
395400
}
396401

397402
impl Config {

src/tools/compiletest/src/directive-list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/// a best-effort approximation for diagnostics. Add new headers to this list when needed.
44
const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
55
// tidy-alphabetical-start
6+
"add-core-stubs",
67
"assembly-output",
78
"aux-bin",
89
"aux-build",

src/tools/compiletest/src/header.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ pub struct TestProps {
198198
pub no_auto_check_cfg: bool,
199199
/// Run tests which require enzyme being build
200200
pub has_enzyme: bool,
201+
/// Build and use `minicore` as `core` stub for `no_core` tests in cross-compilation scenarios
202+
/// that don't otherwise want/need `-Z build-std`.
203+
pub add_core_stubs: bool,
201204
}
202205

203206
mod directives {
@@ -243,6 +246,7 @@ mod directives {
243246
pub const LLVM_COV_FLAGS: &'static str = "llvm-cov-flags";
244247
pub const FILECHECK_FLAGS: &'static str = "filecheck-flags";
245248
pub const NO_AUTO_CHECK_CFG: &'static str = "no-auto-check-cfg";
249+
pub const ADD_CORE_STUBS: &'static str = "add-core-stubs";
246250
// This isn't a real directive, just one that is probably mistyped often
247251
pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags";
248252
}
@@ -300,6 +304,7 @@ impl TestProps {
300304
filecheck_flags: vec![],
301305
no_auto_check_cfg: false,
302306
has_enzyme: false,
307+
add_core_stubs: false,
303308
}
304309
}
305310

@@ -564,6 +569,8 @@ impl TestProps {
564569
}
565570

566571
config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut self.no_auto_check_cfg);
572+
573+
self.update_add_core_stubs(ln, config);
567574
},
568575
);
569576

@@ -677,6 +684,27 @@ impl TestProps {
677684
pub fn local_pass_mode(&self) -> Option<PassMode> {
678685
self.pass_mode
679686
}
687+
688+
pub fn update_add_core_stubs(&mut self, ln: &str, config: &Config) {
689+
let add_core_stubs = config.parse_name_directive(ln, directives::ADD_CORE_STUBS);
690+
if add_core_stubs {
691+
if !matches!(config.mode, Mode::Ui | Mode::Codegen | Mode::Assembly) {
692+
panic!(
693+
"`add-core-stubs` is currently only supported for ui, codegen and assembly test modes"
694+
);
695+
}
696+
697+
// FIXME(jieyouxu): this check is currently order-dependent, but we should probably
698+
// collect all directives in one go then perform a validation pass after that.
699+
if self.local_pass_mode().is_some_and(|pm| pm == PassMode::Run) {
700+
// `minicore` can only be used with non-run modes, because it's `core` prelude stubs
701+
// and can't run.
702+
panic!("`add-core-stubs` cannot be used to run the test binary");
703+
}
704+
705+
self.add_core_stubs = add_core_stubs;
706+
}
707+
}
680708
}
681709

682710
/// If the given line begins with the appropriate comment prefix for a directive,

0 commit comments

Comments
 (0)