Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
117 changes: 91 additions & 26 deletions src/ci/docker/host-x86_64/test-x86_64-fuchsia/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
# Fuchsia as an integration test of the toolchain. See the build-fuchsia.sh
# script in this directory for more details.

FROM ubuntu:22.04
FROM ubuntu:26.04

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
clang-15 \
clang \
g++ \
g++-aarch64-linux-gnu \
make \
ninja-build \
file \
Expand All @@ -26,27 +27,79 @@ RUN apt-get update && apt-get install -y --no-install-recommends \

# Duplicated in dist-various-2 Dockerfile.
ENV \
AR_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-ar \
CC_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang \
CFLAGS_aarch64_unknown_fuchsia="\
--target=aarch64-unknown-fuchsia \
--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot \
-I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \
CXX_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang++ \
CXXFLAGS_aarch64_unknown_fuchsia="\
--target=aarch64-unknown-fuchsia \
--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot \
-I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \
LDFLAGS_aarch64_unknown_fuchsia="\
--target=aarch64-unknown-fuchsia \
--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot \
-L/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/lib" \
AR_riscv64gc_unknown_fuchsia=riscv64gc-unknown-fuchsia-ar \
CC_riscv64gc_unknown_fuchsia=riscv64gc-unknown-fuchsia-clang \
CFLAGS_riscv64gc_unknown_fuchsia="\
--target=riscv64-unknown-fuchsia \
--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/riscv64/sysroot \
-I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \
CXX_riscv64gc_unknown_fuchsia=riscv64gc-unknown-fuchsia-clang++ \
CXXFLAGS_riscv64gc_unknown_fuchsia="\
--target=riscv64-unknown-fuchsia \
--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/riscv64/sysroot \
-I/usr/local/core-linux-amd64-fuchsia-sdk/pkg/fdio/include" \
LDFLAGS_riscv64gc_unknown_fuchsia="\
--target=riscv64-unknown-fuchsia \
--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/riscv64/sysroot \
-L/usr/local/core-linux-amd64-fuchsia-sdk/arch/riscv64/lib" \
AR_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-ar \
CC_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang \
CFLAGS_x86_64_unknown_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" \
CFLAGS_x86_64_unknown_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" \
CXX_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang++ \
CXXFLAGS_x86_64_unknown_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" \
LDFLAGS_x86_64_unknown_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"
CXXFLAGS_x86_64_unknown_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" \
LDFLAGS_x86_64_unknown_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"

WORKDIR /tmp
COPY scripts/shared.sh /tmp/
COPY scripts/build-fuchsia-toolchain.sh /tmp/
RUN /tmp/build-fuchsia-toolchain.sh

ENV CARGO_TARGET_X86_64_UNKNOWN_FUCHSIA_AR="/usr/local/bin/llvm-ar"
ENV CARGO_TARGET_X86_64_UNKNOWN_FUCHSIA_RUSTFLAGS="-C panic=abort \
-C force-unwind-tables=yes \
-C link-arg=--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot \
-Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot/lib \
-Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/lib"
ENV \
CARGO_TARGET_AARCH64_UNKNOWN_FUCHSIA_AR="/usr/local/bin/llvm-ar" \
CARGO_TARGET_AARCH64_UNKNOWN_FUCHSIA_RUSTFLAGS="-C panic=abort \
-C force-unwind-tables=yes \
-C link-arg=--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot \
-Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/sysroot/lib \
-Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/arm64/lib" \
CARGO_TARGET_RISCV64GC_UNKNOWN_FUCHSIA_AR="/usr/local/bin/llvm-ar" \
CARGO_TARGET_RISCV64GC_UNKNOWN_FUCHSIA_RUSTFLAGS="-C panic=abort \
-C force-unwind-tables=yes \
-C link-arg=--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/riscv64/sysroot \
-Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/riscv64/sysroot/lib \
-Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/riscv64/lib" \
CARGO_TARGET_X86_64_UNKNOWN_FUCHSIA_AR="/usr/local/bin/llvm-ar" \
CARGO_TARGET_X86_64_UNKNOWN_FUCHSIA_RUSTFLAGS="-C panic=abort \
-C force-unwind-tables=yes \
-C link-arg=--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot \
-Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot/lib \
-Lnative=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/lib"

ENV TARGETS=x86_64-unknown-fuchsia
ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnu
ENV TARGETS=aarch64-unknown-fuchsia,riscv64gc-unknown-fuchsia,x86_64-unknown-fuchsia
ENV TARGETS=$TARGETS,aarch64-unknown-linux-gnu,x86_64-unknown-linux-gnu

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand All @@ -60,17 +113,29 @@ ENV CODEGEN_BACKENDS="llvm"
# download-rustc is not allowed for `x install`
ENV NO_DOWNLOAD_CI_RUSTC="1"

