Sourcekitd-test build error on ubuntu 14.04

Hi,

For a PR I need to do some changes to the build to exclude some functionality if we target ubuntu 14.04 (actually if ICU is too old).
To do this I have a 14.04 vm and try to build swift using these steps:
swift/utils/update-checkout --clone
swift/utils/update-checkout --scheme swift-4.2-branch
rm -rf build
swift/utils/build-script --xctest --foundation -R

This results in a link error:

[2/3] Linking CXX executable bin/sourcekitd-test
FAILED: : && /usr/bin/clang++  -Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wcovered-switch-default -Wdelete-non-virtual-dtor -Wstring-conversion -fcolor-diagnostics -fdata-sections -Werror=switch -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -O3  -target x86_64-unknown-linux-gnu -lpthread -latomic -ldl -fuse-ld=gold -L/home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64 -lBlocksRuntime tools/SourceKit/tools/sourcekitd-test/CMakeFiles/sourcekitd-test.dir/sourcekitd-test.cpp.o tools/SourceKit/tools/sourcekitd-test/CMakeFiles/sourcekitd-test.dir/TestOptions.cpp.o  -o bin/sourcekitd-test -L/home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/./lib -Wl,-rpath,/home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/./lib:/home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib:/home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src:/home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/linux/x86_64 lib/libsourcekitdInProc.so lib/libSourceKitSupport.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libclangRewrite.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libclangLex.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libclangBasic.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMCore.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMSupport.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMOption.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMCoverage.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMLTO.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src/libdispatch.so lib/swift/linux/x86_64/libswiftCore.so lib/libswiftBasic.a lib/libswiftDemangling.a /usr/lib/x86_64-linux-gnu/libuuid.so lib/libswiftSyntax.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/./lib/libclangBasic.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/./lib/libclangRewrite.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/libBlocksRuntime.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMObjCARCOpts.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMPasses.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMCodeGen.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMTarget.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMipo.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMBitWriter.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMLinker.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMScalarOpts.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMInstCombine.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMInstrumentation.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMVectorize.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMTransformUtils.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMAnalysis.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMObject.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMMCParser.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMMC.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMProfileData.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMIRReader.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMBitReader.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMAsmParser.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMCore.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMBinaryFormat.a /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMSupport.a -lz -lrt -ldl -ltinfo -lpthread -lm /home/h-anders/git-repos/swift/build/Ninja-ReleaseAssert/llvm-linux-x86_64/lib/libLLVMDemangle.a && :
/git-repos/swift/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src/libdispatch.so: undefined reference to `$Ss5RangeVss10StrideableRzs13SignedInteger6StrideRpzrlE8endIndexxvgSi_Tg5'
/git-repos/swift/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src/libdispatch.so: undefined reference to `$Ss27_allocateUninitializedArrayySayxG_BptBwlFSS_Tg5'
/git-repos/swift/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src/libdispatch.so: undefined reference to `$Ss5RangeVss10StrideableRzs13SignedInteger6StrideRpzrlE10startIndexxvgSi_Tg5'
/git-repos/swift/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src/libdispatch.so: undefined reference to `$Ss5RangeV15uncheckedBoundsAByxGx5lower_x5uppert_tcfCSi_Tg5'
/git-repos/swift/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src/libdispatch.so: undefined reference to `$SSS26stringInterpolationSegmentSSx_tcs23CustomStringConvertibleRzs20TextOutputStreamableRzlufCSS_Tg5'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
./swift/utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting

Does anyone have suggestions on what I'm doing wrong?

Thanks!

It's complaining about libdispatch... Have you tried adding --libdispatch to the build-script- invocation?

Thank's for your advice.

Eventually it turned out that my linking problems was because /usr/bin/ld is defaulting to ld.bfd.
After changing this to be ld.gold I can now build release and debug without problems using swift/utils/build-script --xctest --foundation -R

Oh well.. I tried =) Glad you've figured it out.

I'm a bit hesitant to bump up an old thread, but there's something about this that seems odd to me:

The original command has -fuse-ld=gold, but it failed. When ld was replaced with ld.gold, it worked. In the time since this has been posted, have you figured out why? Was some code getting linker via bfd and others getting linked via gold?

I ask because I've gotten the exact same error while building Swift inside a Flatpak.

I did not investigate it further as I only used 14.04 temporarily.
Please share if you find the cause.