Skip to content

Commit 1072ff1

Browse files
committed
[Static Linux SDK] Build script improvements.
When running on an aarch64 host, we need to download a different version of the Swift compiler in order to do the build. If we run the build on a macOS host, we also have to tell the update-checkout script to fetch all the required dependencies (even Linux-only ones). Also tell Foundation where swift-collections lives, to avoid it fetching another copy.
1 parent cd8fc32 commit 1072ff1

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

swift-ci/sdks/static-linux/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ ARG BORINGSSL_VERSION=fips-20220613
2424
ARG ICU_VERSION=maint/maint-69
2525
ARG ZLIB_VERSION=1.3.1
2626

27+
# Architecture to build on (empty means x86-64)
28+
ARG OS_ARCH_SUFFIX=
29+
2730
# ............................................................................
2831

2932
# Install development tools
@@ -62,7 +65,7 @@ ENV SWIFT_SIGNING_KEY=$SWIFT_SIGNING_KEY \
6265
OS_MAJOR_VER=$OS_MAJOR_VER \
6366
OS_MINOR_VER=$OS_MINOR_VER \
6467
OS_VER=$SWIFT_PLATFORM$OS_MAJOR_VER.$OS_MINOR_VER \
65-
SWIFT_WEBROOT="$SWIFT_WEBROOT/$SWIFT_PLATFORM$OS_MAJOR_VER$OS_MINOR_VER"
68+
SWIFT_WEBROOT="$SWIFT_WEBROOT/$SWIFT_PLATFORM$OS_MAJOR_VER$OS_MINOR_VER$OS_ARCH_SUFFIX"
6669

6770
COPY scripts/install-swift.sh /scripts/install-swift.sh
6871
RUN chmod ugo+x /scripts/install-swift.sh

swift-ci/sdks/static-linux/build

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,33 @@
1414
#
1515
# ===----------------------------------------------------------------------===
1616

17-
DOCKER=docker
17+
if [[ "$DOCKER" == "" ]]; then
18+
DOCKER=docker
19+
fi
20+
21+
case $(arch) in
22+
arm64|aarch64)
23+
OS_ARCH_SUFFIX=-aarch64
24+
;;
25+
amd64|x86_64)
26+
OS_ARCH_SUFFIX=
27+
;;
28+
*)
29+
echo "Unknown architecture $(arch)"
30+
exit 1
31+
;;
32+
esac
1833

1934
# Build the Docker image
20-
$(DOCKER) build -t static-swift-linux .
35+
$DOCKER build --build-arg OS_ARCH_SUFFIX=$OS_ARCH_SUFFIX -t static-swift-linux .
2136

2237
# Check-out the sources
2338
scripts/fetch-source.sh --clone-with-ssh --source-dir source
2439

2540
mkdir -p products
2641

2742
# Run the build
28-
$(DOCKER) run -it --rm \
43+
$DOCKER run -it --rm \
2944
-v ./source:/source \
3045
-v ./products:/products \
3146
static-swift-linux \

swift-ci/sdks/static-linux/scripts/build.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,20 @@ while [ "$#" -gt 0 ]; do
144144
shift
145145
done
146146

147+
# Work out the host architecture
148+
case $(arch) in
149+
arm64|aarch64)
150+
host_arch=arm64
151+
;;
152+
amd64|x86_64)
153+
host_arch=x86_64
154+
;;
155+
*)
156+
echo "Unknown host architecture $(arch)"
157+
exit 1
158+
;;
159+
esac
160+
147161
# Change the commas for spaces
148162
archs="${archs//,/ }"
149163

@@ -662,7 +676,7 @@ EOF
662676
--compiler-vendor=apple \
663677
--bootstrapping hosttools \
664678
--build-linux-static --install-swift \
665-
--stdlib-deployment-targets linux-x86_64,linux-static-$arch \
679+
--stdlib-deployment-targets linux-$host_arch,linux-static-$arch \
666680
--build-stdlib-deployment-targets all \
667681
--musl-path=${build_dir}/sdk_root \
668682
--linux-static-arch=$arch \
@@ -724,6 +738,7 @@ EOF
724738
-DFOUNDATION_PATH_TO_LIBDISPATCH_BUILD=${build_dir}/$arch/dispatch \
725739
-D_SwiftFoundation_SourceDIR=${source_dir}/swift-project/swift-foundation \
726740
-D_SwiftFoundationICU_SourceDIR=${source_dir}/swift-project/swift-foundation-icu \
741+
-D_SwiftCollections_SourceDIR=${source_dir}/swift-project/swift-collections \
727742
-DCMAKE_Swift_COMPILER_WORKS=YES \
728743
-Ddispatch_DIR=${build_dir}/$arch/dispatch/cmake/modules
729744

swift-ci/sdks/static-linux/scripts/fetch-source.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ cd swift
164164
# Get its dependencies
165165
header "Fetching Swift Dependencies"
166166

167-
extra_args=--skip-history
167+
extra_args="--skip-history --all-repositories"
168168
if [[ $SWIFT_VERSION == scheme:* ]]; then
169169
utils/update-checkout ${clone_arg} --scheme ${SWIFT_VERSION#scheme:} ${extra_args}
170170
elif [[ $SWIFT_VERSION == tag:* ]]; then

0 commit comments

Comments
 (0)