Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 94e2839

Browse files
committedMar 13, 2025·
Auto merge of rust-lang#138451 - Kobzol:gcc-ci-build-gcc, r=<try>
Build GCC on CI with GCC, not Clang It seems that GCC built with Clang misbehaves. Prerequisite for rust-lang#138395. r? `@ghost`
2 parents 961351c + a1e034a commit 94e2839

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed
 

‎src/bootstrap/src/core/build_steps/gcc.rs

+15-7
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,23 @@ impl Step for Gcc {
6363
}
6464

6565
build_gcc(&metadata, builder, target);
66-
67-
let lib_alias = metadata.install_dir.join("lib/libgccjit.so.0");
68-
if !lib_alias.exists() {
69-
t!(builder.symlink_file(&libgccjit_path, lib_alias));
70-
}
66+
create_lib_alias(builder, &libgccjit_path);
7167

7268
t!(metadata.stamp.write());
7369

7470
GccOutput { libgccjit: libgccjit_path }
7571
}
7672
}
7773

74+
/// Creates a libgccjit.so.0 alias next to libgccjit.so if it does not
75+
/// already exist
76+
fn create_lib_alias(builder: &Builder<'_>, libgccjit: &PathBuf) {
77+
let lib_alias = libgccjit.parent().unwrap().join("libgccjit.so.0");
78+
if !lib_alias.exists() {
79+
t!(builder.symlink_file(libgccjit, lib_alias));
80+
}
81+
}
82+
7883
pub struct Meta {
7984
stamp: BuildStamp,
8085
out_dir: PathBuf,
@@ -109,8 +114,11 @@ fn try_download_gcc(builder: &Builder<'_>, target: TargetSelection) -> Option<Pa
109114
builder.config.download_ci_gcc(&sha, &root);
110115
t!(gcc_stamp.write());
111116
}
117+
112118
// FIXME: put libgccjit.so into a lib directory in dist::Gcc
113-
Some(root.join("libgccjit.so"))
119+
let libgccjit = root.join("libgccjit.so");
120+
create_lib_alias(builder, &libgccjit);
121+
Some(libgccjit)
114122
}
115123

116124
#[cfg(test)]
@@ -210,7 +218,7 @@ fn build_gcc(metadata: &Meta, builder: &Builder<'_>, target: TargetSelection) {
210218
.env("CXXFLAGS", "-Wno-everything -g -O2")
211219
.env("CFLAGS", "-Wno-everything -g -O2")
212220
.arg("--enable-host-shared")
213-
.arg("--enable-languages=jit")
221+
.arg("--enable-languages=c,jit,lto")
214222
.arg("--enable-checking=release")
215223
.arg("--disable-bootstrap")
216224
.arg("--disable-multilib")

‎src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ ENV SCRIPT python3 ../x.py build --set rust.debug=true opt-dist && \
101101
./build/$HOSTS/stage0-tools-bin/opt-dist linux-ci -- python3 ../x.py dist \
102102
--host $HOSTS --target $HOSTS \
103103
--include-default-paths \
104-
build-manifest bootstrap gcc
104+
build-manifest bootstrap && \
105+
# Use GCC for building GCC, as it seems to behave badly when built with Clang
106+
CC=/rustroot/bin/cc CXX=/rustroot/bin/c++ python3 ../x.py dist gcc
105107
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang
106108

107109
# This is the only builder which will create source tarballs

‎src/ci/github-actions/jobs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ envs:
9090
# - not running `opt-dist`'s post-optimization smoke tests on the resulting toolchain
9191
#
9292
# If you *want* these to happen however, temporarily comment it before triggering a try build.
93-
DIST_TRY_BUILD: 1
93+
# DIST_TRY_BUILD: 1
9494

9595
auto:
9696
<<: *production

0 commit comments

Comments
 (0)