Skip to content
Merged
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
55 changes: 49 additions & 6 deletions swift-ci/sdks/static-linux/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ function run() {
"$@"
}

# -----------------------------------------------------------------------

header "Building CMake from source"

quiet_pushd ${source_dir}/swift-project/cmake
Expand All @@ -255,6 +257,8 @@ run export PATH="${build_dir}/cmake/install/bin:$PATH"
quiet_popd
run cmake --version

# -----------------------------------------------------------------------

header "Patching Musl"

echo -n "Patching Musl for locale support... "
Expand All @@ -268,6 +272,45 @@ else
exit 1
fi

# -----------------------------------------------------------------------

header "Patching BoringSSL"

echo -n "Patching BoringSSL to disable -Werror... "
sed -i.bak "s/-Werror //g" ${source_dir}/boringssl/CMakeLists.txt
echo "done"

# -----------------------------------------------------------------------

header "Building clang for host"

mkdir -p ${build_dir}/host/clang ${build_dir}/clang

run cmake -G Ninja -S ${source_dir}/swift-project/llvm-project/llvm \
-B ${build_dir}/host/clang \
Comment on lines +289 to +290
Copy link

@AnthonyLatsis AnthonyLatsis Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this work with the source dir being llvm-project/llvm instead of llvm-project/clang?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually doesn't work with the source dir being llvm-project/clang (that's the first thing I tried). Using llvm rather than clang is actually what the instructions here say to do.

-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="clang" \
-DLLVM_PARALLEL_LINK_JOBS=1 \
-DCMAKE_INSTALL_PREFIX=${build_dir}/clang

quiet_pushd ${build_dir}/host/clang
run ninja -j$parallel_jobs
quiet_popd

header "Installing clang for host"

quiet_pushd ${build_dir}/host/clang
run ninja -j$parallel_jobs install
quiet_popd

clang_dir=${build_dir}/clang

header "Clang version"

${clang_dir}/bin/clang --version

# -----------------------------------------------------------------------

for arch in $archs; do

# Fix architecture names
Expand All @@ -288,11 +331,11 @@ for arch in $archs; do
"${sdk_root}/usr/lib/swift_static"
ln -sf ../swift/clang "${sdk_root}/usr/lib/swift_static/clang"

clang_resource_dir=$(${swift_dir}/bin/clang -print-resource-dir)
clang_resource_dir=$(${clang_dir}/bin/clang -print-resource-dir)
cp -rT $clang_resource_dir/include $sdk_resource_dir/include

cc="${swift_dir}/bin/clang -target $triple -resource-dir ${sdk_resource_dir} --sysroot ${sdk_root}"
cxx="${swift_dir}/bin/clang++ -target $triple -resource-dir ${sdk_resource_dir} --sysroot ${sdk_root} -stdlib=libc++ -unwindlib=libunwind"
cc="${clang_dir}/bin/clang -target $triple -resource-dir ${sdk_resource_dir} --sysroot ${sdk_root}"
cxx="${clang_dir}/bin/clang++ -target $triple -resource-dir ${sdk_resource_dir} --sysroot ${sdk_root} -stdlib=libc++ -unwindlib=libunwind"
as="$cc"

# Creating this gets rid of a warning
Expand Down Expand Up @@ -406,9 +449,9 @@ set(CMAKE_SYSROOT ${sdk_root})
set(CMAKE_CROSSCOMPILING=YES)
set(CMAKE_EXE_LINKER_FLAGS "-unwindlib=libunwind -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld -lc++ -lc++abi")

set(CMAKE_C_COMPILER ${swift_dir}/bin/clang -resource-dir ${sdk_resource_dir})
set(CMAKE_CXX_COMPILER ${swift_dir}/bin/clang++ -resource-dir ${sdk_resource_dir} -stdlib=libc++)
set(CMAKE_ASM_COMPILER ${swift_dir}/bin/clang -resource-dir ${sdk_resource_dir})
set(CMAKE_C_COMPILER ${clang_dir}/bin/clang -resource-dir ${sdk_resource_dir})
set(CMAKE_CXX_COMPILER ${clang_dir}/bin/clang++ -resource-dir ${sdk_resource_dir} -stdlib=libc++)
set(CMAKE_ASM_COMPILER ${clang_dir}/bin/clang -resource-dir ${sdk_resource_dir})
set(CMAKE_FIND_ROOT_PATH ${sdk_root})
EOF

Expand Down
Loading