ENV RUST_CONFIGURE_ARGS="--prefix=$RUST_INSTALL_DIR \
--sysconfdir=etc \
--enable-lld \
--llvm-libunwind=in-tree \
--enable-extended \
--disable-docs \
--set target.x86_64-unknown-fuchsia.cc=/usr/local/bin/clang \
--set target.x86_64-unknown-fuchsia.cxx=/usr/local/bin/clang++ \
--set target.x86_64-unknown-fuchsia.ar=/usr/local/bin/llvm-ar \
--set target.x86_64-unknown-fuchsia.ranlib=/usr/local/bin/llvm-ranlib \
--set target.x86_64-unknown-fuchsia.linker=/usr/local/bin/ld.lld"
ENV RUST_CONFIGURE_ARGS="\
--prefix=$RUST_INSTALL_DIR \
--sysconfdir=etc \
--enable-lld \
--llvm-libunwind=in-tree \
--enable-extended \
--disable-docs \
--set target.aarch64-unknown-fuchsia.cc=/usr/local/bin/clang \
--set target.aarch64-unknown-fuchsia.cxx=/usr/local/bin/clang++ \
--set target.aarch64-unknown-fuchsia.ar=/usr/local/bin/llvm-ar \
--set target.aarch64-unknown-fuchsia.ranlib=/usr/local/bin/llvm-ranlib \
--set target.aarch64-unknown-fuchsia.linker=/usr/local/bin/ld.lld \
--set target.riscv64gc-unknown-fuchsia.cc=/usr/local/bin/clang \
--set target.riscv64gc-unknown-fuchsia.cxx=/usr/local/bin/clang++ \
--set target.riscv64gc-unknown-fuchsia.ar=/usr/local/bin/llvm-ar \
--set target.riscv64gc-unknown-fuchsia.ranlib=/usr/local/bin/llvm-ranlib \
--set target.riscv64gc-unknown-fuchsia.linker=/usr/local/bin/ld.lld \
--set target.x86_64-unknown-fuchsia.cc=/usr/local/bin/clang \
--set target.x86_64-unknown-fuchsia.cxx=/usr/local/bin/clang++ \
--set target.x86_64-unknown-fuchsia.ar=/usr/local/bin/llvm-ar \
--set target.x86_64-unknown-fuchsia.ranlib=/usr/local/bin/llvm-ranlib \
--set target.x86_64-unknown-fuchsia.linker=/usr/local/bin/ld.lld"

ENV SCRIPT="python3 ../x.py install --target $TARGETS compiler/rustc library/std clippy && \
bash ../src/ci/docker/host-x86_64/x86_64-fuchsia/build-fuchsia.sh"
ENV SCRIPT="\
bash ../src/ci/docker/host-x86_64/test-x86_64-fuchsia/install-rust-for-fuchsia.sh && \
bash ../src/ci/docker/host-x86_64/test-x86_64-fuchsia/build-fuchsia.sh"
32 changes: 23 additions & 9 deletions src/ci/docker/host-x86_64/test-x86_64-fuchsia/build-fuchsia.sh
Comment thread
erickt marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#
# You may run this script locally using Docker with the following command:
#
# $ src/ci/docker/run.sh x86_64-fuchsia
# $ src/ci/docker/run.sh test-x86_64-fuchsia
#
# Alternatively, from within the container with --dev, assuming you have made it
# as far as building the toolchain with the above command:
#
# $ src/ci/docker/run.sh --dev x86_64-fuchsia
# docker# git config --global --add safe.directory /checkout/obj/fuchsia
# docker# ../src/ci/docker/host-x86_64/x86_64-fuchsia/build-fuchsia.sh
# $ src/ci/docker/run.sh --dev test-x86_64-fuchsia
# docker# ../src/ci/docker/host-x86_64/test-x86_64-fuchsia/install-rust-for-fuchsia.sh
# docker# ../src/ci/docker/host-x86_64/test-x86_64-fuchsia/build-fuchsia.sh
#
# Also see the docs in the rustc-dev-guide for more info:
# https://github.com/rust-lang/rustc-dev-guide/pull/1989
Expand All @@ -21,7 +21,7 @@ set -euf -o pipefail

# Set this variable to 1 to disable updating the Fuchsia checkout. This is
# useful for making local changes. You can find the Fuchsia checkout in
# `obj/x86_64-fuchsia/fuchsia` in your local checkout after running this
# `obj/test-x86_64-fuchsia/fuchsia` in your local checkout after running this
# job for the first time.
KEEP_CHECKOUT=

