# Swift Build Failure

**URL:** <https://forums.swift.org/t/swift-build-failure/63966>\
**Category:** Compiler\
**Tags:** build-script, help-needed, macos, buildin-the-compiler\
**Created:** [March 25, 2023, 6:28pm UTC](https://forums.swift.org/t/swift-build-failure/63966 "2023-03-25T18:28:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajveer100](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rajveer100/32/35168_2.png) [@Rajveer100](https://forums.swift.org/u/Rajveer100)\
**Post date:** [March 25, 2023, 6:28pm UTC](https://forums.swift.org/t/swift-build-failure/63966/1 "2023-03-25T18:28:15Z")

</div>

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:

```swift
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

```

---

<div class="post-metadata">

**Author:** ![Rajveer100](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rajveer100/32/35168_2.png) [@Rajveer100](https://forums.swift.org/u/Rajveer100)\
**Post date:** [March 26, 2023, 7:08am UTC](https://forums.swift.org/t/swift-build-failure/63966/2 "2023-03-26T07:08:14Z")

</div>

@LucianoPAlmeida @anthonylatsis

---

<div class="post-metadata">

**Author:** ![LucianoPAlmeida](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lucianopalmeida/32/2134_2.png) [@LucianoPAlmeida](https://forums.swift.org/u/LucianoPAlmeida)\
**Post date:** [March 26, 2023, 9:13am UTC](https://forums.swift.org/t/swift-build-failure/63966/3 "2023-03-26T09:13:36Z")

</div>

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](https://forums.swift.org/t/m2-macbook-pro-utils-build-script-results-in-error-looking-for-x86-64-file/63197)?  
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`

---

<div class="post-metadata">

**Author:** ![Rajveer100](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rajveer100/32/35168_2.png) [@Rajveer100](https://forums.swift.org/u/Rajveer100)\
**Post date:** [March 26, 2023, 9:44am UTC](https://forums.swift.org/t/swift-build-failure/63966/4 "2023-03-26T09:44:11Z")

</div>

> [@LucianoPAlmeida](#):
>
> 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?

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

> [@LucianoPAlmeida](#):
>
> Did this help [M2 MacBook Pro: utils/build-script results in error looking for x86\_64 File](https://forums.swift.org/t/m2-macbook-pro-utils-build-script-results-in-error-looking-for-x86-64-file/63197)?

Nope.

> [@LucianoPAlmeida](#):
>
> 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`

This didn't work.

---

<div class="post-metadata">

**Author:** ![LucianoPAlmeida](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lucianopalmeida/32/2134_2.png) [@LucianoPAlmeida](https://forums.swift.org/u/LucianoPAlmeida)\
**Post date:** [March 26, 2023, 2:05pm UTC](https://forums.swift.org/t/swift-build-failure/63966/5 "2023-03-26T14:05:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Rajveer100](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rajveer100/32/35168_2.png) [@Rajveer100](https://forums.swift.org/u/Rajveer100)\
**Post date:** [March 26, 2023, 5:38pm UTC](https://forums.swift.org/t/swift-build-failure/63966/6 "2023-03-26T17:38:40Z")

</div>

Hmm, let me figure out.

---

<div class="post-metadata">

**Author:** ![Rajveer100](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rajveer100/32/35168_2.png) [@Rajveer100](https://forums.swift.org/u/Rajveer100)\
**Post date:** [March 26, 2023, 7:36pm UTC](https://forums.swift.org/t/swift-build-failure/63966/7 "2023-03-26T19:36:33Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Rajveer100](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rajveer100/32/35168_2.png) [@Rajveer100](https://forums.swift.org/u/Rajveer100)\
**Post date:** [March 26, 2023, 7:43pm UTC](https://forums.swift.org/t/swift-build-failure/63966/8 "2023-03-26T19:43:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anthonylatsis](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/anthonylatsis/32/39232_2.png) [@anthonylatsis](https://forums.swift.org/u/anthonylatsis)\
**Post date:** [March 27, 2023, 9:48am UTC](https://forums.swift.org/t/swift-build-failure/63966/9 "2023-03-27T09:48:48Z")

</div>

> [@LucianoPAlmeida](#):
>
> Could it be that either your cmake or python binaries are ran in Roseta because they are not native arm binaries?

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.

---

<div class="post-metadata">

**Author:** ![LucianoPAlmeida](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lucianopalmeida/32/2134_2.png) [@LucianoPAlmeida](https://forums.swift.org/u/LucianoPAlmeida)\
**Post date:** [March 27, 2023, 10:23am UTC](https://forums.swift.org/t/swift-build-failure/63966/10 "2023-03-27T10:23:57Z")

</div>

> [@anthonylatsis](#):
>
> 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.

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 · swiftlang/llvm-project@09d4dbc · GitHub](https://github.com/apple/llvm-project/commit/09d4dbc3829e91397f96d7d7f243440555adee87) (although this one doesn't look related) could affect the swift build?
