swift: [build] fails to build on Amazon Linux 2023
I am trying to build the tool chain on Amazon Linux 2023 (ALI2023)
I identified two changes on ALI2023 (vs ALI2) that impact the build:
- the first one is the lack of support for
ld.gold
forcing me to modify the swift build scripts to uselld
on Amazon Linux 2023 only (other platforms Ubuntu, ALI2, RedHat, Oracle Linux, Debian all provideld.gold
) - the second one is specific to Arm : the clang tool chain is located under
/lib/gcc/aarch64-amazon-linux/11
which is not found - by default - byclang
.
Knowing that, I managed to build LLVM and Swift and its dependencies on x64 and arm64 architectures using build-script
with NO PRESETS. This is the command that works. As I mentioned, I have to use lld
because ld.gold
is unavailable on Amazon Linux 2023.
./swift//utils/build-script --release-debuginfo --skip-early-swift-driver --extra-cmake-options="-DLLVM_USE_LINKER=lld"
🎉 this builds the entire project
My ultimate goal is to add support for ALi2023 to the swift-installer-scripts project. This projects uses the build-script
python script with presets. So I created a new preset for Amazon Linux 2023 to mimic both current behaviour when building Amazon Linux 2 + the two new settings I used on the command that works.
This is my new preset in build-preset.ini
:
[preset: buildbot_amazon_linux_2023,no_assertions,no_test]
extra-cmake-options=-DLLVM_USE_LINKER=lld
skip-early-swift-driver
mixin-preset=
buildbot_linux,no_assertions
mixin_buildbot_linux,no_test
And the command I use to test it
swift/utils/build-script --preset=buildbot_amazon_linux_2023,no_assertions,no_test install_destdir=/tmp installable_package=/tmp/swift-5.7.3-amazonlinux2023.tar.gz
This fails when the build tests the newly built swiftc
compiler because it looks like the LLVM_USE_LINKER=lld
flag is passed as environment variable but the CMakeList.txt
script is not executed to test the new compiler, hence gold
being used.
Here is the full error message. What am I doing wrong ?
+ env /usr/bin/cmake -DENABLE_SWIFT=YES -G Ninja -DCMAKE_C_COMPILER:PATH=/usr/bin/clang -DCMAKE_CXX_COMPILER:PATH=/usr/bin/clang++ -DCMAKE_Swift_COMPILER:PATH= -DCMAKE_LIBTOOL:PATH= -DCMAKE_AR:PATH=/usr/bin/ar -DCMAKE_RANLIB:PATH=/usr/bin/ranlib -DLLVM_VERSION_MAJOR:STRING=13 -DLLVM_VERSION_MINOR:STRING=0 -DLLVM_VERSION_PATCH:STRING=0 -DCLANG_VERSION_MAJOR:STRING=13 -DCLANG_VERSION_MINOR:STRING=0 -DCLANG_VERSION_PATCH:STRING=0 -DCMAKE_MAKE_PROGRAM=/home/ec2-user/project-swift/build/buildbot_linux/ninja-build/ninja -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_COMPILER:PATH=/home/ec2-user/project-swift/build/buildbot_linux/llvm-linux-aarch64/bin/clang -DCMAKE_CXX_COMPILER:PATH=/home/ec2-user/project-swift/build/buildbot_linux/llvm-linux-aarch64/bin/clang++ -DCMAKE_SWIFT_COMPILER:PATH=/home/ec2-user/project-swift/build/buildbot_linux/swift-linux-aarch64/bin/swiftc -DCMAKE_Swift_COMPILER:PATH=/home/ec2-user/project-swift/build/buildbot_linux/swift-linux-aarch64/bin/swiftc '-DCMAKE_Swift_FLAGS:STRING= -module-cache-path "/home/ec2-user/project-swift/build/buildbot_linux/libdispatch-linux-aarch64/module-cache" ' -DCMAKE_INSTALL_PREFIX:PATH=/usr/ -DCMAKE_INSTALL_LIBDIR:PATH=lib -DSwift_DIR=/home/ec2-user/project-swift/build/buildbot_linux/swift-linux-aarch64/lib/cmake/swift -DENABLE_TESTING=YES -DBUILD_SHARED_LIBS=YES -DLLVM_USE_LINKER=lld /home/ec2-user/project-swift/swift-corelibs-libdispatch
-- The C compiler identification is Clang 13.0.0
-- The CXX compiler identification is Clang 13.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/ec2-user/project-swift/build/buildbot_linux/llvm-linux-aarch64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/ec2-user/project-swift/build/buildbot_linux/llvm-linux-aarch64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- The Swift compiler identification is Apple 5.7.3
-- Check for working Swift compiler: /home/ec2-user/project-swift/build/buildbot_linux/swift-linux-aarch64/bin/swiftc
-- Check for working Swift compiler: /home/ec2-user/project-swift/build/buildbot_linux/swift-linux-aarch64/bin/swiftc - broken
CMake Error at /usr/share/cmake/Modules/CMakeTestSwiftCompiler.cmake:44 (message):
The Swift compiler
"/home/ec2-user/project-swift/build/buildbot_linux/swift-linux-aarch64/bin/swiftc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/ec2-user/project-swift/build/buildbot_linux/libdispatch-linux-aarch64/CMakeFiles/CMakeTmp
Run Build Command(s):/home/ec2-user/project-swift/build/buildbot_linux/ninja-build/ninja cmTC_5c601 && [1/1][100%][0.112s] Linking Swift executable cmTC_5c601
FAILED: cmTC_5c601 CMakeFiles/cmTC_5c601.dir/main.swift.o cmTC_5c601.swiftmodule
: && /home/ec2-user/project-swift/build/buildbot_linux/swift-linux-aarch64/bin/swiftc -output-file-map CMakeFiles/cmTC_5c601.dir//output-file-map.json -incremental -j 64 -emit-executable -o cmTC_5c601 -emit-dependencies -module-cache-path "/home/ec2-user/project-swift/build/buildbot_linux/libdispatch-linux-aarch64/module-cache" -module-cache-path "/home/ec2-user/project-swift/build/buildbot_linux/libdispatch-linux-aarch64/module-cache" /home/ec2-user/project-swift/build/buildbot_linux/libdispatch-linux-aarch64/CMakeFiles/CMakeTmp/main.swift && :
clang-15: error: invalid linker name in argument '-fuse-ld=gold'
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:128 (enable_language)
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (7 by maintainers)
I had to let this project aside for a while. Thank you @finagolfin you were correct. After doing a full clean, git clone again etc. I managed to build 5.9.1 without patching anything, just by ensuring 5.8 is installed and available in the path (and using the gold linker)
You’re right @finagolfin I should have shared more details