Problems with `build-script` building compiler with `--xcode`

Hi,
Trying to build the compiler with --xcode and seeing an error

CMake Error in libswift/CMakeLists.txt:
  The custom command generating

    /build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/bootstrapping1/libswift/Optimizer.o

  is attached to multiple targets:

    bootstrapping1-libswift-Optimizer.o
    libswift-bootstrapping1

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".


CMake Error in CMakeLists.txt:
  The custom command generating

    build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/bootstrapping1/libswift/Optimizer.o

  is attached to multiple targets:

    bootstrapping1-libswift-Optimizer.o
    libswift-bootstrapping1

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".


CMake Error in stdlib/CMakeLists.txt:
  The custom command generating

   /build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/bootstrapping1/libswift/Optimizer.o

  is attached to multiple targets:

    bootstrapping1-libswift-Optimizer.o
    libswift-bootstrapping1

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".

Here is the full command SKIP_XCODE_VERSION_CHECK=1 ./swift/utils/build-script --xcode --release-debuginfo --debug-swift --skip-build-benchmarks --swift-darwin-supported-archs "$(uname -m)" --sccache --skip-ios --skip-tvos --skip-watchos

I've seen some changes related to bootstrapping libswift like

There are any new flag that had to be added now e.g. --libswift=off? There are any new setup the have to be made?

Additionally, there are some issues with the Xcode build for a while (at least for me it's been a long time that I can't build the compiler with --xcode) so I wonder what most people use as setup instead of Xcode? I have seen some sharing that VSCode with a couple of plugins for c++ can be good enough for development, but I couldn't find it straightforward to setup.

Thanks in advance,
Best Regards,
Luciano

3 Likes

UPDATE: Using --libswift=off seems to make this error go away, but actually build still fails with a new one

xcodebuild: error: 'Swift.xcodeproj' does not exist.
ERROR: command terminated with a non-zero exit status 66, aborting

Still have to investigate that one

I'm having the same problem, and I saw the same results with --libswift=off. I see we're both using Apple Silicon. I wonder if this also presents on Intel (No longer have one to test)

I just remember that we have to use --reconfigure as well when trying to use --libswift=off, but issue is that we go back to another issue that I've seen couple weeks ago

clang: error: no such file or directory: '${REPO_DIR}/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-arm64/Debug/lib/libLLVMSupport.a'
clang: error: no such file or directory: '${REPO_DIR}/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-arm64/Debug/lib/libLLVMDemangle.a'
Command Ld failed with a nonzero exit code

** BUILD FAILED **


The following build commands failed:
	Ld /${REPO_DIR}/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/Debug/bin/swift-serialize-diagnostics normal (in target 'swift-serialize-diagnostics' from project 'Swift')
(1 failure)
ERROR: command terminated with a non-zero exit status 65, aborting

I'm not sure, but that one start happening after an llvm rebranch maybe related? Or coincidence? I'm not familiar enough with that. Have anyone else seen this?

What branch / commit are you trying to build?

Unfortunately, in my experience, trying to work on the compiler on an M1 is a world of pain [SR-14035] Compiler toolchain build error on M1 mac - Swift though untill recently a --xcode build worked but I cloned main this afternoon and even that is failing at the moment. Seems like there really needs to be an M1 host added to the CI setup.

I on main branch, always update checkout before trying to build for the a couple of weeks or so :)

What is the error you been seeing?
It's been like that for a couple of weeks, I found that the issue with LLVM libraries is related to the fact that I'm building with --release-debuginfo --debug-swift and because of that LLVM libraries are built in llvm-macosx-arm64/RelWithDebugInfo/lib/libLLVMSupport.a but as we can see on the error it tries to find it in the Swift configuration folder for some reason. For what I could understand swift/SwiftXcodeSupport.cmake at 7123d2614b5f222d03b3762cb110d27a9dd98e24 · apple/swift · GitHub is designed to fix this problem but apparently is not being applied for those libraries ... so I'm still not sure what is the issue here.

The purpose of the question was more to know if people are using some workaround, or they are not using Xcode at all and using ninja build with some editor like VSCode which I tried, but was not so trivial to configure :(

I'm seeing a problem very early on with testing cmark dependencies.

    /bin/sh -c /Volumes/Data2/swift-m1/build/Xcode-RelWithDebInfoAssert/cmark-macosx-arm64/cmark.build/RelWithDebInfo/RUN_TESTS.build/Script-003C8D08B0008F35F218E126.sh
Test project /Volumes/Data2/swift-m1/build/Xcode-RelWithDebInfoAssert/cmark-macosx-arm64
    Start 1: api_test
1/9 Test #1: api_test .........................   Passed    0.41 sec
    Start 2: html_normalization
2/9 Test #2: html_normalization ...............   Passed    0.11 sec
    Start 3: spectest_library
3/9 Test #3: spectest_library .................***Failed    0.04 sec
    Start 4: pathological_tests_library
4/9 Test #4: pathological_tests_library .......***Failed    0.03 sec
    Start 5: roundtriptest_library
5/9 Test #5: roundtriptest_library ............***Failed    0.04 sec
    Start 6: entity_library
6/9 Test #6: entity_library ...................***Failed    0.03 sec
    Start 7: spectest_executable
7/9 Test #7: spectest_executable ..............***Failed    0.04 sec
    Start 8: smartpuncttest_executable
8/9 Test #8: smartpuncttest_executable ........***Failed    0.03 sec
    Start 9: regressiontest_executable
9/9 Test #9: regressiontest_executable ........***Failed    0.03 sec

I remember I fixed this in the past by removing some lines in cmark/test/CMakeLists.txt but it was enough to put me off trying to go any further today.

Update: I've reapplied that fix now and it's getting further with --xcode. I'll let you know how it turns out.

1 Like

OK, it got as far as the error you mentioned in the OP which is probably something to do with the "swift-driver" changes I'd guess. --xcode used to work so I'd probably bisect back through the daily tags doing a utils/update-checkout --tag TAG until you find one that works from a month or so ago or perhaps work off a release branch. Once you have an Xcode project that builds you can download the toolchain for that date and swap in the binary Xcode builds for testing.

I was just able to build a Xcode build successfully as suspected with --debug (the whole command SKIP_XCODE_VERSION_CHECK=1 ./swift/utils/build-script --xcode --debug --skip-build-benchmarks --swift-darwin-supported-archs "$(uname -m)" --sccache --skip-ios --skip-tvos --skip-watchos --libswift=off)
Although I think it is an issue not be able to build with --release-debuginfo --debug-swift --debug works at a cost of some disk space and slower build time.

@mishal_shah Can I open an SR for that issue? Just asking before open because maybe this is already reported somewhere

Note that to build successfully, we need also to apply another workaround for unsupported flag: No Xcode builds on CI - #2 by LucianoPAlmeida

I've been rolling the source code repo back and forth in time today and have found that for me, using an M1 mini, tag swift-DEVELOPMENT-SNAPSHOT-2021-09-09-a builds but tag swift-DEVELOPMENT-SNAPSHOT-2021-09-18-a does not if that helps. This is for --release-debuginfo and without --test.
Xcode 13.1.

1 Like
Terms of Service

Privacy Policy

Cookie Policy