Skip to content

Commit 1939787

Browse files
committed
Auto merge of rust-lang#117771 - tmandry:fuchsia-gha, r=<try>
Build Fuchsia in CI This is very much in a draft state but I wanted to put it up now to get early feedback. It would also be nice if we could test it on actual CI builders. Fittingly, it is failing right now due to discovering an ICE in clippy (looks like fixed in rust-lang/rust-clippy#11760), probably more fallout from recent type system changes. Other recent regressions this would have caught include - rust-lang#117455 and rust-lang#117493 - rust-lang#117602 This ends up not sharing very much at all with cargotest. Fuchsia has its own tool to manage checkouts and its own build system. What it requires is a fully "install"ed toolchain with a host and fuchsia target. We share logic from the dist-various-2 builder to build the fuchsia target. Right now this runs clippy and skips linking a bunch of targets, since most issues we catch are in the frontend. In theory we could probably get the build CPU time down quite a bit with this approach, but right now some linked targets are creeping into the dependencies anyway and we don't have a good way of preventing that yet. The approach is basically to get a checkout at a pinned commit and then run a [script](https://fuchsia-review.git.corp.google.com/c/fuchsia/+/943833/6/scripts/rust/build_fuchsia_from_rust_ci.sh) at a predetermined location. I would like to update that pin every few weeks. For now we cherry-pick some build changes but that's temporary. Partial checkouts are used to minimize clone time, but we don't filter out prebuilt packages. r? `@Mark-Simulacrum` Based on discussion in [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/Putting.20Fuchsia.20in.20crater).
2 parents e886137 + 44b2ead commit 1939787

File tree

8 files changed

+147
-8
lines changed

8 files changed

+147
-8
lines changed

.github/workflows/ci.yml

+9
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ jobs:
288288
- name: x86_64-gnu-aux
289289
os: ubuntu-20.04-4core-16gb
290290
env: {}
291+
- name: x86_64-gnu-integration
292+
os: ubuntu-20.04-16core-64gb
293+
env: {}
291294
- name: x86_64-gnu-debug
292295
os: ubuntu-20.04-8core-32gb
293296
env: {}
@@ -583,6 +586,12 @@ jobs:
583586
env:
584587
CODEGEN_BACKENDS: "llvm,cranelift"
585588
os: ubuntu-20.04-16core-64gb
589+
- name: x86_64-gnu-integration
590+
os: ubuntu-20.04-16core-64gb
591+
env: {}
592+
- name: dist-various-2
593+
os: ubuntu-20.04-8core-32gb
594+
env: {}
586595
timeout-minutes: 600
587596
runs-on: "${{ matrix.os }}"
588597
steps:

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,7 @@ impl Step for Assemble {
17151715
let dst_exe = exe("rust-lld", target_compiler.host);
17161716
builder.copy(&lld_install.join("bin").join(&src_exe), &libdir_bin.join(&dst_exe));
17171717
let self_contained_lld_dir = libdir_bin.join("gcc-ld");
1718-
t!(fs::create_dir(&self_contained_lld_dir));
1718+
t!(fs::create_dir_all(&self_contained_lld_dir));
17191719
let lld_wrapper_exe = builder.ensure(crate::core::build_steps::tool::LldWrapper {
17201720
compiler: build_compiler,
17211721
target: target_compiler.host,

src/ci/docker/host-x86_64/dist-various-2/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ RUN env \
7979
rm -rf /build/*
8080

8181
WORKDIR /tmp
82-
COPY host-x86_64/dist-various-2/shared.sh /tmp/
83-
COPY host-x86_64/dist-various-2/build-fuchsia-toolchain.sh /tmp/
82+
COPY scripts/shared.sh /tmp/
83+
COPY scripts/build-fuchsia-toolchain.sh /tmp/
8484
RUN /tmp/build-fuchsia-toolchain.sh
8585
COPY host-x86_64/dist-various-2/build-solaris-toolchain.sh /tmp/
8686
RUN /tmp/build-solaris-toolchain.sh x86_64 amd64 solaris-i386 pc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
FROM ubuntu:22.04
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
5+
build-essential \
6+
g++ \
7+
make \
8+
ninja-build \
9+
file \
10+
curl \
11+
ca-certificates \
12+
python3 \
13+
git \
14+
cmake \
15+
libssl-dev \
16+
sudo \
17+
xz-utils \
18+
pkg-config \
19+
unzip \
20+
&& rm -rf /var/lib/apt/lists/*
21+
22+
# Duplicated in dist-various-2 Dockerfile.
23+
# FIXME: Move to canonical triple
24+
ENV \
25+
AR_x86_64_fuchsia=x86_64-unknown-fuchsia-ar \
26+
CC_x86_64_fuchsia=x86_64-unknown-fuchsia-clang \
27+
CFLAGS_x86_64_fuchsia="--target=x86_64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot -I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \
28+
CXX_x86_64_fuchsia=x86_64-unknown-fuchsia-clang++ \
29+
CXXFLAGS_x86_64_fuchsia="--target=x86_64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot -I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \
30+
LDFLAGS_x86_64_fuchsia="--target=x86_64-unknown-fuchsia --sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot -L/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/lib"
31+
32+
WORKDIR /tmp
33+
COPY scripts/shared.sh /tmp/
34+
COPY scripts/build-fuchsia-toolchain.sh /tmp/
35+
RUN /tmp/build-fuchsia-toolchain.sh
36+
37+
ENV CARGO_TARGET_X86_64_FUCHSIA_AR /usr/local/bin/llvm-ar
38+
ENV CARGO_TARGET_X86_64_FUCHSIA_RUSTFLAGS \
39+
-C panic=abort \
40+
-C force-unwind-tables=yes \
41+
-C link-arg=--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot \
42+
-Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot/lib \
43+
-Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/lib
44+
45+
ENV TARGETS=x86_64-fuchsia
46+
ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnu
47+
48+
COPY scripts/sccache.sh /scripts/
49+
RUN sh /scripts/sccache.sh
50+
51+
ENV RUST_INSTALL_DIR /checkout/obj/install
52+
RUN mkdir -p $RUST_INSTALL_DIR/etc
53+
54+
ENV RUST_CONFIGURE_ARGS \
55+
--prefix=$RUST_INSTALL_DIR \
56+
--sysconfdir=etc \
57+
--enable-lld \
58+
--llvm-libunwind=in-tree \
59+
--enable-extended \
60+
--disable-docs \
61+
--set target.x86_64-fuchsia.cc=/usr/local/bin/clang \
62+
--set target.x86_64-fuchsia.cxx=/usr/local/bin/clang++ \
63+
--set target.x86_64-fuchsia.ar=/usr/local/bin/llvm-ar \
64+
--set target.x86_64-fuchsia.ranlib=/usr/local/bin/llvm-ranlib \
65+
--set target.x86_64-fuchsia.linker=/usr/local/bin/ld.lld
66+
ENV SCRIPT \
67+
python3 ../x.py install --target $TARGETS compiler/rustc library/std clippy && \
68+
bash ../src/ci/docker/host-x86_64/x86_64-gnu-integration/build-fuchsia.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
# Downloads and builds the Fuchsia operating system using a toolchain installed
4+
# in $RUST_INSTALL_DIR.
5+
6+
set -euf -o pipefail
7+
8+
INTEGRATION_SHA=06ae16d18bd8e4db9a3fc062f678a170025d9f1a
9+
PICK_REFS=(
10+
refs/changes/14/948614/1
11+
refs/changes/33/943833/20
12+
)
13+
14+
checkout=fuchsia
15+
jiri=.jiri_root/bin/jiri
16+
17+
set -x
18+
19+
# This script will:
20+
# - create a directory named "fuchsia" if it does not exist
21+
# - download "jiri" to "fuchsia/.jiri_root/bin"
22+
curl -s "https://fuchsia.googlesource.com/jiri/+/HEAD/scripts/bootstrap_jiri?format=TEXT" \
23+
| base64 --decode \
24+
| bash -s $checkout
25+
26+
cd $checkout
27+
28+
$jiri init \
29+
-partial=true \
30+
-analytics-opt=false \
31+
.
32+
33+
$jiri import \
34+
-name=integration \
35+
-revision=$INTEGRATION_SHA \
36+
-overwrite=true \
37+
flower \
38+
"https://fuchsia.googlesource.com/integration"
39+
40+
if [ -d ".git" ]; then
41+
# Wipe out any local changes if we're reusing a checkout.
42+
git checkout --force JIRI_HEAD
43+
fi
44+
45+
$jiri update -autoupdate=false
46+
47+
echo integration commit = $(git -C integration rev-parse HEAD)
48+
49+
for git_ref in "${PICK_REFS[@]}"; do
50+
git fetch https://fuchsia.googlesource.com/fuchsia $git_ref
51+
git cherry-pick --no-commit FETCH_HEAD
52+
done
53+
54+
bash scripts/rust/build_fuchsia_from_rust_ci.sh

src/ci/docker/host-x86_64/dist-various-2/build-fuchsia-toolchain.sh renamed to src/ci/docker/scripts/build-fuchsia-toolchain.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ set -ex
44
source shared.sh
55

66
FUCHSIA_SDK_URL=https://chrome-infra-packages.appspot.com/dl/fuchsia/sdk/core/linux-amd64
7-
FUCHSIA_SDK_ID=4xjxrGUrDbQ6_zJwj6cDN1IbWsWV5aCQXC_zO_Hu0XkC
8-
FUCHSIA_SDK_SHA256=e318f1ac652b0db43aff32708fa70337521b5ac595e5a0905c2ff33bf1eed179
7+
FUCHSIA_SDK_ID=MrhQwtmP8CpZre-i_PNOREcThbUcrX3bA-45d6WQr-cC
8+
FUCHSIA_SDK_SHA256=32b850c2d98ff02a59adefa2fcf34e44471385b51cad7ddb03ee3977a590afe7
99
FUCHSIA_SDK_USR_DIR=/usr/local/core-linux-amd64-fuchsia-sdk
1010
CLANG_DOWNLOAD_URL=\
1111
https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/linux-amd64
12-
CLANG_DOWNLOAD_ID=vU0vNjSihOV4Q6taQYCpy03JXGiCyVwxen3rFMNMIgsC
13-
CLANG_DOWNLOAD_SHA256=bd4d2f3634a284e57843ab5a4180a9cb4dc95c6882c95c317a7deb14c34c220b
12+
CLANG_DOWNLOAD_ID=Tpc85d1ZwSlZ6UKl2d96GRUBGNA5JKholOKe24sRDr0C
13+
CLANG_DOWNLOAD_SHA256=4e973ce5dd59c12959e942a5d9df7a19150118d03924a86894e29edb8b110ebd
1414

1515
install_clang() {
1616
mkdir -p clang_download

src/ci/github-actions/ci.yml

+8
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ jobs:
470470
- name: x86_64-gnu-aux
471471
<<: *job-linux-4c
472472

473+
- name: x86_64-gnu-integration
474+
<<: *job-linux-16c
475+
473476
- name: x86_64-gnu-debug
474477
<<: *job-linux-8c
475478

@@ -734,6 +737,11 @@ jobs:
734737
env:
735738
CODEGEN_BACKENDS: llvm,cranelift
736739
<<: *job-linux-16c
740+
- name: x86_64-gnu-integration
741+
<<: *job-linux-16c
742+
- name: dist-various-2
743+
<<: *job-linux-8c
744+
737745

738746
master:
739747
name: master

src/ci/shared.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
export MIRRORS_BASE="https://ci-mirrors.rust-lang.org/rustc"
99

1010
# See https://unix.stackexchange.com/questions/82598
11-
# Duplicated in docker/dist-various-2/shared.sh
11+
# Duplicated in docker/scripts/shared.sh
1212
function retry {
1313
echo "Attempting with retry:" "$@"
1414
local n=1

0 commit comments

Comments
 (0)