Expand All @@ -35,7 +35,7 @@ PICK_REFS=()
# commit hash of fuchsia.git and some other repos in the "monorepo" checkout, in
# addition to versions of prebuilts. It should be bumped regularly by the
# Fuchsia team – we aim for every 1-2 months.
INTEGRATION_SHA=f6f83d3e3852209f7752be55694006afbe979e50
INTEGRATION_SHA=be532c365aa6ba56b08ed684c0f8bb71960c18fd

checkout=fuchsia
jiri=.jiri_root/bin/jiri
Expand All @@ -46,14 +46,16 @@ if [ -z "$KEEP_CHECKOUT" ]; then
# This script will:
# - create a directory named "fuchsia" if it does not exist
# - download "jiri" to "fuchsia/.jiri_root/bin"
curl -s "https://fuchsia.googlesource.com/jiri/+/HEAD/scripts/bootstrap_jiri?format=TEXT" \
curl \
--retry 10 \
-s "https://fuchsia.googlesource.com/jiri/+/HEAD/scripts/bootstrap_jiri?format=TEXT" \
| base64 --decode \
| bash -s $checkout

cd $checkout

$jiri init \
-partial=true \
-partial-filter=tree:0 \
-analytics-opt=false \
.

Expand All @@ -69,7 +71,19 @@ if [ -z "$KEEP_CHECKOUT" ]; then
git checkout --force JIRI_HEAD
fi

$jiri update -autoupdate=false
# Check out Fuchsia, and skip downloading Fuchsia's rust toolchain, since we want to use the one
# we just built.
$jiri -j=10 update \
-autoupdate=false \
-attempts 10 \
-package-to-skip 'fuchsia/third_party/rust/host/${platform}' \
-package-to-skip 'fuchsia/third_party/rust/target/aarch64-apple-darwin' \
-package-to-skip 'fuchsia/third_party/rust/target/aarch64-unknown-linux-gnu' \
-package-to-skip 'fuchsia/third_party/rust/target/fuchsia' \
-package-to-skip 'fuchsia/third_party/rust/target/riscv64gc-unknown-linux-gnu' \
-package-to-skip 'fuchsia/third_party/rust/target/wasm32-unknown-unknown' \
-package-to-skip 'fuchsia/third_party/rust/target/x86_64-apple-darwin' \
-package-to-skip 'fuchsia/third_party/rust/target/x86_64-unknown-linux-gnu'

echo integration commit = $(git -C integration rev-parse HEAD)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -ex

# Build the components of Rust that are needed by the Fuchsia build system.
python3 ../x.py install \
--target=$TARGETS \
compiler/rustc library/std clippy rustfmt src

