Failure building swift lib

Trying to build swift using the basic command: ./utils/build-script --release-debuginfo

Unfortunately getting this error:

FAILED: stdlib/public/runtime/CMakeFiles/swiftRuntime-macosx-x86_64.dir/__/__/__/lib/Demangling/NodePrinter.cpp.o
/Volumes/Seagate/Swift/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./bin/clang++  -DCMARK_STATIC_DEFINE -DGTEST_HAS_RTTI=0 -DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Istdlib/public/runtime -I/Volumes/Seagate/Swift/swift/stdlib/public/runtime -Iinclude -I/Volumes/Seagate/Swift/swift/include -I/Volumes/Seagate/Swift/llvm-project/llvm/include -I/Volumes/Seagate/Swift/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/include -I/Volumes/Seagate/Swift/llvm-project/clang/include -I/Volumes/Seagate/Swift/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/tools/clang/include -I/Volumes/Seagate/Swift/cmark/src -I/Volumes/Seagate/Swift/build/Ninja-RelWithDebInfoAssert/cmark-macosx-x86_64/src -Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector -fPIC -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 -fdiagnostics-color -Werror=switch -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -O2  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk    -fno-exceptions -fno-rtti -Werror=gnu -UNDEBUG -fno-sanitize=all -Wall -Wglobal-constructors -Wexit-time-destructors -fvisibility=hidden -DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS=1 -DswiftCore_EXPORTS -I/Volumes/Seagate/Swift/swift/include -DSWIFT_TARGET_LIBRARY_NAME=swiftRuntime -target x86_64-apple-macosx10.9 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -arch x86_64 -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/../../../Developer/Library/Frameworks -mmacosx-version-min=10.9 -O2 -g -DSWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS -std=c++14 -MD -MT stdlib/public/runtime/CMakeFiles/swiftRuntime-macosx-x86_64.dir/__/__/__/lib/Demangling/NodePrinter.cpp.o -MF stdlib/public/runtime/CMakeFiles/swiftRuntime-macosx-x86_64.dir/__/__/__/lib/Demangling/NodePrinter.cpp.o.d -o stdlib/public/runtime/CMakeFiles/swiftRuntime-macosx-x86_64.dir/__/__/__/lib/Demangling/NodePrinter.cpp.o -c /Volumes/Seagate/Swift/swift/lib/Demangling/NodePrinter.cpp
/Volumes/Seagate/Swift/swift/lib/Demangling/NodePrinter.cpp:695:14: error: no viable conversion from returned value of type 'llvm::StringRef' to function return type 'std::string' (aka 'basic_string<char, char_traits<char>, allocator<char> >')
      return Label->getKind() == Node::Kind::Identifier ? Label->getText()
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Seagate/Swift/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./bin/../include/c++/v1/string:800:5: note: candidate constructor not viable: no known conversion from 'llvm::StringRef' to 'const std::__1::basic_string<char> &' for 1st argument
    basic_string(const basic_string& __str);
    ^
/Volumes/Seagate/Swift/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./bin/../include/c++/v1/string:805:5: note: candidate constructor not viable: no known conversion from 'llvm::StringRef' to 'std::__1::basic_string<char> &&' for 1st argument
    basic_string(basic_string&& __str)
    ^
/Volumes/Seagate/Swift/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./bin/../include/c++/v1/string:818:5: note: candidate constructor template not viable: no known conversion from 'llvm::StringRef' to 'const char *' for 1st argument
    basic_string(const _CharT* __s) {
    ^
/Volumes/Seagate/Swift/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./bin/../include/c++/v1/string:868:5: note: candidate constructor not viable: no known conversion from 'llvm::StringRef' to 'initializer_list<char>' for 1st argument
    basic_string(initializer_list<_CharT> __il);
    ^
/Volumes/Seagate/Swift/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./bin/../include/c++/v1/string:793:40: note: explicit constructor is not a candidate
    _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a)
                                       ^
/Volumes/Seagate/Swift/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./bin/../include/c++/v1/string:854:18: note: explicit constructor is not a candidate
        explicit basic_string(const _Tp& __t);
                 ^
/Volumes/Seagate/Swift/llvm-project/llvm/include/llvm/ADT/StringRef.h:275:14: note: explicit conversion function is not a candidate
    explicit operator std::string() const { return str(); }
             ^
/Volumes/Seagate/Swift/swift/lib/Demangling/NodePrinter.cpp:1150:47: error: no matching conversion for functional-style cast from 'llvm::StringRef' to '(anonymous namespace)::QuotedString'
      Printer << " with unmangled suffix " << QuotedString(Node->getText());
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Seagate/Swift/swift/lib/Demangling/NodePrinter.cpp:66:8: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'llvm::StringRef' to 'const (anonymous namespace)::QuotedString' for 1st argument
struct QuotedString {
       ^
/Volumes/Seagate/Swift/swift/lib/Demangling/NodePrinter.cpp:66:8: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'llvm::StringRef' to '(anonymous namespace)::QuotedString' for 1st argument
struct QuotedString {
       ^
/Volumes/Seagate/Swift/swift/lib/Demangling/NodePrinter.cpp:69:12: note: candidate constructor not viable: no known conversion from 'llvm::StringRef' to 'std::string' (aka 'basic_string<char, char_traits<char>, allocator<char> >') for 1st argument
  explicit QuotedString(std::string Value) : Value(Value) {}
           ^
2 errors generated.
[50/1679][  2%][52.392s] Building CXX object stdlib/public/runtime/CMakeFiles/swiftRuntime-macosx-x86_64.dir/Metadata.cpp.o
/Volumes/Seagate/Swift/swift/stdlib/public/runtime/Metadata.cpp:4304:23: warning: declaration requires a global constructor [-Wglobal-constructors]
static const unsigned swift_ptrauth_key_associated_type =
                      ^
/Volumes/Seagate/Swift/swift/stdlib/public/runtime/Metadata.cpp:4319:23: warning: declaration requires a global constructor [-Wglobal-constructors]
static const unsigned swift_ptrauth_key_associated_conformance =
                      ^
2 warnings generated.
ninja: build stopped: subcommand failed.
ERROR: command terminated with a non-zero exit status 1, aborting

I think that you have the wrong points of the LLVM repository checked out - that was a recent API change in LLVM. Changing Label->getText() to Label->getText().str() should fix the issue, though I would verify that you have swift/master checked out on llvm-project and master checked out on swift.

I would also make sure you use update-checkout to get the right source. The draconian option:

./swift/utils/update-checkout --scheme master --reset-to-remote --clean

The reset to remote will do a force reset of branches and --clean will clean any other weird stuff you are seeing. Hope this helps!

Thank you guys for helping me out!

@compnerd you are right, I guess I didn't use the llvm-project fork from apple and used original instead.
@Michael_Gottesman thanks, by combing your both advices it seems to work :slight_smile: