# Building Swift compiler from source fails when not using Ninja

**URL:** <https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656>\
**Category:** Compiler\
**Tags:** xcode, build-script, help-needed\
**Created:** [January 16, 2022, 10:46pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656 "2022-01-16T22:46:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![philipturner](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@philipturner](https://forums.swift.org/u/philipturner)\
**Post date:** [January 16, 2022, 10:46pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/1 "2022-01-16T22:46:51Z")

</div>

I'm trying to build Swift from source using the guide at [GettingStarted.md](https://github.com/apple/swift/blob/main/docs/HowToGuides/GettingStarted.md). I downloaded all of the repositories and made my first invocation to build-script using the `--xcode` flag. There was a failure when running tests for CMark that halted compilation, and I found the cause.

The build products for CMark are located in the following folder:

```swift
/path/to/swift-project/build/Xcode-RelWithDebInfo/cmark-macosx-arm64/testdir/../src/RelWithDebInfo

```

But the Python scripts in the tests for CMark only check this directory, which omits the last path component ("RelWithDebInfo"):

```swift
/path/to/swift-project/build/Xcode-RelWithDebInfo/cmark-macosx-arm64/testdir/../src

```

I confirmed this was the cause by modifying one of the Python scripts called in the third test for CMark (`cmark.py`, line 47) to look for `["libcmark.dylib, RelWithDebInfo/libcmark.dylib"]` instead of just `["libcmark.dylib"]`. Subsequently, the third test and a few others succeeded, but some more were broken because they searched for a `cmark` file in the wrong directory (same situation as `libcmark.dylib`). I don't have the time or patience to hunt down where that error occurs in the Python code, and fixing the symptom instead of the problem is not a good idea.

I then tried building using Ninja instead of Xcode, and it worked just fine (it's compiling as I make this post). I'm worried because I'm going to make a lot of changes to the compiler's code as I debug it. I plan to overhaul autodiff and fix all the bugs breaking Swift for TensorFlow, which is an incredibly difficult task. If I can't use an IDE, I won't be as productive. Has anyone else had this build failure (is it something new or exclusive to Apple silicon?), or do you have suggestions for how I can work just as productively as if I were using Xcode?

Update: compiling with `--xcode` seems to work when I omit the `--test` flag.

---

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [January 17, 2022, 12:04am UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/2 "2022-01-17T00:04:26Z")

</div>

See also:

> [@Failing Tests while Compiling Swift on Xcode 12 with MacOS Big Sur Beta](https://forums.swift.org/t/failing-tests-while-compiling-swift-on-xcode-12-with-macos-big-sur-beta/40749/):
>
> I am trying to compile Swift for a while now. The compilation goes perfectly but some test case fails which results in the process to terminate with an exit status of 65. I am using Xcode 12 ( not beta ) and macOS Big Sur Beta. I am using this command to build the Swift compiler. utils/build-script --skip-build-benchmarks \ --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "x86\_64" --cmake-c-launcher="$(which sccache)" --cmake-cxx-launcher="$(which sccache)" --release-…

> <https://github.com/apple/swift/issues/56070>
>
> | | |
> |------------------|-----------------|…
> |Previous ID | SR-13635 |
> |Radar | None |
> |Original Reporter | pushpinderpalsingh (JIRA User) |
> |Type | Bug |
> 
> \<details\>
> \<summary\>Environment\</summary\>
> 
> master branch,
> 
> macOS Big Sur Beta,
> 
> Xcode 12
> 
> 
> \</details\>
> 
> \<details\>
> \<summary\>Additional Detail from JIRA\</summary\>
> 
> | | |
> |------------------|-----------------|
> |Votes | 2 |
> |Component/s | |
> |Labels | Bug |
> |Assignee | None |
> |Priority | Medium |
> 
>    
> 
> md5: e0f5c41f8df8d01a23a4aebd07ad1f5e
> 
> \</details\>
> 
> 
> 
> 
> \*\*relates to\*\*:  
> \* \[SR-14724\](https://bugs.swift.org/browse/SR-14724) --skip-test-cmark does not skip CTest  
> 
> 
> \*\*Issue Description:\*\*
> 
> 
> I am trying to compile Swift for a while now. The compilation goes perfectly but some test case fails which results in the process to terminate with an exit status of 65.  
> I am using Xcode 12 ( not beta ) and macOS Big Sur Beta. I am using this command to build the Swift compiler.
> 
> \> {{utils/build-script --skip-build-benchmarks }}  
> \> --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "x86\_64"  
> \> --cmake-c-launcher="$(which sccache)" --cmake-cxx-launcher="(which sccache)"  
> \> --release-debuginfo --test  
> \> --xcode
> 
> And getting the following output (I am just adding the failing test cases)
> 
> \> === BUILD AGGREGATE TARGET RUN\_TESTS OF PROJECT cmark WITH CONFIGURATION RelWithDebInfo ===
> \>
> \> Check dependencies
> \>
> \> PhaseScriptExecution CMake\\\\ PostBuild\\\\ Rules /Volumes/ExtremeSSD/swift-project/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86\_64/cmark.build/RelWithDebInfo/RUN\_TESTS.build/Script-209180F299BC48E5B78D44FC.sh  
> \> cd /Volumes/ExtremeSSD/swift-project/cmark  
> \> /bin/sh -c /Volumes/ExtremeSSD/swift-project/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86\_64/cmark.build/RelWithDebInfo/RUN\_TESTS.build/Script-209180F299BC48E5B78D44FC.sh  
> \> /usr/local/Cellar/cmake/3.18.3/bin/ctest --force-new-ctest-process -C RelWithDebInfo  
> \> Test project /Volumes/ExtremeSSD/swift-project/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86\_64  
> \> Start 1: api\_test  
> \> 1/9 Test #&#8203;1: api\_test ......................... Passed 0.02 sec  
> \> Start 2: html\_normalization  
> \> 2/9 Test #&#8203;2: html\_normalization ............... Passed 0.94 sec  
> \> Start 3: spectest\_library  
> \> 3/9 Test #&#8203;3: spectest\_library .................\\\*\\\*\\\*Failed 0.11 sec  
> \> Start 4: pathological\_tests\_library  
> \> 4/9 Test #&#8203;4: pathological\_tests\_library .......\\\*\\\*\\\*Failed 0.09 sec  
> \> Start 5: roundtriptest\_library  
> \> 5/9 Test #&#8203;5: roundtriptest\_library ............\\\*\\\*\\\*Failed 0.08 sec  
> \> Start 6: entity\_library  
> \> 6/9 Test #&#8203;6: entity\_library ...................\\\*\\\*\\\*Failed 0.06 sec  
> \> Start 7: spectest\_executable  
> \> 7/9 Test #&#8203;7: spectest\_executable ..............\\\*\\\*\\\*Failed 0.08 sec  
> \> Start 8: smartpuncttest\_executable  
> \> 8/9 Test #&#8203;8: smartpuncttest\_executable ........\\\*\\\*\\\*Failed 0.07 sec  
> \> Start 9: regressiontest\_executable  
> \> 9/9 Test #&#8203;9: regressiontest\_executable ........\\\*\\\*\\\*Failed 0.07 sec
> \>
> \> 22% tests passed, 7 tests failed out of 9
> \>
> \> Total Test time (real) = 1.53 sec
> \>
> \> The following tests FAILED:  
> \> 3 - spectest\_library (Failed)  
> \> 4 - pathological\_tests\_library (Failed)  
> \> 5 - roundtriptest\_library (Failed)  
> \> 6 - entity\_library (Failed)  
> \> 7 - spectest\_executable (Failed)  
> \> 8 - smartpuncttest\_executable (Failed)  
> \> 9 - regressiontest\_executable (Failed)  
> \> Errors while running CTest  
> \> make: \\\*\\\*\\\* \\\[RUN\_TESTS\_buildpart\_0\\\] Error 8  
> \> Command /bin/sh failed with exit code 2
> \>
> \> === BUILD AGGREGATE TARGET ZERO\_CHECK OF PROJECT cmark WITH CONFIGURATION RelWithDebInfo ===
> \>
> \> Check dependencies
> \>
> \> PhaseScriptExecution CMake\\\\ Rules /Volumes/ExtremeSSD/swift-project/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86\_64/cmark.build/RelWithDebInfo/ZERO\_CHECK.build/Script-8A9EE83BA8FD420BB7903C9C.sh  
> \> cd /Volumes/ExtremeSSD/swift-project/cmark  
> \> /bin/sh -c /Volumes/ExtremeSSD/swift-project/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86\_64/cmark.build/RelWithDebInfo/ZERO\_CHECK.build/Script-8A9EE83BA8FD420BB7903C9C.sh  
> \> echo ""
> \>
> \> make -f /Volumes/ExtremeSSD/swift-project/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86\_64/CMakeScripts/ReRunCMake.make  
> \> make\\\[1\\\]: \\\`/Volumes/ExtremeSSD/swift-project/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86\_64/CMakeFiles/cmake.check\_cache' is up to date.
> \>
> \> - - BUILD FAILED \\\*\\\*
> \>
> \> The following build commands failed:  
> \> PhaseScriptExecution CMake\\\\ PostBuild\\\\ Rules /Volumes/ExtremeSSD/swift-project/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86\_64/cmark.build/RelWithDebInfo/RUN\_TESTS.build/Script-209180F299BC48E5B78D44FC.sh  
> \> (1 failure)  
> \> ERROR: command terminated with a non-zero exit status 65, aborting
> 
> Additional configuration information (utils/update-checkout --dump-hashes):
> 
> \> {
> \>
> \> "https-clone-pattern": "https://github.com/%s.git", 
> \>
> \> "ssh-clone-pattern": "git@github.com:%s.git", 
> \>
> \> "repos": {
> \>
> \> "sourcekit-lsp": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/sourcekit-lsp"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "indexstore-db": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/indexstore-db"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "llbuild": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-llbuild"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swift-xcode-playground-support": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-xcode-playground-support"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swift-syntax": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-syntax"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swift-corelibs-xctest": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-corelibs-xctest"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swiftpm": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-package-manager"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swift-tools-support-core": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-tools-support-core"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "cmake": {
> \>
> \> "platforms": \\\[
> \>
> \> "Linux"
> \>
> \> \\\], 
> \>
> \> "remote": {
> \>
> \> "id": "KitWare/CMake"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swift-driver": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-driver"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "yams": {
> \>
> \> "remote": {
> \>
> \> "id": "jpsim/Yams"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "icu": {
> \>
> \> "platforms": \\\[
> \>
> \> "Linux"
> \>
> \> \\\], 
> \>
> \> "remote": {
> \>
> \> "id": "unicode-org/icu"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swift-corelibs-foundation": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-corelibs-foundation"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "llvm-project": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/llvm-project"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swift-argument-parser": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-argument-parser"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "ninja": {
> \>
> \> "remote": {
> \>
> \> "id": "ninja-build/ninja"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swift-integration-tests": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-integration-tests"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swift": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swift-stress-tester": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-stress-tester"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "cmark": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-cmark"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swift-format": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-format"
> \>
> \> }
> \>
> \> }, 
> \>
> \> "swift-corelibs-libdispatch": {
> \>
> \> "remote": {
> \>
> \> "id": "apple/swift-corelibs-libdispatch"
> \>
> \> }
> \>
> \> }
> \>
> \> }, 
> \>
> \> "branch-schemes": {
> \>
> \> "repro": {
> \>
> \> "repos": {
> \>
> \> "sourcekit-lsp": "241744da9ba73ab9951e7fb70a75e04779642302", 
> \>
> \> "swift-syntax": "94fc5ae3f34fac87380756b9c17ea7c6752a227b", 
> \>
> \> "llbuild": "3f236e84ebf77fbc4a1c6a41500ffa6b6709180a", 
> \>
> \> "swift-xcode-playground-support": "88043d7d320f92598efb39408c3f4b1903a4fff6", 
> \>
> \> "indexstore-db": "b7cc40f64a72ce1368b9b2f7bcfa9d9950698e0b", 
> \>
> \> "swift-corelibs-xctest": "d728b6456d453be212038bd8fe01ceebf5b7ce4f", 
> \>
> \> "swiftpm": "726eff2c35fc3620bc0afde6befecc9b0246b0b5", 
> \>
> \> "swift-tools-support-core": "cf5db868eeed2f41ddf1d7ac9b202b5738d67dc1", 
> \>
> \> "cmake": "skip", 
> \>
> \> "swift-driver": "5a7b75cac10aeee72f89cb965754167739dcd497", 
> \>
> \> "yams": "81a65c4069c28011ee432f2858ba0de49b086677", 
> \>
> \> "icu": "skip", 
> \>
> \> "swift-corelibs-foundation": "e9d8347e64ece3de453d617887af7229f73358d8", 
> \>
> \> "llvm-project": "40349c774225a0989b6a70bd16122b7d486c1dfb", 
> \>
> \> "swift-argument-parser": "15351c1cd009eba0b6e438bfef55ea9847a8dc4a", 
> \>
> \> "ninja": "a1f879b29c9aafe6a2bc0ba885701f8f4f19f772", 
> \>
> \> "swift-integration-tests": "3ceb61d33ea8885938eace0add830d143a3059cd", 
> \>
> \> "swift": "44c8052bb53108464a43ac8d8f3297e487439d7d", 
> \>
> \> "swift-stress-tester": "4d8f8a790d32a3ced310c6b68c46ca8e6f71f52c", 
> \>
> \> "cmark": "9c8096a23f44794bde297452d87c455fc4f76d42", 
> \>
> \> "swift-format": "d4bba6e22891ff1813e8267e36f2b00307684366", 
> \>
> \> "swift-corelibs-libdispatch": "f13ea5dcc055e5d2d7c02e90d8c9907ca9dc72e1"
> \>
> \> }, 
> \>
> \> "aliases": \\\[
> \>
> \> "repro"
> \>
> \> \\\]
> \>
> \> }
> \>
> \> }
> \>
> \> }\*\*%\*\*

> [@CPPLib\_log error when building with Xcode](https://forums.swift.org/t/cpplib-log-error-when-building-with-xcode/49550/):
>
> I'm trying to build Swift with Xcode following the [Getting Started Guide](https://github.com/apple/swift/blob/main/docs/HowToGuides/GettingStarted.md). I'm running the following command: utils/build-script --verbose-build --skip-build-benchmarks \ --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \--sccache --release-debuginfo --swift-disable-dead-stripping --test \ --xcode --skip-test-cmark The error I get is the following: User/swift-project/swift/validation-test/BuildSystem/swift-cmake/Klass.swift:14:5: error: cannot find 'CPPLi…

Note the following from that last thread:

> [@CPPLib\_log error when building with Xcode](https://forums.swift.org/t/cpplib-log-error-when-building-with-xcode/49550/18):
>
> The Xcode generator has many issues and isn't the normal build people use (we generally use ninja).

---

<div class="post-metadata">

**Author:** ![philipturner](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@philipturner](https://forums.swift.org/u/philipturner)\
**Post date:** [January 17, 2022, 12:11am UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/3 "2022-01-17T00:11:26Z")

</div>

Thanks. The Xcode build without tests just succeeded, but the way.

SR-13635 is exactly the set of tests that failed for me.

---

<div class="post-metadata">

**Author:** ![philipturner](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@philipturner](https://forums.swift.org/u/philipturner)\
**Post date:** [January 17, 2022, 12:22am UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/4 "2022-01-17T00:22:06Z")

</div>

Now I'm getting the following error when I press `Cmd + B` with the Xcode project open:

```swift
clang-13: error: no such file or directory: '/Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/llvm-macosx-arm64/Debug/lib/libLLVMSupport.a'
clang-13: error: no such file or directory: '/Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/llvm-macosx-arm64/Debug/lib/libLLVMDemangle.a'
Command Ld failed with a nonzero exit code

```

> **Full log**
>
> Ld /Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-arm64/Debug/bin/swift-serialize-diagnostics normal (in target 'swift-serialize-diagnostics' from project 'Swift')  
> cd /Users/philipturner/Documents/Swift-Compiler/swift-project/swift  
> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-01-09-a.xctoolchain/usr/bin/clang++ -target arm64-apple-macos12.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -L/Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-arm64/Debug/bin -L/Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/llvm-macosx-arm64/RelWithDebInfo/lib/Debug -L/Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/llvm-macosx-arm64/RelWithDebInfo/lib -F/Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-arm64/Debug/bin -filelist /Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-arm64/tools/swift-serialize-diagnostics/Swift.build/Debug/swift-serialize-diagnostics.build/Objects-normal/arm64/swift-serialize-diagnostics.LinkFileList -Xlinker -object\_path\_lto -Xlinker /Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-arm64/tools/swift-serialize-diagnostics/Swift.build/Debug/swift-serialize-diagnostics.build/Objects-normal/arm64/swift-serialize-diagnostics\_lto.o -stdlib=libc++ -target arm64-apple-macosx10.9 -Xlinker /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/lib/libz.tbd -Xlinker /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/lib/libcurses.tbd -Xlinker /Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/llvm-macosx-arm64/Debug/lib/libLLVMDemangle.a -Wl,-search\_paths\_first -Wl,-headerpad\_max\_install\_names /Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-arm64/Debug/lib/libswiftLocalization.a /Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/llvm-macosx-arm64/Debug/lib/libLLVMSupport.a -lm /Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/llvm-macosx-arm64/Debug/lib/libLLVMDemangle.a -Xlinker -no\_adhoc\_codesign -Xlinker -dependency\_info -Xlinker /Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-arm64/tools/swift-serialize-diagnostics/Swift.build/Debug/swift-serialize-diagnostics.build/Objects-normal/arm64/swift-serialize-diagnostics\_dependency\_info.dat -o /Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-RelWithDebInfoAssert/swift-macosx-arm64/Debug/bin/swift-serialize-diagnostics

Any ideas how to fix this? Should I edit with Xcode but still compile with Ninja from command line? The error happens when I try each of the recommended schemes in GettingStarted.md.

---

<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:** [January 18, 2022, 12:36am UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/5 "2022-01-18T00:36:20Z")

</div>

Not entirely sure, but I think that is a problem with LLVM paths when building llvm in a different mode than swift (in this case llvm RelWithDebugInfo and swift in Debug) note that you are building with ` --release-debuginfo` so llvm libraries will probably be at `RelWithDebugInfo` directory but error is that it doesn't find them in the `Debug` directory(which is swift build mode). You probably find those libraries in the `RelWithDebugInfo` folder.

A work around you may be able to do it to build all in debug mode if the goal is only to build, this 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` should work.

---

<div class="post-metadata">

**Author:** ![philipturner](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@philipturner](https://forums.swift.org/u/philipturner)\
**Post date:** [January 18, 2022, 12:19pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/6 "2022-01-18T12:19:03Z")

</div>

That seems to be the problem! All the executables I need are in the `RelWithDebugInfo/lib` directory instead of the `Debug` directory, which doesn't even have a `lib` folder. I'll test your command soon.

---

<div class="post-metadata">

**Author:** ![philipturner](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@philipturner](https://forums.swift.org/u/philipturner)\
**Post date:** [January 18, 2022, 1:15pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/7 "2022-01-18T13:15:26Z")

</div>

Now I got this problem, where the build tried to reference the `lib/Debug` folder instead of the plain `Debug` folder:

```swift
clang: error: no such file or directory: '/Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-DebugAssert/swift-macosx-arm64/lib/Debug/libswiftCompilerModules-bootstrapping1.a'
Command Ld failed with a nonzero exit code

```

I opened up the Xcode project and pressed `Cmd + B`. It seems to have encountered that error just as a warning and continued with the build, so hopefully it will work!

Update: the same error happened later on in the build. I just wasted 30% of my MBP's battery on that build when it already started at 80%, and I have a full day ahead!

```swift
clang-13: error: no such file or directory: '/Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-DebugAssert/swift-macosx-arm64/lib/Debug/libswiftCompilerModules-bootstrapping1.a'

```

---

<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:** [January 19, 2022, 12:41am UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/8 "2022-01-19T00:41:21Z")

</div>

This is an issue that should be fixed by now, see [[SR-15705] Compiler build failed (PhaseScriptExecution CMake PostBuild\ Rules) · Issue #57984 · apple/swift · GitHub](https://bugs.swift.org/browse/SR-15705) for more info. I would suggest to try pass `--bootstrapping=off`

---

<div class="post-metadata">

**Author:** ![ksluder](https://avatars.discourse-cdn.com/v4/letter/k/eada6e/32.png) [@ksluder](https://forums.swift.org/u/ksluder)\
**Post date:** [January 19, 2022, 3:38pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/9 "2022-01-19T15:38:43Z")

</div>

I don’t follow… if it’s fixed, then why is it necessary to pass `--bootstrapping=off`?

---

<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:** [January 19, 2022, 8:40pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/10 "2022-01-19T20:40:36Z")

</div>

Bootstrapping was `off` by default in Xcode build because it was not supported so it would never try bootstrapping when `--xcode` and it should build just fine. [Fix printing Xcode version from CMake when building with Xcode by cbjeukendrup · Pull Request #40870 · apple/swift · GitHub](https://github.com/apple/swift/pull/40870) enabled bootstrapping for Xcode, but by the error message something may not be working as expected since it failing. So what I'm simply suggesting is that if the goal is build the compiler with `--xcode` enforce `--bootstrapping=off` should do it as a workaround at least util we figure out the cause of the bootstrapping issue.

Best Regards,  
Luciano

---

<div class="post-metadata">

**Author:** ![philipturner](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@philipturner](https://forums.swift.org/u/philipturner)\
**Post date:** [January 19, 2022, 10:01pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/11 "2022-01-19T22:01:11Z")

</div>

It's still failing. From the command line, I tried this:

```swift
./swift/utils/build-script --xcode --debug --skip-build-benchmarks --swift-darwin-supported-archs "$(uname -m)" --sccache --skip-ios --skip-tvos --skip-watchos --bootstrapping=off

```

And ended up with this:

```swift
clang: error: no such file or directory: '/Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-DebugAssert/swift-macosx-arm64/lib/Debug/libswiftCompilerModules-bootstrapping1.a'
Command Ld failed with a nonzero exit code

**BUILD FAILED**

The following build commands failed:
	Ld /Users/philipturner/Documents/Swift-Compiler/swift-project/build/Xcode-DebugAssert/swift-macosx-arm64/bootstrapping1/Debug/bin/swift-frontend normal (in target 'swift-frontend-bootstrapping1' from project 'Swift')
(1 failure)
ERROR: command terminated with a non-zero exit status 65, aborting

```

Did I do anything wrong? Or do you have the capacity to test it out yourself and reproduce my error?

---

<div class="post-metadata">

**Author:** ![ksluder](https://avatars.discourse-cdn.com/v4/letter/k/eada6e/32.png) [@ksluder](https://forums.swift.org/u/ksluder)\
**Post date:** [January 19, 2022, 10:25pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/12 "2022-01-19T22:25:16Z")

</div>

I successfully built with `--bootstrapping=off` this morning. I did have to nuke my `build` directory first.

---

<div class="post-metadata">

**Author:** ![philipturner](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@philipturner](https://forums.swift.org/u/philipturner)\
**Post date:** [January 19, 2022, 10:28pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/13 "2022-01-19T22:28:16Z")

</div>

I'll try doing that. In the meantime, what machine specifications (platform, CPU architecture) were you using?

---

<div class="post-metadata">

**Author:** ![ksluder](https://avatars.discourse-cdn.com/v4/letter/k/eada6e/32.png) [@ksluder](https://forums.swift.org/u/ksluder)\
**Post date:** [January 19, 2022, 10:28pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/14 "2022-01-19T22:28:40Z")

</div>

M1 Mac mini, building for arm64.

---

<div class="post-metadata">

**Author:** ![philipturner](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@philipturner](https://forums.swift.org/u/philipturner)\
**Post date:** [January 19, 2022, 10:29pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/15 "2022-01-19T22:29:29Z")

</div>

I have M1 Max Macbook Pro. You only had to nuke the sub-folder for Xcode-DebugAssert right? I'm free to keep the others like Xcode-RelWithDebInfoAssert?

---

<div class="post-metadata">

**Author:** ![ksluder](https://avatars.discourse-cdn.com/v4/letter/k/eada6e/32.png) [@ksluder](https://forums.swift.org/u/ksluder)\
**Post date:** [January 19, 2022, 10:30pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/16 "2022-01-19T22:30:22Z")

</div>

I deleted the entire build directory. I don’t know if there’s a more limited subset you can delete.

---

<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:** [January 19, 2022, 10:52pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/17 "2022-01-19T22:52:18Z")

</div>

Before deleting all there are a couple of options to try first because delete all will make you need to rebuild everything again: So you can try using `--reconfigure` to force cmake to re-generate everything or delete only `swift-macosx-arm64` because llvm, cmark and driver probably don't need rebuilding =]

---

<div class="post-metadata">

**Author:** ![philipturner](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@philipturner](https://forums.swift.org/u/philipturner)\
**Post date:** [January 19, 2022, 10:53pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/18 "2022-01-19T22:53:21Z")

</div>

Already deleted the Xcode-DebugAssert, although I just moved the other two (Xcode release, Ninja release) out of the directory. Xcode-DebugAssert is in the trash, so I could retain it. At this point, I'd rather not mess with the build.

---

<div class="post-metadata">

**Author:** ![philipturner](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@philipturner](https://forums.swift.org/u/philipturner)\
**Post date:** [January 19, 2022, 11:28pm UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/19 "2022-01-19T23:28:46Z")

</div>

It built successfully both from the command line and in Xcode!

---

<div class="post-metadata">

**Author:** ![peter1234](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@peter1234](https://forums.swift.org/u/peter1234)\
**Post date:** [October 31, 2023, 7:54am UTC](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656/20 "2023-10-31T07:54:30Z")

</div>

Hello, what is your compiler instruction @philipturner

[Next page](https://forums.swift.org/t/building-swift-compiler-from-source-fails-when-not-using-ninja/54656.md?page=2)