# The Fuchsia build system requires that shared libraries that are used inside Fuchsia are stripped,
# so use `llvm-objcopy` to remove the debug symbols and strip the libraries, but keeping the
# `.rustc` section needed by rust for dynamic linking.
find ${RUST_INSTALL_DIR}/lib/rustlib/*-fuchsia/lib \
-type f \
-name "*.so" \
-exec sh \
-c '/usr/local/bin/llvm-objcopy --only-keep-debug "$1" "$1.debug" && \
/usr/local/bin/llvm-objcopy --strip-all --keep-section=.rustc "$1"' \
_ \
{} \
\;
10 changes: 5 additions & 5 deletions src/ci/docker/scripts/build-fuchsia-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ set -ex
source shared.sh

FUCHSIA_SDK_URL=https://chrome-infra-packages.appspot.com/dl/fuchsia/sdk/core/linux-amd64
FUCHSIA_SDK_ID=version:26.20241211.7.1
FUCHSIA_SDK_SHA256=2cb7a9a0419f7413a46e0ccef7dad89f7c9979940d7c1ee87fac70ff499757d6
FUCHSIA_SDK_ID=version:33.20260909.5.1
FUCHSIA_SDK_SHA256=5d82a1ba625e91e0e93cf4f718dfde7e5c0fb833f83e95b8d8c00e3a3fe4f02e
FUCHSIA_SDK_USR_DIR=/usr/local/core-linux-amd64-fuchsia-sdk
CLANG_DOWNLOAD_URL=\
https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/linux-amd64
CLANG_DOWNLOAD_ID=git_revision:388d7f144880dcd85ff31f06793304405a9f44b6
CLANG_DOWNLOAD_SHA256=970d1f427b9c9a3049d8622c80c86830ff31b5334ad8da47a2f1e81143197e8b
CLANG_DOWNLOAD_ID=git_revision:5e63f2ce42db2c42f1d0012a3b5fa9c6113f750a
CLANG_DOWNLOAD_SHA256=2a97bbf480661bcc6f71f0abb1ff62365b9e94cc105a4d9a152e715c233f74d0

install_clang() {
mkdir -p clang_download
Expand All @@ -27,7 +27,7 @@ install_clang() {
cp -a clang-linux-amd64/. /usr/local

# CFLAGS and CXXFLAGS env variables in main Dockerfile handle sysroot linking
for arch in x86_64 aarch64; do
for arch in x86_64 aarch64 riscv64gc; do
for tool in clang clang++; do
ln -s /usr/local/bin/${tool} /usr/local/bin/${arch}-unknown-fuchsia-${tool}
done
Expand Down
17 changes: 7 additions & 10 deletions src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,13 @@ auto:
- name: test-various
<<: *job-linux-4c

# FIXME: temporarily disabled due to fuchsia server rate limits. See
# <https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/fuchsia.20failure/with/506637259>.
#
#- name: x86_64-fuchsia
# # Only run this job on the nightly channel. Fuchsia requires
# # nightly features to compile, and this job would fail if
# # executed on beta and stable.
# only_on_channel: nightly
# doc_url: https://rustc-dev-guide.rust-lang.org/tests/fuchsia.html
# <<: *job-linux-8c
- name: test-x86_64-fuchsia
# Only run this job on the nightly channel. Fuchsia requires
# nightly features to compile, and this job would fail if
# executed on beta and stable.
only_on_channel: nightly
doc_url: https://rustc-dev-guide.rust-lang.org/tests/fuchsia.html
<<: *job-linux-x86-8c-ec2

# Tests integration with Rust for Linux.
# Builds stage 1 compiler and tries to compile a few RfL examples with it.
Expand Down
22 changes: 13 additions & 9 deletions src/doc/rustc-dev-guide/src/tests/ecosystem-test-jobs/fuchsia.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ is merged.

If you are worried that a pull request might break the Fuchsia builder and want
to test it out before submitting it to the bors queue, simply ask bors to run
the try job that builds the Fuchsia integration: `@bors try jobs=x86_64-fuchsia`.
the try job that builds the Fuchsia integration:

```text
@bors try jobs=test-x86_64-fuchsia
```

## Building Fuchsia locally

Expand All @@ -33,24 +37,24 @@ simply run this command from your Rust checkout to download and build Fuchsia
using your local Rust toolchain.

```
src/ci/docker/run.sh x86_64-fuchsia
src/ci/docker/run.sh test-x86_64-fuchsia
```

See the [Testing with Docker](../docker.md) chapter for more details on how to run
and debug jobs with Docker.

Note that a Fuchsia checkout is *large* – as of this writing, a checkout and
build takes 46G of space – and as you might imagine, it takes a while to
build takes over 67G of space – and as you might imagine, it takes a while to
complete.

### Modifying the Fuchsia checkout

The main reason you would want to build Fuchsia locally is because you need to
investigate a regression. After running a Docker build, you'll find the Fuchsia
checkout inside the `obj/fuchsia` directory of your Rust checkout. If you
modify the `KEEP_CHECKOUT` line in the [build-fuchsia.sh] script to
`KEEP_CHECKOUT=1`, you can change the checkout as needed and rerun the build
command above. This will reuse all the build results from before.
checkout inside the `obj/test-x86_64-fuchsia/fuchsia` directory of your Rust
checkout. If you modify the `KEEP_CHECKOUT` line in the [build-fuchsia.sh]
script to `KEEP_CHECKOUT=1`, you can change the checkout as needed and rerun
the build command above. This will reuse all the build results from before.

You can find more options to customize the Fuchsia checkout in the
[build-fuchsia.sh] script.
Expand Down Expand Up @@ -158,8 +162,8 @@ rustc book][platform-support].

[regressions]: https://gist.github.com/tmandry/7103eba4bd6a6fb0c439b5a90ae355fa
[build-toolchain]: https://fuchsia.dev/fuchsia-src/development/build/rust_toolchain
[build-fuchsia.sh]: https://github.com/rust-lang/rust/blob/221e2741c39515a5de6da42d8c76ee1e132c2c74/src/ci/docker/host-x86_64/x86_64-fuchsia/build-fuchsia.sh
[build_fuchsia_from_rust_ci.sh]: https://cs.opensource.google/fuchsia/fuchsia/+/main:scripts/rust/build_fuchsia_from_rust_ci.sh?q=build_fuchsia_from_rust_ci&ss=fuchsia
[build-fuchsia.sh]: https://github.com/rust-lang/rust/blob/main/src/ci/docker/host-x86_64/test-x86_64-fuchsia/build-fuchsia.sh
[build_fuchsia_from_rust_ci.sh]: https://cs.opensource.google/fuchsia/fuchsia/+/main:scripts/rust/build_fuchsia_from_rust_ci.sh
[platform-support]: https://doc.rust-lang.org/nightly/rustc/platform-support/fuchsia.html
[GN]: https://gn.googlesource.com/gn/+/main#gn
[Ninja]: https://ninja-build.org/
Expand Down
Loading