Error When Building the Swift Compiler for the First Time

I was trying to build the Swift compiler for the first time and encountered an error when doing so that I have no idea what to do about.

First thing I did to get setup developing the Swift compiler was make a fork on GitHub.

After that, I ran the following commands:

brew install cmake ninja
mkdir swift-source && cd swift-source
git clone https://github.com/Wildchild9/swift.git
cd swift
git remote add upstream https://github.com/apple/swift.git
cd ..
swift/utils/update-checkout --clone

All of that seemed to run successfully. After that, I attempted to build the Swift compiler with the following command.

swift/utils/build-script --xcode --debug

After letting it build for some time, it came to a halt, producing the following error:

** BUILD FAILED **


The following build commands failed:
	CompileC /Users/noahwilder/swift-source/build/Xcode-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl/Swift.build/Debug/sourcekitd-repl.build/Objects-normal/x86_64/sourcekitd-repl.o tools/SourceKit/tools/sourcekitd-repl/sourcekitd-repl.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
ERROR: command terminated with a non-zero exit status 65, aborting

I'm pretty sure I followed the right steps to setup and build the compiler as I was referencing a few different tutorials. The only things that I wasn't really sure about were:

Whether or not the current directory from which you run `build-script` and `update- checkout` matters as long as you specify the path to each of them.

I know this seems sort of stupid, but I wasn't totally sure if it made a difference whether I ran swift/utils/update-checkout and swift/utils/build-script --xcode --debug from the swift-source directory versus running the same commands without the swift/ prefix but from already inside the swift directory. My basic knowledge of the command line tells me that this probably doesn't matter but, because of my unfamiliarity with the Swift compiler, I did the former as I saw the full command with the prefix in more of the tutorials I found online.

The flags that I used when building the compiler.

After watching most of this super helpful video, I decided to use the build flags --xcode and --debug. I decided to use those flags because, from what I gathered, the first flag would allow me to make changes to the compiler through Xcode (I think I'd rather work with the compiler in an IDE rather than the command line because I'm more comfortable with that environment). Also, I used the --debug flag because, from what I gathered from the video I saw and the documentation I read, it seemed like this would build the entire compiler in debug mode rather than just individual aspects. I'm questioning the flags that I used because in many of the other tutorials I read, I saw the --release-debuginfo and --debug-swift flags used a lot. From what I gathered, I thought that these were building only select aspects of the compiler in debug mode, while --debug builds the entire compiler in debug mode. In the case that I am correct, do I really need the extra coverage offered by --debug versus --release-debuginfo or --release-debuginfo --debug-swift? What does debug offer that the other combination of flags don't? I do realize that building the compiler in the first place takes an incredibly long time and as such I would ideally like to reduce the build time as much as possible and only build necessary components in debug mode. What flags would you recommend I build with as a beginner?

Despite all the questioning I did in the two points above, I don't really think that any of the commands I ran were wrong per se. In any case, how can I go about figuring out what is causing the error or, better yet, fix the error that's being produced right off the bat?

Whether or not the current directory from which you run build-script and update- checkout matters as long as you specify the path to each of them.

No it shouldn't matter, I think. If you see a difference in behavior, please report it as a bug.

The flags that I used when building the compiler.

