Skip to content

Commit c541503

Browse files
Run rustc_codegen_gcc tests in the CI
1 parent 3089c31 commit c541503

File tree

4 files changed

+163
-4
lines changed

4 files changed

+163
-4
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+33-2
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,42 @@ pub struct Std {
4545
/// When using download-rustc, we need to use a new build of `std` for running unit tests of Std itself,
4646
/// but we need to use the downloaded copy of std for linking to rustdoc. Allow this to be overriden by `builder.ensure` from other steps.
4747
force_recompile: bool,
48+
extra_rust_args: &'static [&'static str],
4849
}
4950

5051
impl Std {
5152
pub fn new(compiler: Compiler, target: TargetSelection) -> Self {
52-
Self { target, compiler, crates: Default::default(), force_recompile: false }
53+
Self {
54+
target,
55+
compiler,
56+
crates: Default::default(),
57+
force_recompile: false,
58+
extra_rust_args: &[],
59+
}
5360
}
5461

5562
pub fn force_recompile(compiler: Compiler, target: TargetSelection) -> Self {
56-
Self { target, compiler, crates: Default::default(), force_recompile: true }
63+
Self {
64+
target,
65+
compiler,
66+
crates: Default::default(),
67+
force_recompile: true,
68+
extra_rust_args: &[],
69+
}
70+
}
71+
72+
pub fn new_with_extra_rust_args(
73+
compiler: Compiler,
74+
target: TargetSelection,
75+
extra_rust_args: &'static [&'static str],
76+
) -> Self {
77+
Self {
78+
target,
79+
compiler,
80+
crates: Default::default(),
81+
force_recompile: false,
82+
extra_rust_args,
83+
}
5784
}
5885
}
5986

@@ -81,6 +108,7 @@ impl Step for Std {
81108
target: run.target,
82109
crates,
83110
force_recompile: false,
111+
extra_rust_args: &[],
84112
});
85113
}
86114

