Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c6ace5c
Run rustc_codegen_gcc tests in the CI
GuillaumeGomez Oct 28, 2023
42bdc87
Disable `master` feature by default when building rustc_codegen_gcc
GuillaumeGomez Oct 28, 2023
ded81de
Fix compilation errors in rustc_codegen_gcc examples
GuillaumeGomez Oct 28, 2023
ead5dff
Fix missing error libgccjit in CI
GuillaumeGomez Oct 28, 2023
3c58fea
Fix config.sh script
GuillaumeGomez Oct 28, 2023
05a8476
Fix rustc_codegen_gcc lto issue
GuillaumeGomez Oct 28, 2023
7f6aa44
Add comment explaning when to uncomment the `prepare` command code
GuillaumeGomez Oct 28, 2023
edfd67b
Pass `--sysroot` option
GuillaumeGomez Oct 28, 2023
4b290d4
Only run cg_gcc tests on linux x86_64
GuillaumeGomez Oct 28, 2023
a1902a8
Force mangling version for rustc_codegen_gcc
GuillaumeGomez Oct 28, 2023
c5ff230
Skip codegen tests in llvm-15 CI check
GuillaumeGomez Oct 30, 2023
4329093
Remove `libc` dependency in cg_gcc alloc_system example
GuillaumeGomez Oct 30, 2023
260d91b
Add FIXME header for two comments in cg_gcc and cg_clif boostrap types
GuillaumeGomez Nov 1, 2023
13f7f05
Run codegen tests outside if not llvm-15
GuillaumeGomez Nov 1, 2023
25a96ca
Don't include GCC backend if SKIP_CODEGEN_TESTS is not enabled
GuillaumeGomez Nov 2, 2023
a141b69
Rename `SKIP_CODEGEN_TESTS` into `ENABLE_GCC_CODEGEN`
GuillaumeGomez Nov 2, 2023
2dbe7d8
Fix invalid enabling of gcc backend in `run.sh`
GuillaumeGomez Nov 2, 2023
30a0709
Add comment explaining why the ENABLE_GCC_CODEGEN env variable is needed
GuillaumeGomez Nov 2, 2023
c890dd6
Set some environment variables value only if ENABLE_GCC_CODEGEN is set
GuillaumeGomez Nov 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Run rustc_codegen_gcc tests in the CI
  • Loading branch information
GuillaumeGomez committed Nov 2, 2023
commit c6ace5c564eae4254a39deb7ed834ad739e6e010
35 changes: 33 additions & 2 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,42 @@ pub struct Std {
/// When using download-rustc, we need to use a new build of `std` for running unit tests of Std itself,
/// 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.
force_recompile: bool,
extra_rust_args: &'static [&'static str],
}

impl Std {
pub fn new(compiler: Compiler, target: TargetSelection) -> Self {
Self { target, compiler, crates: Default::default(), force_recompile: false }
Self {
target,
compiler,
crates: Default::default(),
force_recompile: false,
extra_rust_args: &[],
}
}

pub fn force_recompile(compiler: Compiler, target: TargetSelection) -> Self {
Self { target, compiler, crates: Default::default(), force_recompile: true }
Self {
target,
compiler,
crates: Default::default(),
force_recompile: true,
extra_rust_args: &[],
}
}

pub fn new_with_extra_rust_args(
compiler: Compiler,
target: TargetSelection,
extra_rust_args: &'static [&'static str],
) -> Self {
Self {
target,
compiler,
crates: Default::default(),
force_recompile: false,
extra_rust_args,
}
}
}

Expand Down Expand Up @@ -81,6 +108,7 @@ impl Step for Std {
target: run.target,
crates,
force_recompile: false,
extra_rust_args: &[],
});
}

