Problem with clean Xcode builds on new stable branches?

I recently updated my checkout to pull all of the new stable branches, and then tried to do a clean build using ./utils/build-script --xcode --release-debuginfo --debug-swift --skip-build-benchmarks --clean. I've been running into issues where the build fails every time trying to link clang's diagtool. Has anyone run into something similar or have any advice on how to debug? It seems like some of the clang libs might be getting symlinked in the wrong places. It's kind of odd though because the corresponding ninja build (./utils/build-script --release-debuginfo --debug-swift --skip-build-benchmarks --clean) succeeds. I've pasted the relevant output below. Any help would be much appreciated!

Edit: I'm running the final released version of Xcode 11.0 which I believe is still supported.

=== BUILD TARGET diagtool OF PROJECT LLVM WITH CONFIGURATION RelWithDebInfo ===

Check dependencies

Ld /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/bin/diagtool normal x86_64
    cd /Users/owenvoorhees/Documents/Development/swift-source/llvm
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-macos10.9 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -L/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/bin -F/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/bin -filelist /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/tools/clang/tools/diagtool/LLVM.build/RelWithDebInfo/diagtool.build/Objects-normal/x86_64/diagtool.LinkFileList -Xlinker -rpath -Xlinker @loader_path/../lib -Xlinker -object_path_lto -Xlinker /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/tools/clang/tools/diagtool/LLVM.build/RelWithDebInfo/diagtool.build/Objects-normal/x86_64/diagtool_lto.o -Wl,-dead_strip -Wl,-search_paths_first -Wl,-headerpad_max_install_names /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMSupport.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangBasic.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangFrontend.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangDriver.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangParse.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMMCParser.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangSerialization.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangSema.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangAPINotes.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangEdit.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangAnalysis.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangASTMatchers.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangAST.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangLex.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangBasic.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMMC.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMDebugInfoCodeView.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMDebugInfoMSF.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMBitReader.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMOption.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMProfileData.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMCore.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMBinaryFormat.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMRemarks.a /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMSupport.a -lz -lcurses -lm /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libLLVMDemangle.a -Xlinker -dependency_info -Xlinker /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/tools/clang/tools/diagtool/LLVM.build/RelWithDebInfo/diagtool.build/Objects-normal/x86_64/diagtool_dependency_info.dat -o /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/bin/diagtool
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangBasic.a'
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangFrontend.a'
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangDriver.a'
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangParse.a'
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangSerialization.a'
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangSema.a'
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangAPINotes.a'
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangEdit.a'
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangAnalysis.a'
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangASTMatchers.a'
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangAST.a'
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangLex.a'
clang: error: no such file or directory: '/Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/lib/libclangBasic.a'

=== BUILD TARGET clangCrossTU OF PROJECT LLVM WITH CONFIGURATION RelWithDebInfo ===

Check dependencies

=== BUILD TARGET obj.clangRewrite OF PROJECT LLVM WITH CONFIGURATION RelWithDebInfo ===

Check dependencies

** BUILD FAILED **


The following build commands failed:
	Ld /Users/owenvoorhees/Documents/Development/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/RelWithDebInfo/bin/diagtool normal x86_64
(1 failure)
./utils/build-script: fatal error: command terminated with a non-zero exit status 65, aborting
2 Likes

I found that updating to the newest cmake fixed the issue. I am not sure why that was required though (it shouldn't be required: that such a thing would fix the problem is a bug).

1 Like

Thanks @Michael_Gottesman, it never occurred to me CMake might be the issue. I'm trying that now, if it works I'll file a bug.

(I just decided to update all of the things, it was just luck more than anything else).

For anyone following along, it seems like just updating cmake to 3.15.4 isn't enough to resolve this. I'm now getting the same error when linking SampleAnalyzerPlugin.dylib. Going to try and update to Catalina GM + Xcode 11.1 this afternoon, I'll update here If I get it working.

I was having issues with Xcode 11 GM as well, although it was when building LLVM (for some reason it wasn't building with C++14, but ninja build was fine). The CI is currently using Xcode 11 b6 so I installed that and the issue went away (unfortunately you can't download it now, but maybe it's been fixed in 11.1).

I got a chance to look into it today and it looks like a CMake bug uncovered by an LLVM change. I put up https://reviews.llvm.org/D68430 to tweak the Clang CMake code to be Xcode-friendly again and will pull that into stable shortly. Sorry for the trouble!

(5766e93db0eba14a9a11974bbc6864dd02ebaabc is the commit hash in the swift-clang repo for this, if you want to try reverting it directly. It doesn't quite revert cleanly, but that's just because one of the files it changes has since been deleted.)

4 Likes

It's no problem at all, thanks for fixing it so quickly! Ninja's been working fine in the meantime. I'm not a CMake expert by any means, but taking another look at the failed build log your assessment and fix LGTM.

Merged into Apple's stable branch in https://github.com/apple/swift-clang/pull/363. That should propagate to the regular stable branch tomorrow.

5 Likes

After applying the same fixes to my local branch and updating the cmake, I'm hitting a different error


Anybody else seeing this?

I think that one means you have too old an ld in your PATH. Which Xcode did you have xcode-select-ed when you first configured the CMake project? And do you have the Command Line Tools installed?

1 Like

@jrose Humm I don't remember, but I'm just re-cloning the project and reconfiguring it all, so the Xcode is the 11.1. Command line tools are installed and updated :))

@Douglas_Gregor ran into this one today too, so perhaps there's still a lingering issue.

I've tried a new clean build today with the latest version of ld installed, but no success yet :(( Don't know if that has some effect here but I updated cmake to lastest version 3.15.4. Thinking about revert an try to build with the cmake version I had previously installed, maybe could that work?

I got things working with 3.15.4 somehow so I’m not sure that’s it (might still be worth a try though). I did have trouble when using cmake compiled from latest source (which is what brew upgrade cmake does by default)

It’s a really horrible hack, but you might also try adding return() as the first line of https://github.com/apple/swift-clang/pull/363/files#diff-b721ba0c9dbfa1647ef806245cfde9b4 in your local swift-clang checkout. It’s definitely not the correct way to solve this and I hesitate to recommend it, but it may work as a temporary hack if you’re stuck(I had this patch applied while I was waiting for the fix to get cherry picked).

Thank's for the answer :) does installing cmake using brew is build from lastest source? I'm installing it using homebrew but the version it appears it is installed is 3.15.4. Maybe I should try install cmake from somewhere else?

If cmake —version shows 3.15.4 instead of a commit hash I think you should be ok. I ended up using an installer from cmake.org

I guess I'll check that to confirm and see if this can work, thank's @owenv :)

It didn't work, I'm still not able to build :((. @jrose, was @Douglas_Gregor able to make it work?

I don't think so. :-/ Most of us have a dual Xcode/Ninja setup anyway, since the Xcode project can't build the stdlib for the other Apple OSs. Hopefully one of us will find time to dig into the CMake some more today.

Terms of Service

Privacy Policy

Cookie Policy