@@ -188,6 +216,9 @@ impl Step for Std {
188216
if target.is_synthetic() {
189217
cargo.env("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET", "1");
190218
}
219+
for rustflag in self.extra_rust_args.into_iter() {
220+
cargo.rustflag(rustflag);
221+
}
191222

192223
let _guard = builder.msg(
193224
Kind::Build,

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

+127
Original file line numberDiff line numberDiff line change
@@ -3104,3 +3104,130 @@ impl Step for CodegenCranelift {
31043104
builder.run_cmd(BootstrapCommand::from(&mut cmd).fail_fast());
31053105
}
31063106
}
3107+
3108+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3109+
pub struct CodegenGCC {
3110+
compiler: Compiler,
3111+
target: TargetSelection,
3112+
}
3113+
3114+
impl Step for CodegenGCC {
3115+
type Output = ();
3116+
const DEFAULT: bool = true;
3117+
const ONLY_HOSTS: bool = true;
3118+
3119+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
3120+
run.paths(&["compiler/rustc_codegen_gcc"])
3121+
}
3122+
3123+
fn make_run(run: RunConfig<'_>) {
3124+
let builder = run.builder;
3125+
let host = run.build_triple();
3126+
let compiler = run.builder.compiler_for(run.builder.top_stage, host, host);
3127+
3128+
if builder.doc_tests == DocTests::Only {
3129+
return;
3130+
}
3131+
3132+
let triple = run.target.triple;
3133+
let target_supported = if triple.contains("linux") {
3134+
triple.contains("x86_64")
3135+
|| triple.contains("aarch64")
3136+
|| triple.contains("s390x")
3137+
|| triple.contains("riscv64gc")
3138+
} else if triple.contains("darwin") || triple.contains("windows") {
3139+
triple.contains("x86_64")
3140+
} else {
3141+
false
3142+
};
3143+
if !target_supported {
3144+
builder.info("target not supported by rustc_codegen_gcc. skipping");
3145+
return;
3146+
}
3147+
3148+
if builder.remote_tested(run.target) {
3149+
builder.info("remote testing is not supported by rustc_codegen_gcc. skipping");
3150+
return;
3151+
}
3152+
3153+
if !builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("gcc")) {
3154+
builder.info("gcc not in rust.codegen-backends. skipping");
3155+
return;
3156+
}
3157+
3158+
builder.ensure(CodegenGCC { compiler, target: run.target });
3159+
}
3160+
3161+
fn run(self, builder: &Builder<'_>) {
3162+
let compiler = self.compiler;
3163+
let target = self.target;
3164+
3165+
builder.ensure(compile::Std::new_with_extra_rust_args(
3166+
compiler,
3167+
target,
3168+
&["-Csymbol-mangling-version=v0", "-Cpanic=abort", "-Zpanic-abort-tests"],
3169+
));
3170+
3171+
// If we're not doing a full bootstrap but we're testing a stage2
3172+
// version of libstd, then what we're actually testing is the libstd
3173+
// produced in stage1. Reflect that here by updating the compiler that
3174+
// we're working with automatically.
3175+
let compiler = builder.compiler_for(compiler.stage, compiler.host, target);
3176+
3177+
let build_cargo = || {
3178+
let mut cargo = builder.cargo(
3179+
compiler,
3180+
Mode::Codegen, // Must be codegen to ensure dlopen on compiled dylibs works
3181+
SourceType::InTree,
3182+
target,
3183+
"run",
3184+
);
3185+
cargo.current_dir(&builder.src.join("compiler/rustc_codegen_gcc"));
3186+
cargo
3187+
.arg("--manifest-path")
3188+
.arg(builder.src.join("compiler/rustc_codegen_gcc/build_system/Cargo.toml"));
3189+
compile::rustc_cargo_env(builder, &mut cargo, target, compiler.stage);
3190+
3191+
// Avoid incremental cache issues when changing rustc
3192+
cargo.env("CARGO_BUILD_INCREMENTAL", "false");
3193+
cargo.rustflag("-Cpanic=abort");
3194+
3195+
cargo
3196+
};
3197+
3198+
builder.info(&format!(
3199+
"{} GCC stage{} ({} -> {})",
3200+
Kind::Test.description(),
3201+
compiler.stage,
3202+
&compiler.host,
3203+
target
3204+
));
3205+
let _time = helpers::timeit(&builder);
3206+
3207+
/*
3208+
let mut prepare_cargo = build_cargo();
3209+
prepare_cargo.arg("--").arg("prepare");
3210+
#[allow(deprecated)]
3211+
builder.config.try_run(&mut prepare_cargo.into()).unwrap();
3212+
*/
3213+
3214+
let mut cargo = build_cargo();
3215+
3216+
cargo
3217+
.arg("--")
3218+
.arg("test")
3219+
.arg("--use-system-gcc")
3220+
.arg("--use-backend")
3221+
.arg("gcc")
3222+
.arg("--out-dir")
3223+
.arg(builder.stage_out(compiler, Mode::ToolRustc).join("cg_gcc"))
3224+
.arg("--release")
3225+
.arg("--no-default-features")
3226+
.arg("--mini-tests")
3227+
.arg("--std-tests");
3228+
cargo.args(builder.config.test_args());
3229+
3230+
let mut cmd: Command = cargo.into();
3231+
builder.run_cmd(BootstrapCommand::from(&mut cmd).fail_fast());
3232+
}
3233+
}

src/bootstrap/src/core/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ impl<'a> Builder<'a> {
737737
test::Debuginfo,
738738
test::UiFullDeps,
739739
test::CodegenCranelift,
740+
test::CodegenGCC,
740741
test::Rustdoc,
741742
test::RunCoverageRustdoc,
742743
test::Pretty,

src/ci/run.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ else
124124

125125
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
126126

127-
# Test the Cranelift backend in on CI, but don't ship it.
128-
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=llvm,cranelift"
127+
# Test the Cranelift and GCC backends in CI, but don't ship them.
128+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=llvm,cranelift,gcc"
129129

130130
# We enable this for non-dist builders, since those aren't trying to produce
131131
# fresh binaries. We currently don't entirely support distributing a fresh

0 commit comments

Comments
 (0)