Expand Down Expand Up @@ -188,6 +216,9 @@ impl Step for Std {
if target.is_synthetic() {
cargo.env("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET", "1");
}
for rustflag in self.extra_rust_args.into_iter() {
cargo.rustflag(rustflag);
}

let _guard = builder.msg(
Kind::Build,
Expand Down
127 changes: 127 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3094,3 +3094,130 @@ impl Step for CodegenCranelift {
builder.run_cmd(BootstrapCommand::from(&mut cmd).fail_fast());
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CodegenGCC {
compiler: Compiler,
target: TargetSelection,
}

impl Step for CodegenGCC {
type Output = ();
const DEFAULT: bool = true;
const ONLY_HOSTS: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.paths(&["compiler/rustc_codegen_gcc"])
}

fn make_run(run: RunConfig<'_>) {
let builder = run.builder;
let host = run.build_triple();
let compiler = run.builder.compiler_for(run.builder.top_stage, host, host);

if builder.doc_tests == DocTests::Only {
return;
}

let triple = run.target.triple;
let target_supported = if triple.contains("linux") {
triple.contains("x86_64")
|| triple.contains("aarch64")
|| triple.contains("s390x")
|| triple.contains("riscv64gc")
} else if triple.contains("darwin") || triple.contains("windows") {
triple.contains("x86_64")
} else {
false
};
if !target_supported {
builder.info("target not supported by rustc_codegen_gcc. skipping");
return;
}

if builder.remote_tested(run.target) {
builder.info("remote testing is not supported by rustc_codegen_gcc. skipping");
return;
}

if !builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("gcc")) {
builder.info("gcc not in rust.codegen-backends. skipping");
return;
}

builder.ensure(CodegenGCC { compiler, target: run.target });
}

fn run(self, builder: &Builder<'_>) {
let compiler = self.compiler;
let target = self.target;

builder.ensure(compile::Std::new_with_extra_rust_args(
compiler,
target,
&["-Csymbol-mangling-version=v0", "-Cpanic=abort"],
));

// If we're not doing a full bootstrap but we're testing a stage2
// version of libstd, then what we're actually testing is the libstd
// produced in stage1. Reflect that here by updating the compiler that
// we're working with automatically.
let compiler = builder.compiler_for(compiler.stage, compiler.host, target);

let build_cargo = || {
let mut cargo = builder.cargo(
compiler,
Mode::Codegen, // Must be codegen to ensure dlopen on compiled dylibs works
SourceType::InTree,
target,
"run",
);
cargo.current_dir(&builder.src.join("compiler/rustc_codegen_gcc"));
cargo
.arg("--manifest-path")
.arg(builder.src.join("compiler/rustc_codegen_gcc/build_system/Cargo.toml"));
compile::rustc_cargo_env(builder, &mut cargo, target, compiler.stage);

// Avoid incremental cache issues when changing rustc
cargo.env("CARGO_BUILD_INCREMENTAL", "false");
cargo.rustflag("-Cpanic=abort");

cargo
};

builder.info(&format!(
"{} GCC stage{} ({} -> {})",
Kind::Test.description(),
compiler.stage,
&compiler.host,
target
));
let _time = helpers::timeit(&builder);

/*
let mut prepare_cargo = build_cargo();
prepare_cargo.arg("--").arg("prepare");
#[allow(deprecated)]
builder.config.try_run(&mut prepare_cargo.into()).unwrap();
*/

let mut cargo = build_cargo();

cargo
.arg("--")
.arg("test")
.arg("--use-system-gcc")
.arg("--use-backend")
.arg("gcc")
.arg("--out-dir")
.arg(builder.stage_out(compiler, Mode::ToolRustc).join("cg_gcc"))
.arg("--release")
.arg("--no-default-features")
.arg("--mini-tests")
.arg("--std-tests");
cargo.args(builder.config.test_args());

let mut cmd: Command = cargo.into();
builder.run_cmd(BootstrapCommand::from(&mut cmd).fail_fast());
}
}
1 change: 1 addition & 0 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ impl<'a> Builder<'a> {
test::Debuginfo,
test::UiFullDeps,
test::CodegenCranelift,
test::CodegenGCC,
test::Rustdoc,
test::RunCoverageRustdoc,
test::Pretty,
Expand Down
2 changes: 1 addition & 1 deletion src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ else
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"

# Test the Cranelift backend in CI. Bootstrap knows which targets to run tests on.
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=llvm,cranelift"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=llvm,cranelift,gcc"

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