Skip to content

Commit e3f1827

Browse files
committed
Build Fuchsia in CI
1 parent 8a7b203 commit e3f1827

File tree

9 files changed

+144
-11
lines changed

9 files changed

+144
-11
lines changed

.github/workflows/ci.yml

+3
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: {}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ impl Step for Assemble {
17221722
let dst_exe = exe("rust-lld", target_compiler.host);
17231723
builder.copy(&lld_install.join("bin").join(&src_exe), &libdir_bin.join(&dst_exe));
17241724
let self_contained_lld_dir = libdir_bin.join("gcc-ld");
1725-
t!(fs::create_dir(&self_contained_lld_dir));
1725+
t!(fs::create_dir_all(&self_contained_lld_dir));
17261726
let lld_wrapper_exe = builder.ensure(crate::core::build_steps::tool::LldWrapper {
17271727
compiler: build_compiler,
17281728
target: target_compiler.host,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ RUN env \
7676
rm -rf /build/*
7777

7878
WORKDIR /tmp
79-
COPY host-x86_64/dist-various-2/shared.sh /tmp/
80-
COPY host-x86_64/dist-various-2/build-fuchsia-toolchain.sh /tmp/
79+
COPY scripts/shared.sh /tmp/
80+
COPY scripts/build-fuchsia-toolchain.sh /tmp/
8181
RUN /tmp/build-fuchsia-toolchain.sh
8282
COPY host-x86_64/dist-various-2/build-solaris-toolchain.sh /tmp/
8383
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,51 @@
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=132717f7831803d9f083e3ca0afb89405c6bc312
9+
PICK_REFS=()
10+
11+
checkout=fuchsia
12+
jiri=.jiri_root/bin/jiri
13+
14+
set -x
15+
16+
# This script will:
17+
# - create a directory named "fuchsia" if it does not exist
18+
# - download "jiri" to "fuchsia/.jiri_root/bin"
19+
curl -s "https://fuchsia.googlesource.com/jiri/+/HEAD/scripts/bootstrap_jiri?format=TEXT" \
20+
| base64 --decode \
21+
| bash -s $checkout
22+
23+
cd $checkout
24+
25+
$jiri init \
26+
-partial=true \
27+
-analytics-opt=false \
28+
.
29+
30+
$jiri import \
31+
-name=integration \
32+
-revision=$INTEGRATION_SHA \
33+
-overwrite=true \
34+
flower \
35+
"https://fuchsia.googlesource.com/integration"
36+
37+
if [ -d ".git" ]; then
38+
# Wipe out any local changes if we're reusing a checkout.
39+
git checkout --force JIRI_HEAD
40+
fi
41+
42+
$jiri update -autoupdate=false
43+
44+
echo integration commit = $(git -C integration rev-parse HEAD)
45+
46+
for git_ref in "${PICK_REFS[@]}"; do
47+
git fetch https://fuchsia.googlesource.com/fuchsia $git_ref
48+
git cherry-pick --no-commit FETCH_HEAD
49+
done
50+
51+
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/docker/host-x86_64/dist-various-2/shared.sh renamed to src/ci/docker/scripts/shared.sh

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
#!/usr/bin/env bash
2-
hide_output() {
1+
#!/bin/false
2+
# shellcheck shell=bash
3+
4+
# This file is intended to be sourced with `. shared.sh` or
5+
# `source shared.sh`, hence the invalid shebang and not being
6+
# marked as an executable file in git.
7+
8+
function hide_output {
39
{ set +x; } 2>/dev/null
410
on_err="
511
echo ERROR: An error was encountered with the build.
@@ -15,7 +21,8 @@ exit 1
1521
set -x
1622
}
1723

18-
# Copied from ../../shared.sh
24+
# See https://unix.stackexchange.com/questions/82598
25+
# Duplicated in src/ci/shared.sh
1926
function retry {
2027
echo "Attempting with retry:" "$@"
2128
local n=1

src/ci/github-actions/ci.yml

+4
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

@@ -730,6 +733,7 @@ jobs:
730733
CODEGEN_BACKENDS: llvm,cranelift
731734
<<: *job-linux-16c
732735

736+
733737
master:
734738
name: master
735739
runs-on: ubuntu-latest

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)