On the point of the --debug flag, IMO that's mostly a last resort (but the fact that you bring this up means that we should be clearer about documenting it). This will build everything in debug mode (LLVM, Clang, Swift) which will take up a lot of time to build (several hours depending on your hardware), disk space, and the resulting compiler will be very slow. The most common options I've seen people use are (in no particular order):

  • --release-debuginfo (no additional --debug)
  • --release-debuginfo --debug-swift (the debuginfo with --release-debuginfo is not good enough for your purposes and you're ok with a slower compiler)
  • --release-debuginfo --debug-swift-stdlib (if you're working on the stdlib and the debuginfo is not good enough)

I think --release-debuginfo usually strikes a good balance, but sometimes it doesn't; if it doesn't, I'll add --debug-swift. If you're just starting out and don't mind the additional disk space/up-front cost of compiling with debuginfo, --release-debuginfo --debug-swift is also a good choice.

I'm not entirely sure what's causing the Xcode error, could you share more details about the error message (or file a bug report on bugs.swift.org with the commit hash and link that here)? I remember seeing either a forum post or a JIRA about this recently, can't find it at the moment...

1 Like

Thank you for your explanations, I really appreciate it.

This morning, I deleted swift-source and started from the beginning with the --release-debuginfo and --debug-swift build flags only to have what I think is the same error again.

A couple other things that may be of note regarding my environment:

  • I have Xcode Version 11.4.1 (11E503a)
  • I am running macOS Catalina 10.15.4 (19E287)
  • Checking swift --version yields:
    Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)
    Target: x86_64-apple-darwin19.4.0
    
  • I know this doesn't matter but just for the sake of exhaustiveness, I am using iTerm2 (Build 3.3.9) instead of Terminal

Here is the end of the output produced leading up to the build failing:

=== BUILD TARGET sourcekitd-repl OF PROJECT Swift WITH CONFIGURATION Debug ===

Check dependencies

Write auxiliary files
/bin/mkdir -p /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl/Swift.build/Debug/sourcekitd-repl.build/Objects-normal/x86_64
write-file /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl/Swift.build/Debug/sourcekitd-repl.build/Objects-normal/x86_64/sourcekitd-repl.LinkFileList

CompileC /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl/Swift.build/Debug/sourcekitd-repl.build/Objects-normal/x86_64/sourcekitd-repl.o tools/SourceKit/tools/sourcekitd-repl/sourcekitd-repl.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/noahwilder/swift-source/swift
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -target x86_64-apple-macos10.15 -fmessage-length=202 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fcolor-diagnostics -std=c++14 -stdlib=libc++ -Wno-trigraphs -fno-exceptions -fno-rtti -fno-sanitize=vptr -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wdocumentation -Wnon-virtual-dtor -Woverloaded-virtual -Wno-exit-time-destructors -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wsign-compare -Wno-shorten-64-to-32 -Wnewline-eof -Wno-c++11-extensions -DCMAKE_INTDIR=\"Debug\" -DGTEST_HAS_RTTI=0 -DSWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DCMARK_STATIC_DEFINE -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/Debug/bin/include -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl -I/Users/noahwilder/swift-source/swift/tools/SourceKit/tools/sourcekitd-repl -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/include -I/Users/noahwilder/swift-source/swift/tools/SourceKit/include -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/include -I/Users/noahwilder/swift-source/swift/include -I/Users/noahwilder/swift-source/llvm-project/llvm/include -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/include -I/Users/noahwilder/swift-source/llvm-project/clang/include -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/tools/clang/include -I/Users/noahwilder/swift-source/cmark/src -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/cmark-macosx-x86_64/src -I/Users/noahwilder/swift-source/swift/tools/SourceKit/tools/sourcekitd/include -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl/Swift.build/Debug/sourcekitd-repl.build/DerivedSources-normal/x86_64 -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl/Swift.build/Debug/sourcekitd-repl.build/DerivedSources/x86_64 -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl/Swift.build/Debug/sourcekitd-repl.build/DerivedSources -F/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/Debug/bin -Wno-unknown-warning-option -Werror=unguarded-availability-new -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-class-memaccess -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Werror=switch -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -fno-exceptions -fno-rtti -Werror=gnu -target x86_64-apple-macosx10.9 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -arch x86_64 -F/../../../Developer/Library/Frameworks -mmacosx-version-min=10.9 -UNDEBUG -fblocks -std=c++14 -MMD -MT dependencies -MF /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl/Swift.build/Debug/sourcekitd-repl.build/Objects-normal/x86_64/sourcekitd-repl.d --serialize-diagnostics /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl/Swift.build/Debug/sourcekitd-repl.build/Objects-normal/x86_64/sourcekitd-repl.dia -c /Users/noahwilder/swift-source/swift/tools/SourceKit/tools/sourcekitd-repl/sourcekitd-repl.cpp -o /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl/Swift.build/Debug/sourcekitd-repl.build/Objects-normal/x86_64/sourcekitd-repl.o
In file included from /Users/noahwilder/swift-source/swift/tools/SourceKit/tools/sourcekitd-repl/sourcekitd-repl.cpp:15:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/ADT/Hashing.h:47:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/Support/DataTypes.h:16:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm-c/DataTypes.h:28:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:317:9: error: no member named 'signbit' in the global namespace
using ::signbit;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:318:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:319:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
      ~~^
In file included from /Users/noahwilder/swift-source/swift/tools/SourceKit/tools/sourcekitd-repl/sourcekitd-repl.cpp:15:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/ADT/Hashing.h:47:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/Support/DataTypes.h:16:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm-c/DataTypes.h:28:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:304:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/math.h:749:12: note: 'finite' declared here
extern int finite(double)
           ^
In file included from /Users/noahwilder/swift-source/swift/tools/SourceKit/tools/sourcekitd-repl/sourcekitd-repl.cpp:15:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/ADT/Hashing.h:47:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/Support/DataTypes.h:16:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm-c/DataTypes.h:28:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:320:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:9: error: no member named 'isnan' in the global namespace
using ::isnan;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:322:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:323:9: error: no member named 'isgreater' in the global namespace
using ::isgreater;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:324:9: error: no member named 'isgreaterequal' in the global namespace
using ::isgreaterequal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:325:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:326:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:327:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:328:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:329:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:335:9: error: no member named 'abs' in the global namespace; did you mean 'fabs'?
using ::abs;
      ~~^
In file included from /Users/noahwilder/swift-source/swift/tools/SourceKit/tools/sourcekitd-repl/sourcekitd-repl.cpp:15:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/ADT/Hashing.h:47:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/Support/DataTypes.h:16:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm-c/DataTypes.h:28:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:304:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/math.h:417:15: note: 'fabs' declared here
extern double fabs(double);
              ^
In file included from /Users/noahwilder/swift-source/swift/tools/SourceKit/tools/sourcekitd-repl/sourcekitd-repl.cpp:15:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/ADT/Hashing.h:47:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm/Support/DataTypes.h:16:
In file included from /Users/noahwilder/swift-source/llvm-project/llvm/include/llvm-c/DataTypes.h:28:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:640:26: error: no template named 'numeric_limits'
    bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
                         ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:640:60: error: no template named 'numeric_limits'
    bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
                                                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:641:18: error: no template named 'numeric_limits'
    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                 ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:641:50: error: no template named 'numeric_limits'
    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                                                 ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:646:17: error: no template named 'numeric_limits'
  static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

=== BUILD TARGET complete-test OF PROJECT Swift WITH CONFIGURATION Debug ===

Check dependencies

Write auxiliary files
/bin/mkdir -p /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/complete-test/Swift.build/Debug/complete-test.build/Objects-normal/x86_64
write-file /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/complete-test/Swift.build/Debug/complete-test.build/Objects-normal/x86_64/complete-test.LinkFileList

CompileC /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/complete-test/Swift.build/Debug/complete-test.build/Objects-normal/x86_64/complete-test.o tools/SourceKit/tools/complete-test/complete-test.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/noahwilder/swift-source/swift
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -target x86_64-apple-macos10.15 -fmessage-length=202 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fcolor-diagnostics -std=c++14 -stdlib=libc++ -Wno-trigraphs -fno-exceptions -fno-rtti -fno-sanitize=vptr -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wdocumentation -Wnon-virtual-dtor -Woverloaded-virtual -Wno-exit-time-destructors -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wsign-compare -Wno-shorten-64-to-32 -Wnewline-eof -Wno-c++11-extensions -DCMAKE_INTDIR=\"Debug\" -DGTEST_HAS_RTTI=0 -DSWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DCMARK_STATIC_DEFINE -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/Debug/bin/include -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/complete-test -I/Users/noahwilder/swift-source/swift/tools/SourceKit/tools/complete-test -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/include -I/Users/noahwilder/swift-source/swift/tools/SourceKit/include -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/include -I/Users/noahwilder/swift-source/swift/include -I/Users/noahwilder/swift-source/llvm-project/llvm/include -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/include -I/Users/noahwilder/swift-source/llvm-project/clang/include -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/llvm-macosx-x86_64/tools/clang/include -I/Users/noahwilder/swift-source/cmark/src -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/cmark-macosx-x86_64/src -I/Users/noahwilder/swift-source/swift/tools/SourceKit/tools/sourcekitd/include -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/complete-test/Swift.build/Debug/complete-test.build/DerivedSources-normal/x86_64 -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/complete-test/Swift.build/Debug/complete-test.build/DerivedSources/x86_64 -I/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/complete-test/Swift.build/Debug/complete-test.build/DerivedSources -F/Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/Debug/bin -Wno-unknown-warning-option -Werror=unguarded-availability-new -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-class-memaccess -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Werror=switch -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -fno-exceptions -fno-rtti -Werror=gnu -target x86_64-apple-macosx10.9 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -arch x86_64 -F/../../../Developer/Library/Frameworks -mmacosx-version-min=10.9 -UNDEBUG -fblocks -std=c++14 -MMD -MT dependencies -MF /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/complete-test/Swift.build/Debug/complete-test.build/Objects-normal/x86_64/complete-test.d --serialize-diagnostics /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/complete-test/Swift.build/Debug/complete-test.build/Objects-normal/x86_64/complete-test.dia -c /Users/noahwilder/swift-source/swift/tools/SourceKit/tools/complete-test/complete-test.cpp -o /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/complete-test/Swift.build/Debug/complete-test.build/Objects-normal/x86_64/complete-test.o

** BUILD FAILED **


The following build commands failed:
	CompileC /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl/Swift.build/Debug/sourcekitd-repl.build/Objects-normal/x86_64/sourcekitd-repl.o tools/SourceKit/tools/sourcekitd-repl/sourcekitd-repl.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
ERROR: command terminated with a non-zero exit status 65, aborting

After looking through the included output, build failing might have something to do with the prior BUILD TARGET sourcekitd-repl OF PROJECT Swift WITH CONFIGURATION Debug. I say this because it says that is is "stopping now" and that 20 errors were generated (even though I only counted 19):

fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Here are the 19 errors that I found before the fatal error was produced:
  1. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:317:9: error: no member named 'signbit' in the global namespace
    using ::signbit;
          ~~^
    
  2. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:318:9: error: no member named 'fpclassify' in the global namespace
    using ::fpclassify;
    ~~^
    
  3. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:319:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
    using ::isfinite;
    ~~^
    
  4. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:320:9: error: no member named 'isinf' in the global namespace
    using ::isinf;
          ~~^
    
  5. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:9: error: no member named 'isnan' in the global namespace
    using ::isnan;
          ~~^
    
  6. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:322:9: error: no member named 'isnormal' in the global namespace
    using ::isnormal;
          ~~^
    
  7. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:323:9: error: no member named 'isgreater' in the global namespace
    using ::isgreater;
          ~~^
    
  8. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:324:9: error: no member named 'isgreaterequal' in the global namespace
    using ::isgreaterequal;
          ~~^
    
  9. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:325:9: error: no member named 'isless' in the global namespace
    using ::isless;
          ~~^
    
  10. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:326:9: error: no member named 'islessequal' in the global namespace
    using ::islessequal;
          ~~^
    
  11. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:327:9: error: no member named 'islessgreater' in the global namespace
    using ::islessgreater;
          ~~^
    
  12. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:328:9: error: no member named 'isunordered' in the global namespace
    using ::isunordered;
          ~~^
    
  13. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:329:9: error: no member named 'isunordered' in the global namespace
    using ::isunordered;
          ~~^
    
  14. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:335:9: error: no member named 'abs' in the global namespace; did you mean 'fabs'?
    using ::abs;
          ~~^
    
  15. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:640:26: error: no template named 'numeric_limits'
        bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
                             ^
    
  16. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:640:60: error: no template named 'numeric_limits'
        bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
                                                               ^
    
  17. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:641:18: error: no template named 'numeric_limits'
        int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                     ^
    
  18. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:641:50: error: no template named 'numeric_limits'
        int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                                                     ^
    
  19. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:646:17: error: no template named 'numeric_limits'
      static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
                    ^
    

Again, I'm not really familiar with the compiler and as such am not sure if these errors caused the build to fail in the subsequent BUILD TARGET complete-test OF PROJECT Swift WITH CONFIGURATION Debug phase or if the prior phase errors are actually non-issue and irrelevant in this case.

** BUILD FAILED **


The following build commands failed:
	CompileC /Users/noahwilder/swift-source/build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/tools/SourceKit/tools/sourcekitd-repl/Swift.build/Debug/sourcekitd-repl.build/Objects-normal/x86_64/sourcekitd-repl.o tools/SourceKit/tools/sourcekitd-repl/sourcekitd-repl.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
ERROR: command terminated with a non-zero exit status 65, aborting

And as I said before it seems that this is the same error as that which was emitted initially with the only difference being the path which I assume is altered only because of the different build flags.

I think I'm going to browse around JIRA to see if I can find anything remotely similar and if not, I'll report it.

Also, if there is any other information that you would like on my end to help solve this, just let me know. Anyways, did the issue present itself here / do you know what is happening now by any chance? (not sure if this second post added any pertinent information to the error that wasn't present in the initial post).

On a separate note, if a build fails, when I go about building it again, does it write over the failed build? Up 'til now I have just deleted the entire thing and restarted because I'm not sure even though I know that is probably not necessary (just being safe). So I guess my question is, is there anything that I need to do to either get rid of the previous build or tell it to overwrite it in the subsequent build?

1 Like

Thanks for pasting the errors. Those definitely look familiar. Here's a slightly older thread with the same issue (thanks @dan-zheng for helping me find it!) : Is anyone else getting this error when building the compiler from `master` on macOS?

I'm going to try to see what we can do to fix the corresponding JIRA SR-12726. In the meantime, there is a workaround suggested of removing the CommandLineTools (I'd suggest moving it to a temporary directory instead of deleting in case something goes wrong :sweat_smile:).


This morning, I deleted swift-source and started from the beginning with the --release-debuginfo and --debug-swift build flags only to have what I think is the same error again.

That makes sense, since changing the flags affects the optimization/debuginfo settings, whereas the problem is more fundamental; it has something to do with headers/paths.

On a separate note, if a build fails, when I go about building it again, does it write over the failed build? Up 'til now I have just deleted the entire thing and restarted because I'm not sure even though I know that is probably not necessary (just being safe). So I guess my question is, is there anything that I need to do to either get rid of the previous build or tell it to overwrite it in the subsequent build?

There's several different things that could happen here:

  1. If you don't change the build settings, and don't use --reconfigure it will overwrite some things and not others (e.g. some configuration steps might not be re-run because the files haven't changed).
  2. If you don't change the build settings, but use --reconfigure it should I think overwrite everything (or maybe most of it), because the configuration steps will be re-run even if the underlying files haven't changed.
  3. If you change the build settings, like say using --release-debuginfo instead of --debug (but don't supply an explicit --build-dir), then it will create a fresh build directory (the build directory mangles the names of a bunch of flags). If you use the --build-dir flag, it will overwrite stuff. (This is particularly handy when bisecting issues.)

Since clean builds can take a long time, you might also want to check out how to setup caching, so in case you need to do a clean build again for some reason, most of it comes straight from the cache.

2 Likes

I posted the issue on Jira (SR-12807) linking to this post and SR-12726.

From (1) I gather that you are saying that it diffs the previous and current build and only changes what it needs to. If the build were to fail though, should I be using --reconfigure because part of the prior build is presumably failing, or should I trust it to overwrite what it needs to and assume that any errors that are subsequently produced are from the current build and not remnants of the previous one? More generally, in the case the build is failing, is re-running and overwriting everything (the previous build) necessary when try to fix the issue (I think this applies to both --build-dir and --reconfigure)? If I don't need it in this case, why/when would I want to use --reconfigure?

Let me see if I understand correctly. If, for example, I ran a build with the flags --xcode --debug that failed, and then wanted to change the build settings to let's say --release-debuginfo --debug-swift --xcode and try to build it again, adding --build-dir would overwrite the previous build and its corresponding directory (and not use a diff?) and replace it with the new build and directory.

From what I gathered also, I think that both --build-dir and --reconfigure only rewrite the previous directory, presumably without a diff and re-run everything, but the only difference between when they should be used is whether or not the build settings were changed between builds.

Also, if I'm correct thus far, when I try and run utils/build-script --release-debuginfo --debug-swift --xcode again after it having failed, I should just run the same command again and it will diff the two builds and only change what it needs to, and assuming the error was taken care of before the second build, I should be good.

Lastly, if let's say a build stops mid-way, running the same build again will more or less pick up where it left off I assume.

I'll definitely check that out, thanks! Also, I assume a "clean build" means deleting and re-running everything from the previous build and thus not using a diff, or is it just the next subsequent build that's performed?

Also, sorry for berating you with all of these seemingly straightforward questions, I really appreciate all of the explanations you have gave me and they are helping me actually get an understanding of what I'm doing!

--reconfigure is a bit hard to describe. :thinking: I too have a fuzzy understanding, but I'll try to explain what I know. For example, say you were working on master and maybe your local master got outdated by a week while you were hacking away on a particular branch. After you update your local master (using utils/update-checkout), you have a few options:

  • Wipe the build directory and do a clean build: Usually an option of last resort (because of time overhead), when I still get build errors after using --reconfigure (and I don't want to get blocked on the build error).
  • Build with the flags you were using earlier, but with an extra --reconfigure: This will make sure that any important CMake changes that were made since you updated. [IME using --reconfigure is faster than a clean build but I haven't measure it.]
  • Build normally (i.e. without the extra --reconfigure): Might work, might not work (you'll probably get some obscure build error) if you're unlucky, because the CMake configuration has been changed in a way that doesn't work with your old build. If this works, it will be the fastest option.

So there's a correctness vs risk/speed tradeoff here. This mostly applies to doing subsequent work, and isn't directly applicable when you're doing your first build (in hindsight, I should probably not have brought it up to avoid front-loading the complexity.)

IMO reusing the same directory with different flags is kinda' asking for trouble, so I don't know exactly what will happen. You might get a weird error, or perhaps it will overwrite things (because you reused the build directory using --build-dir) and it will "just work". I suspect it'll probably "just work" (and I think I tried it once and it did work, but I might be misremembering) but I would not bet money on that.

Usually, the build directory is named something like Xcode-RelWithDebInfoAssert (if you used --xcode --release-debuginfo). If you switch to say --xcode --debug --build-dir=/path/to/Xcode-RelWithDebInfoAssert, IMO that's very confusing, because now the directory name misrepresents the configuration. Instead, if you did a --xcode --release-debuginfo --reconfigure (say, because you updated your local master), that should mostly rebuild everything (I think), but it will do so in the same directory. (I say "mostly" because I'm fuzzy on the difference between clean build vs reconfigure -- maybe someone else who knows better can explain things here).

Yes, if you rerun it, it will try to do an incremental build. If the fix ("the error was taken care of" part) was part of the CMake configuration, this might lead to a configuration mismatch (and hence require a --reconfigure). If the fix was part of the C++ code, and the fix is correct, you should be good.

Yes, that's correct. (It might do a few extra things but that list should be small.) If it's rebuilding a lot before failing again, there's probably something funky going on there.

Yes, sorry I didn't define my terms. Yeah, clean build means clean/wipe/delete/nuke the build directory and then build again.

Don't worry about it! We need to work on making building the project (and understanding how the build works!) a smoother experience and this is valuable feedback. Keep the questions coming.