Swift Build Failure

Hey Everyone!

I am facing issues with the initial build (i.e. utils/build-script --skip-build-benchmarks \ --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \ --sccache --release-debuginfo --swift-disable-dead-stripping
after few recent pulls and have never faced such issue during my workflow.

I have tried out several ways to fixit, researched a lot to find any issues on my side, and after all this, to make my work a little easier I deleted the entire swift-project folder, starting everything from the beginning, i.e. re-cloning, resetting entire workspace, thinking it should probably fix the error in case there was an issue on my end, but it still throws the same error.

For more clarity, following is the error message:

CMake Error at /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:960 (add_executable):
  Error evaluating generator expression:

    $<TARGET_OBJECTS:swiftRuntime-macosx-x86_64>

  Objects of target "swiftRuntime-macosx-x86_64" referenced but no such
  target exists.
Call Stack (most recent call first):
  /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:1576 (add_llvm_executable)
  cmake/modules/AddSwiftUnittests.cmake:11 (add_unittest)
  unittests/runtime/CMakeLists.txt:103 (add_swift_unittest)


CMake Error at /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:960 (add_executable):
  Error evaluating generator expression:

    $<TARGET_OBJECTS:swiftRuntime-macosx-x86_64>

  Objects of target "swiftRuntime-macosx-x86_64" referenced but no such
  target exists.
Call Stack (most recent call first):
  /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:1576 (add_llvm_executable)
  cmake/modules/AddSwiftUnittests.cmake:11 (add_unittest)
  unittests/runtime/LongTests/CMakeLists.txt:37 (add_swift_unittest)


CMake Error at /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:960 (add_executable):
  Error evaluating generator expression:

    $<TARGET_OBJECTS:swiftRuntime-macosx-x86_64>

  Objects of target "swiftRuntime-macosx-x86_64" referenced but no such
  target exists.
Call Stack (most recent call first):
  /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:1576 (add_llvm_executable)
  cmake/modules/AddSwiftUnittests.cmake:11 (add_unittest)
  unittests/runtime/CMakeLists.txt:103 (add_swift_unittest)


CMake Error at /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:960 (add_executable):
  Error evaluating generator expression:

    $<TARGET_OBJECTS:swiftRuntime-macosx-x86_64>

  Objects of target "swiftRuntime-macosx-x86_64" referenced but no such
  target exists.
Call Stack (most recent call first):
  /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:1576 (add_llvm_executable)
  cmake/modules/AddSwiftUnittests.cmake:11 (add_unittest)
  unittests/runtime/LongTests/CMakeLists.txt:37 (add_swift_unittest)


CMake Error at /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:960 (add_executable):
  Error evaluating generator expression:

    $<TARGET_OBJECTS:swiftRuntime-macosx-x86_64>

  Objects of target "swiftRuntime-macosx-x86_64" referenced but no such
  target exists.
Call Stack (most recent call first):
  /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:1576 (add_llvm_executable)
  cmake/modules/AddSwiftUnittests.cmake:11 (add_unittest)
  unittests/runtime/CMakeLists.txt:103 (add_swift_unittest)


CMake Error at /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:960 (add_executable):
  Error evaluating generator expression:

    $<TARGET_OBJECTS:swiftRuntime-macosx-x86_64>

  Objects of target "swiftRuntime-macosx-x86_64" referenced but no such
  target exists.
Call Stack (most recent call first):
  /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:1576 (add_llvm_executable)
  cmake/modules/AddSwiftUnittests.cmake:11 (add_unittest)
  unittests/runtime/LongTests/CMakeLists.txt:37 (add_swift_unittest)


CMake Error at /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:960 (add_executable):
  No SOURCES given to target: SwiftRuntimeTests
Call Stack (most recent call first):
  /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:1576 (add_llvm_executable)
  cmake/modules/AddSwiftUnittests.cmake:11 (add_unittest)
  unittests/runtime/CMakeLists.txt:103 (add_swift_unittest)


CMake Error at /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:960 (add_executable):
  No SOURCES given to target: SwiftRuntimeLongTests
Call Stack (most recent call first):
  /Users/rajveersingh/Desktop/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/lib/cmake/llvm/AddLLVM.cmake:1576 (add_llvm_executable)
  cmake/modules/AddSwiftUnittests.cmake:11 (add_unittest)
  unittests/runtime/LongTests/CMakeLists.txt:37 (add_swift_unittest)


CMake Generate step failed.  Build files cannot be regenerated correctly.
ERROR: command terminated with a non-zero exit status 1, aborting

@LucianoPAlmeida @anthonylatsis

Are you on an Intel Mac or arm?
What does "uname -m" returns when you run on your temirnal?
What version of Cmake you have?

Did this help M2 MacBook Pro: utils/build-script results in error looking for x86_64 File?
Also to unblock you, if you really don't those targets you can try --skip-test-swift.
Alternatively we've seen a few random issues with bootstrapping so sometimes is worth try --bootstrapping=off

I have an ARM64 Mac, i.e., MacBook Pro with M1 Pro chip.
cmake version 3.26.1

Nope.

This didn't work.

It seems that it is trying to build the runtime for x86_64 although "uname -m" is probably returning arm64. Right? Could it be that either your cmake or python binaries are ran in Roseta because they are not native arm binaries? Note that I'm just guessing here, I don't know for sure what may be causing this issue.

2 Likes

Hmm, let me figure out.

FIXED!!!

Your suspect was correct, even I had some thoughts about brew going in my mind since a long time, grateful this error occurred, I updated my home-brew and fixed a lot of other things due to some old stuff...In simple words, just reinstalled brew, and it fixed everything, including placing it in the right folder, i.e., /opt.

Always a pleasure grinding and fixing stuff!

I remember contributing for the first time setting up my environment, and errors which lead to fixing the 'GettingStarted' readme file for setup, which was cool!

GG!

1 Like

PS: I realised one more thing, might me helpful for some people who are unaware, when you do a Mac transfer from Intel to ARM-64 (which I had done around 2 years back when I did a switch), that had the old intel-files like brew in this case, hence running probably under Rosetta, causing such errors, which actually didn't occur until now.

Hats off to you! I wonder why this only happened now though. Something about --swift-darwin-supported-archs or the way the target arch is chosen must have changed recently. According to the logs, the whole thing was being built for x86_64.

1 Like

That is a good question, the recent rebranch with llvm maybe? Swift has a certain dependency with llvm so is possible that something changed there in terms of how/which tools are used. For example, something like this [llvm-driver] Generate symlinks instead of executables for tools · apple/llvm-project@09d4dbc · GitHub (although this one doesn't look related) could affect the swift build?

1 Like