'/lib/swift/linux/x86_64/swiftrt.o', needed by 'lib/libswiftDemangle.so', missing when building swift from source

Hello there, I'm trying to build swift from source on ArchLinux following the getting started
but I get ninja: error: '/lib/swift/linux/x86_64/swiftrt.o', needed by 'lib/libswiftDemangle.so', missing and no known rule to make it and the ../build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift/linux/x86_64 directory is empty.

Here's the gist containing full build output and output of utils/update-checkout --dump-hashes

Am I missing some linux specific flags on utils/build-script necessary to properly build it? :thinking:

You're adding a --linux-archs flag that is not mentioned in that getting started doc. I should know, as I added the linux command to that doc. I had never even seen that flag, turns out it was just added last year as part of Alastair's work for the static linux SDK and is unused by any of the current build presets.

What are you adding that flag for and what do you want to build exactly? If you just run the linux command from the doc, without that recent flag, it should build the compiler and stdlib alone for the host.

I added the --linux-archs flag because the build wasn't working for me even without it, so I thought I'd try including it to see if it might help. But it fails with the same error either way :sweat_smile:

I've updated the gist too.

Not quite, that shows it is simply reusing the old CMake config from before. Wipe the build directory with rm -rf /home/saheed/projects/builds/swift-project/build/ and run the build again.

still the same (╥﹏╥)

but has much bigger output

OK, that fresh CMake log output is helpful, so we know what it is trying to set. It looks like you built LLVM just fine, but your ninja config for the Swift compiler frontend has gone askew in some way. Comparing to my local Android build from a couple months ago, I see that the path for that object file is set by an internal variable:

> ag 64/swiftrt.o: build/Ninja-Release/swift-android-aarch64/build.ninja
24862:build lib/swift/android/aarch64/swiftrt.o lib/swift_static/android/aarch64/swiftrt.o | ${cmake_ninja_workdir}lib/swift/android/aarch64/swiftrt.o ${cmake_ninja_workdir}lib/swift_static/android/aarch64/swiftrt.o: CUSTOM_COMMAND stdlib/public/runtime/CMakeFiles/swiftImageRegistrationObjectELF-android-aarch64.dir/SwiftRT-ELF-WASM.cpp.o

> ag ninja_workdir build/Ninja-Release/swift-android-aarch64/build.ninja | head -1
42:cmake_ninja_workdir = /data/data/com.termux/files/home/build/Ninja-Release/swift-android-aarch64/

It seems like cmake_ninja_workdir is incorrectly being set to / for you, not to your actual build directory. Check those variables in your own build.ninja config for linux x86_64, and any guesses for why it's incorrect will need to be investigated by you, as I've never seen it fail like this.

1 Like