`swift-def-to-yaml-converter: No such file or directory` when building the toolchain on Exherbo

Context: see Swift on Exherbo

I'm trying to compile the Swift toolchain on Exherbo, and I'm facing an error I can't work around:

[1/942][  0%][0.010s] Generating ../share/swift/diagnostics/generated
FAILED: share/swift/diagnostics/generated /home/bas/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/share/swift/diagnostics/generated
cd /home/bas/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/localization && /usr/x86_64-pc-linux-gnu/bin/cmake -E copy_directory /home/bas/swift-project/swift/localization/diagnostics/ /home/bas/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/share/swift/diagnostics/ && /home/bas/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/./bin/swift-def-to-yaml-converter --output-directory /home/bas/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/share/swift/diagnostics/ && /home/bas/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/./bin/swift-serialize-diagnostics --input-file-path /home/bas/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/share/swift/diagnostics/en.yaml --output-directory /home/bas/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/share/swift/diagnostics/ && /usr/x86_64-pc-linux-gnu/bin/cmake -E touch /home/bas/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/share/swift/diagnostics/generated
/bin/sh: line 1: /home/bas/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/./bin/swift-def-to-yaml-converter: No such file or directory

(The /home/bas/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/./bin/swift-def-to-yaml-converter file exists, is executable, not empty, and accessible (I'm root))

You can find the (truncated) log here and comments on my progression in this Gist: Error when building Swift on Exherbo (2022-05-17-a) · GitHub

Does anyone know why this problem happens?

Note: I'm creating a topic here, and not a GitHub issue, as asked by swift/GettingStarted.md at main · apple/swift · GitHub.

The toolchain builds its own fork of clang and thus will be missing patches for the loader changes that I had created with the cross compilation support for exherbo. You will need to patch that in as I don’t think that it was ever merged upstream. You could also work around that with flags (-Xlinker -I/usr/$(exhost --build)/ld-linux-$(uname -m).so.2) but would need to do a two phase build as the build tools need different flags and the CMake setup is not setup properly for building build tools.

1 Like

What do you mean by a two phase build? What should be built in each phase?

See the windows builds. The build tools need to be built first for build and passed along to the subsequent builds. This will enable you to use the correct flags for the tooling. Make sure that you include the linker flags as the compiler won’t do that unless you’re using the patches gcc or clang. Without that you will likely get an incorrect PT_INTERP which will manifest as the problem that you saw.

Thank you :pray:t2:
I'll do some research and read your contributions tonight, and try them tomorrow :slightly_smiling_face:
As always, I'll keep you in touch :wink: