I am following the recommended guide (swift/docs/HowToGuides/GettingStarted.md at main · swiftlang/swift · GitHub) to compile Swift on my local machine (Ubuntu 24.04 LTS). I installed a prebuilt Swift release toolchain using Swiftly (guide: Swift.org - Install Swift) and then built swift.
utils/build-script --release-debuginfo --xctest --sccache --debug-swift
The build fails with this error.
ninja: error: '/home/rup/.local/share/swiftly/lib/swift/linux/x86_64/swiftrt.o', needed by 'lib/libswiftDemangle.so', missing and no known rule to make it
I checked I don't have a lib
directory in ~/.local/share/swiftly
.
A build log that I found has 8 lines which I quote below. This could provide some context about the stage at which the build failed. (I could not find a full build log; any pointer to one is appreciated.)
swift-project/swift/build/.build_script_log
{"event": "start", "command": "Building earlyswiftdriver", "duration": "0.00"}
{"event": "end", "command": "Building earlyswiftdriver", "duration": "121.19"}
{"event": "start", "command": "Building cmark", "duration": "0.00"}
{"event": "end", "command": "Building cmark", "duration": "2.17"}
{"event": "start", "command": "Building llvm", "duration": "0.00"}
{"event": "end", "command": "Building llvm", "duration": "2881.73"}
{"event": "start", "command": "linux-x86_64-swift-build", "duration": "0.00"}
{"event": "end", "command": "linux-x86_64-swift-build", "duration": "12.68"}
This ninja build script shows what invoked the compilation:
swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-linux-x86_64/build.ninja
#############################################
Link the shared library lib/libswiftDemangle.so
build lib/libswiftDemangle.so: CXX_SHARED_LIBRARY_LINKER__swiftDemangle_Debug lib/SwiftDemangle/CMakeFiles/swiftDemangle.dir/SwiftDemangle.cpp.o lib/SwiftDemangle/CMakeFiles/swiftDemangle.dir/MangleHack.cpp.o | /home/rup/.local/share/swiftly/lib/swift/linux/x86_64/swiftrt.o lib/libswiftDemangling.a || clang-tablegen-targets intrinsics_gen lib/libswiftDemanglin
g.a
LANGUAGE_COMPILE_FLAGS = -Wno-unknown-warning-option -Werror=unguarded-availability-new -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-ty
pe -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g
LINK_FLAGS = -target x86_64-unknown-linux-gnu -fuse-ld=gold -Xlinker --build-id=sha1
LINK_LIBRARIES = -Wl,-rpath,"$$ORIGIN:$$ORIGIN/./swift/linux" -lpthread -ldl /home/rup/.local/share/swiftly/lib/swift/linux/x86_64/swiftrt.o -lswiftCore lib/libswiftDemangling.a -lpthread -ldl
LINK_PATH = -L/home/rup/swifthack/local/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/llvm-linux-x86_64/./lib -L/home/rup/swifthack/local/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-linux-x86_64/lib -L/home/rup/.local/share/swiftly/lib/swift/linux -L/home/rup/.local/share/swiftly/lib/swift/linux/x86_64
OBJECT_DIR = lib/SwiftDemangle/CMakeFiles/swiftDemangle.dir
POST_BUILD = :
PRE_LINK = :
SONAME = libswiftDemangle.so
SONAME_FLAG = -Wl,-soname,
TARGET_COMPILE_PDB = lib/SwiftDemangle/CMakeFiles/swiftDemangle.dir/
TARGET_FILE = lib/libswiftDemangle.so
TARGET_PDB = lib/libswiftDemangle.pdb
pool = local_jobs
What could I have missed out, in the pre-build steps, in order to prep for the build?