i suppose i brought this on myself by trying to use a “custom built toolchain” in the first place. but sadly these days we have no other choice on the server as swift has no support Amazon Linux 2023 and nobody at Apple seems to be working on it.
when i use the official 5.9.2 toolchain for a different platform (Amazon Linux 2), my project compiles without problems. when i use my custom Amazon Linux 2023 5.9.2 toolchain, i get this strange SIL verification error:
error: compile command failed due to signal 6 (use -v to see invocation)
SIL verification failed: result of struct_extract does not match type of field
$@moveOnly Phylum.Language
$Phylum.Language
Verifying instruction:
< lots and lots of SIL dumped >
1. Swift version 5.9.2 (swift-5.9.2-RELEASE)
2. Compiling with the current language version
3. While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for SymbolGraphCompiler)
4. While running pass #447 SILModuleTransform "MandatoryInlining".
...
note that SymbolGraphCompiler
is a module in my project, it is not related to the swift compiler.
dockerfile:
build the toolchain:
$ docker build . -t tayloraswift/swift-toolchain-build:5.9.2 --build-arg SWIFT_BRANCH_CHECKOUT=swift-5.9.2-RELEASE --build-arg SWIFT_VERSION=5.8.1
FROM amazonlinux:2023
RUN yum -y update
# install sysadmin basics
RUN yum -y install sudo passwd
# install swift dependencies
RUN yum install shadow-utils -y
RUN yum -y group install "development tools"
RUN yum -y install \
cmake \
curl-devel \
git \
glibc-static \
libbsd-devel \
libedit-devel \
libicu-devel \
libuuid-devel \
libxml2-devel \
ncurses-devel \
pkgconfig \
procps-ng \
python \
python-devel \
python-pkgconfig \
python-six \
python3-devel \
python3-psutil \
rsync \
sqlite-devel \
swig \
tzdata \
unzip \
uuid-devel \
wget \
which \
zip
RUN mkdir -p /usr/local/lib/python3.7/site-packages/
ARG SWIFT_BRANCH_CHECKOUT=main
ARG SWIFT_PLATFORM=amazonlinux2
ARG SWIFT_VERSION=5.9.2
ARG SWIFT_BRANCH=swift-${SWIFT_VERSION}-release
ARG SWIFT_TAG=swift-${SWIFT_VERSION}-RELEASE
ARG SWIFT_WEBROOT=https://download.swift.org
ARG SWIFT_PREFIX=/opt/swift/${SWIFT_VERSION}
ENV SWIFT_BRANCH_CHECKOUT=$SWIFT_BRANCH_CHECKOUT \
SWIFT_PLATFORM=$SWIFT_PLATFORM \
SWIFT_VERSION=$SWIFT_VERSION \
SWIFT_BRANCH=$SWIFT_BRANCH \
SWIFT_TAG=$SWIFT_TAG \
SWIFT_WEBROOT=$SWIFT_WEBROOT \
SWIFT_PREFIX=$SWIFT_PREFIX
RUN dnf -y install dirmngr --allowerasing
RUN dnf swap gnupg2-minimal gnupg2-full
RUN set -e; \
ARCH_NAME="$(rpm --eval '%{_arch}')"; \
url=; \
case "${ARCH_NAME##*-}" in \
'x86_64') \
OS_ARCH_SUFFIX=''; \
;; \
'aarch64') \
OS_ARCH_SUFFIX='-aarch64'; \
;; \
*) echo >&2 "error: unsupported architecture: '$ARCH_NAME'"; exit 1 ;; \
esac; \
SWIFT_WEBDIR="$SWIFT_WEBROOT/$SWIFT_BRANCH/$(echo $SWIFT_PLATFORM | tr -d .)$OS_ARCH_SUFFIX" \
&& SWIFT_BIN_URL="$SWIFT_WEBDIR/$SWIFT_TAG/$SWIFT_TAG-$SWIFT_PLATFORM$OS_ARCH_SUFFIX.tar.gz" \
&& SWIFT_SIG_URL="$SWIFT_BIN_URL.sig" \
&& echo $SWIFT_BIN_URL \
# - Download the GPG keys, Swift toolchain, and toolchain signature, and verify.
&& export GNUPGHOME="$(mktemp -d)" \
&& curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_SIG_URL" -o swift.tar.gz.sig \
&& curl -fSsL https://swift.org/keys/all-keys.asc | gpg --import - \
&& gpg --batch --verify swift.tar.gz.sig swift.tar.gz \
# - Unpack the toolchain, set libs permissions, and clean up.
&& mkdir -p $SWIFT_PREFIX \
&& tar -xzf swift.tar.gz --directory $SWIFT_PREFIX --strip-components=1 \
&& chmod -R o+r $SWIFT_PREFIX/usr/lib/swift \
&& rm -rf "$GNUPGHOME" swift.tar.gz.sig swift.tar.gz
ENV PATH="${SWIFT_PREFIX}/usr/bin:${PATH}"
RUN yum install -y gcc-c++
RUN sudo yum install -y libmpc-devel
RUN sudo yum install -y texinfo
RUN git clone --depth 1 git://sourceware.org/git/binutils-gdb.git binutils
RUN mkdir binutils.build
RUN cd binutils.build
RUN ../binutils/configure --enable-gold --enable-plugins --disable-werror
RUN make all-gold
RUN mv gold/ld-new /usr/bin/ld.gold
RUN cd ..
RUN mkdir /swift-project
WORKDIR /swift-project
RUN git clone --depth 1 --branch $SWIFT_BRANCH_CHECKOUT https://github.com/apple/swift
WORKDIR /swift-project/swift
RUN utils/update-checkout --clone --tag $SWIFT_BRANCH_CHECKOUT
COPY preset.ini build-preset-ext.ini
RUN cat build-preset-ext.ini >> utils/build-presets.ini
RUN utils/build-script \
--preset buildbot_linux_amazon_linux_2023 \
install_destdir=/swift-install \
installable_package=/swift-install/swift-TAYLORS-VERSION.tar.gz \
package the toolchain:
FROM amazonlinux:2023
RUN yum -y update
# install sysadmin basics
RUN yum -y install sudo passwd
# install swift dependencies
RUN yum -y install \
binutils \
gcc \
git \
unzip \
glibc-static \
gzip \
libbsd \
libcurl-devel \
libedit \
libicu \
libstdc++-static \
libuuid \
libxml2-devel \
tar \
tzdata \
zlib-devel
COPY --from=tayloraswift/swift-toolchain-build:5.9.2 /usr/bin/ld.gold /usr/bin/ld.gold
# install swift
COPY --from=tayloraswift/swift-toolchain-build:5.9.2 /swift-install /swift-install
RUN cp -r /swift-install/usr/bin/* /usr/bin
RUN cp -r /swift-install/usr/include/* /usr/include/
RUN cp -r /swift-install/usr/libexec/* /usr/libexec/
RUN cp -r /swift-install/usr/lib/* /usr/lib/
RUN cp -r /swift-install/usr/local/* /usr/local
RUN cp -r /swift-install/usr/share/* /usr/share
# create the `ec2-user`, and switch to her
RUN useradd -ms /bin/bash ec2-user
RUN passwd -d ec2-user
RUN usermod -aG wheel ec2-user
USER ec2-user
WORKDIR /home/ec2-user/
# optional, but python, and iptables are very useful in a container
RUN sudo yum -y install python3 python3-devel iptables nc
# jemalloc
RUN sudo yum -y install bzip2 make
RUN curl https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2 \
-L -o jemalloc-5.3.0.tar.bz2
RUN tar -xf jemalloc-5.3.0.tar.bz2
RUN cd jemalloc-5.3.0 && ./configure && make && sudo make install
# generate script that will run on terminal creation,
# enables showing the PWD prompt
RUN echo "PS1='\w\$ '" >> .bashrc
RUN echo "force_color_prompt=yes" >> .bashrc
ENV TERM xterm-256color
CMD sleep infinity
preset extension:
[preset: buildbot_linux_amazon_linux_2023]
mixin-preset=
buildbot_linux
mixin_buildbot_linux,no_test
skip-early-swift-driver
perhaps running the test suites would illuminate the issue, but as discussed on another thread, those needed to be disabled in order to successfully build the toolchain in the first place.