Building Swift on Ubuntu fails with 'unknown argument: -gsplit-dwarf'

I am trying to build the most recent version of the Swift compiler on Ubuntu 20.04 (x86-64) and am getting the following error message:

[291/1179][ 24%][85.015s] Linking Swift static library lib/libTestPureSwiftStaticLib.a
FAILED: lib/libTestPureSwiftStaticLib.a validation-test/BuildSystem/swift-cmake/CMakeFiles/TestPureSwiftStaticLib.dir/Klass.swift.o validation-test/BuildSystem/swift-cmake/TestPureSwiftStaticLib.swiftmodule 
: && /home/fw/.swiftenv/shims/swiftc -output-file-map validation-test/BuildSystem/swift-cmake/CMakeFiles/TestPureSwiftStaticLib.dir/RelWithDebInfo/output-file-map.json -incremental -j 8 -emit-library -static -o lib/libTestPureSwiftStaticLib.a -module-name TestPureSwiftStaticLib -module-link-name TestPureSwiftStaticLib -emit-module -emit-module-path validation-test/BuildSystem/swift-cmake/TestPureSwiftStaticLib.swiftmodule -emit-dependencies -DCMARK_STATIC_DEFINE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O -g -gsplit-dwarf -target x86_64-unknown-linux-gnu -g -cross-module-optimization -import-objc-header /home/fw/git/swift-project/swift/validation-test/BuildSystem/swift-cmake/CPPLib.h -I validation-test/BuildSystem/swift-cmake -I /home/fw/git/swift-project/swift/validation-test/BuildSystem/swift-cmake -I include -I /home/fw/git/swift-project/swift/include -I /home/fw/git/swift-project/llvm-project/llvm/include -I /home/fw/git/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-linux-x86_64/include -I /home/fw/git/swift-project/llvm-project/clang/include -I /home/fw/git/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-linux-x86_64/tools/clang/include -I /home/fw/git/swift-project/cmark/src -I /home/fw/git/swift-project/build/Ninja-RelWithDebInfoAssert/cmark-linux-x86_64/src -I /home/fw/git/swift-project/swift-corelibs-libdispatch/src/BlocksRuntime -I /home/fw/git/swift-project/swift-corelibs-libdispatch /home/fw/git/swift-project/swift/validation-test/BuildSystem/swift-cmake/Klass.swift    && :
<unknown>:0: error: unknown argument: '-gsplit-dwarf'
[298/1179][ 25%][107.761s] Building CXX object tools/swift-reflection-dump/CMakeFiles/swift-reflection-dump.dir/swift-reflection-dump.cpp.o
ninja: build stopped: subcommand failed.
ERROR: command terminated with a non-zero exit status 1, aborting

Any ideas? I am using the following versions:

$ clang --version
clang version 10.0.0 (git@github.com:apple/llvm-project.git cf0195a2f45d22e5e4487152f78fc077e5100dae)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/fw/.swiftenv/versions/5.4.1-RELEASE/usr/bin
$ swift --version
Swift version 5.4.1 (swift-5.4.1-RELEASE)
Target: x86_64-unknown-linux-gnu
$ cmake --version
cmake version 3.20.3

That's odd, it looks like some swiftc is getting passed some flags that are meant for clang. If you got the error above after updating an existing checkout of the compiler, I'd recommend running build-script again with --reconfigure to see if that fixes it. If that doesn't help or you saw this after a clean build, it looks like it's only a build system test that's failing so you can probably use @LucianoPAlmeida 's workaround for a similar issue here to temporarily disable it.

1 Like

Yes, this was already a clean, reconfiguring build:

$ utils/build-script --release-debuginfo --skip-early-swift-driver --clean --reconfigure

I'll have a look at the workaround, thanks!

Terms of Service

Privacy Policy

Cookie Policy