Static Swift Stdlib with Swiftly and Tarball Installation

I am trying to create a minimal example of a statically linked executable under Linux (Ubuntu 22.04 LTS, Swift 5.10 or 6.0 installed via swiftly, ARM64 and x86).

Compiling with swift build --static-swift-stdlib gives the error below. I have not checked yet with the Docker image or other installation methods.

// Edit: I checked with the Docker installation and the problem does not occur . However, installation as described in Swift.org - Linux Installation via Tarball leads to the same issue.

I would appreciate any suggestions of what might have gone wrong.

Building for debugging...
error: link command failed with exit code 1 (use -v to see invocation)
/usr/bin/ld.gold: error: cannot find -lstdc++
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(AnyHashableSupport.cpp.o):AnyHashableSupport.cpp:function std::pair<(anonymous namespace)::HashableConformanceEntry*, unsigned int> swift::ConcurrentReadableHashMap<(anonymous namespace)::HashableConformanceEntry, swift::LazyMutex>::find<(anonymous namespace)::HashableConformanceKey>((anonymous namespace)::HashableConformanceKey const&, swift::ConcurrentReadableHashMap<(anonymous namespace)::HashableConformanceEntry, swift::LazyMutex>::IndexStorage, unsigned long, (anonymous namespace)::HashableConformanceEntry*): error: undefined reference to '__cxa_guard_acquire'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(AnyHashableSupport.cpp.o):AnyHashableSupport.cpp:function std::pair<(anonymous namespace)::HashableConformanceEntry*, unsigned int> swift::ConcurrentReadableHashMap<(anonymous namespace)::HashableConformanceEntry, swift::LazyMutex>::find<(anonymous namespace)::HashableConformanceKey>((anonymous namespace)::HashableConformanceKey const&, swift::ConcurrentReadableHashMap<(anonymous namespace)::HashableConformanceEntry, swift::LazyMutex>::IndexStorage, unsigned long, (anonymous namespace)::HashableConformanceEntry*): error: undefined reference to '__cxa_guard_release'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(AnyHashableSupport.cpp.o):AnyHashableSupport.cpp:function swift::ConcurrentReadableHashMap<(anonymous namespace)::HashableConformanceEntry, swift::LazyMutex>::resize(swift::ConcurrentReadableHashMap<(anonymous namespace)::HashableConformanceEntry, swift::LazyMutex>::IndexStorage, unsigned char, (anonymous namespace)::HashableConformanceEntry*): error: undefined reference to '__cxa_guard_acquire'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(AnyHashableSupport.cpp.o):AnyHashableSupport.cpp:function swift::ConcurrentReadableHashMap<(anonymous namespace)::HashableConformanceEntry, swift::LazyMutex>::resize(swift::ConcurrentReadableHashMap<(anonymous namespace)::HashableConformanceEntry, swift::LazyMutex>::IndexStorage, unsigned char, (anonymous namespace)::HashableConformanceEntry*): error: undefined reference to '__cxa_guard_release'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift::nameForMetadata[abi:cxx11](swift::TargetMetadata<swift::InProcess> const*, bool): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift::nameForMetadata[abi:cxx11](swift::TargetMetadata<swift::InProcess> const*, bool): error: undefined reference to 'operator delete(void*)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift::MetadataOrPack::nameForMetadata[abi:cxx11]() const: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift::MetadataOrPack::nameForMetadata[abi:cxx11]() const: error: undefined reference to 'operator delete(void*)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift::MetadataOrPack::nameForMetadata[abi:cxx11]() const: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift::MetadataOrPack::nameForMetadata[abi:cxx11]() const: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift::MetadataOrPack::nameForMetadata[abi:cxx11]() const: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift::MetadataOrPack::nameForMetadata[abi:cxx11]() const: error: undefined reference to 'operator delete(void*)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift::MetadataOrPack::nameForMetadata[abi:cxx11]() const: error: undefined reference to 'std::__throw_length_error(char const*)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift_getTypeName: error: undefined reference to 'operator delete(void*)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift_getMangledTypeName: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift_getFunctionFullNameFromMangledName: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift_getFunctionFullNameFromMangledName: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift_getFunctionFullNameFromMangledName: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift_getFunctionFullNameFromMangledName: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char const*)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function swift_getFunctionFullNameFromMangledName: error: undefined reference to 'std::__throw_length_error(char const*)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function __swift::__runtime::llvm::operator+=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, __swift::__runtime::llvm::StringRef): error: undefined reference to 'std::__throw_length_error(char const*)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function $ss36_getBridgedNonVerbatimObjectiveCTypeyypXpSgxmlF: error: undefined reference to '__cxa_guard_acquire'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function $ss36_getBridgedNonVerbatimObjectiveCTypeyypXpSgxmlF: error: undefined reference to '__cxa_guard_release'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function $ss33_isBridgedNonVerbatimToObjectiveCySbxmlF: error: undefined reference to '__cxa_guard_acquire'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Casting.cpp.o):Casting.cpp:function $ss33_isBridgedNonVerbatimToObjectiveCySbxmlF: error: undefined reference to '__cxa_guard_release'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Errors.cpp.o):Errors.cpp:function swift::dumpStackTraceEntry(unsigned int, void*, bool): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Errors.cpp.o):Errors.cpp:function swift::dumpStackTraceEntry(unsigned int, void*, bool): error: undefined reference to '__cxa_demangle'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Errors.cpp.o):Errors.cpp:function swift::dumpStackTraceEntry(unsigned int, void*, bool): error: undefined reference to 'std::__throw_length_error(char const*)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Errors.cpp.o):Errors.cpp:function swift::withCurrentBacktrace(std::function<void (void**, int)>): error: undefined reference to 'std::__throw_bad_function_call()'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Metadata.cpp.o):Metadata.cpp:function swift::Lazy<(anonymous namespace)::SingletonTypeMetadataCache>::defaultInitCallback(void*): error: undefined reference to 'operator new(unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Metadata.cpp.o):Metadata.cpp:function swift::Lazy<(anonymous namespace)::TupleCache>::defaultInitCallback(void*): error: undefined reference to 'operator new(unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Metadata.cpp.o):Metadata.cpp:function __swift::__runtime::llvm::StringRef::str[abi:cxx11]() const: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Metadata.cpp.o):Metadata.cpp:function swift_getWitnessTable: error: undefined reference to 'operator new(unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Metadata.cpp.o):Metadata.cpp:function swift_getWitnessTableRelative: error: undefined reference to 'operator new(unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Metadata.cpp.o):Metadata.cpp:function std::pair<std::__detail::_Node_iterator<swift::TargetMetadata<swift::InProcess> const*, true, false>, bool> std::_Hashtable<swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, std::allocator<swift::TargetMetadata<swift::InProcess> const*>, std::__detail::_Identity, std::equal_to<swift::TargetMetadata<swift::InProcess> const*>, std::hash<swift::TargetMetadata<swift::InProcess> const*>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >::_M_insert<swift::TargetMetadata<swift::InProcess> const* const&, std::__detail::_AllocNode<std::allocator<std::__detail::_Hash_node<swift::TargetMetadata<swift::InProcess> const*, false> > > >(swift::TargetMetadata<swift::InProcess> const* const&, std::__detail::_AllocNode<std::allocator<std::__detail::_Hash_node<swift::TargetMetadata<swift::InProcess> const*, false> > > const&, std::integral_constant<bool, true>): error: undefined reference to 'std::__detail::_Prime_rehash_policy::_M_need_rehash(unsigned long, unsigned long, unsigned long) const'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Metadata.cpp.o):Metadata.cpp:function std::_Hashtable<swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, std::allocator<swift::TargetMetadata<swift::InProcess> const*>, std::__detail::_Identity, std::equal_to<swift::TargetMetadata<swift::InProcess> const*>, std::hash<swift::TargetMetadata<swift::InProcess> const*>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >::_M_rehash_aux(unsigned long, std::integral_constant<bool, true>): error: undefined reference to 'std::__throw_bad_array_new_length()'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Metadata.cpp.o):Metadata.cpp:function std::_Hashtable<swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, std::allocator<swift::TargetMetadata<swift::InProcess> const*>, std::__detail::_Identity, std::equal_to<swift::TargetMetadata<swift::InProcess> const*>, std::hash<swift::TargetMetadata<swift::InProcess> const*>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >::_M_rehash_aux(unsigned long, std::integral_constant<bool, true>): error: undefined reference to 'std::__throw_bad_alloc()'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Metadata.cpp.o):Metadata.cpp:function diagnoseMetadataDependencyCycle(__swift::__runtime::llvm::ArrayRef<swift::MetadataDependency>): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Metadata.cpp.o):Metadata.cpp:function __swift::__runtime::llvm::toHex[abi:cxx11](__swift::__runtime::llvm::StringRef, bool): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::reserve(unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Metadata.cpp.o):Metadata.cpp:function __swift::__runtime::llvm::toHex[abi:cxx11](__swift::__runtime::llvm::StringRef, bool): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Metadata.cpp.o):Metadata.cpp:function __swift::__runtime::llvm::toHex[abi:cxx11](__swift::__runtime::llvm::StringRef, bool): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(MetadataLookup.cpp.o):MetadataLookup.cpp:function swift::Demangle::__runtime::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledProtocolType(swift::Demangle::__runtime::Node*, unsigned int): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(MetadataLookup.cpp.o):MetadataLookup.cpp:function (anonymous namespace)::DecodedMetadataBuilder::createTupleType(__swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, __swift::__runtime::llvm::ArrayRef<__swift::__runtime::llvm::StringRef>) const: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace_aux(unsigned long, unsigned long, unsigned long, char)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(MetadataLookup.cpp.o):MetadataLookup.cpp:function (anonymous namespace)::DecodedMetadataBuilder::createTupleType(__swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, __swift::__runtime::llvm::ArrayRef<__swift::__runtime::llvm::StringRef>) const: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(MetadataLookup.cpp.o):MetadataLookup.cpp:function (anonymous namespace)::DecodedMetadataBuilder::createTupleType(__swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, __swift::__runtime::llvm::ArrayRef<__swift::__runtime::llvm::StringRef>) const: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(MetadataLookup.cpp.o):MetadataLookup.cpp:function swift::TypeLookupError::TypeLookupError<_gatherGenericParameters(swift::TargetContextDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::SmallVectorImpl<unsigned int>&, __swift::__runtime::llvm::SmallVectorImpl<void const*>&, swift::Demangle::__runtime::Demangler&)::$_26>(_gatherGenericParameters(swift::TargetContextDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::SmallVectorImpl<unsigned int>&, __swift::__runtime::llvm::SmallVectorImpl<void const*>&, swift::Demangle::__runtime::Demangler&)::$_26 const&)::{lambda(void*, swift::TypeLookupError::Command, void*)#1}::__invoke(void*, swift::TypeLookupError::Command, void*): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct(unsigned long, char)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(MetadataLookup.cpp.o):MetadataLookup.cpp:function swift::TypeLookupError::TypeLookupError<_gatherGenericParameters(swift::TargetContextDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::SmallVectorImpl<unsigned int>&, __swift::__runtime::llvm::SmallVectorImpl<void const*>&, swift::Demangle::__runtime::Demangler&)::$_26>(_gatherGenericParameters(swift::TargetContextDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::SmallVectorImpl<unsigned int>&, __swift::__runtime::llvm::SmallVectorImpl<void const*>&, swift::Demangle::__runtime::Demangler&)::$_26 const&)::{lambda(void*, swift::TypeLookupError::Command, void*)#1}::__invoke(void*, swift::TypeLookupError::Command, void*): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(MetadataLookup.cpp.o):MetadataLookup.cpp:function swift::TypeLookupError::TypeLookupError<_gatherGenericParameters(swift::TargetContextDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::SmallVectorImpl<unsigned int>&, __swift::__runtime::llvm::SmallVectorImpl<void const*>&, swift::Demangle::__runtime::Demangler&)::$_26>(_gatherGenericParameters(swift::TargetContextDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::SmallVectorImpl<unsigned int>&, __swift::__runtime::llvm::SmallVectorImpl<void const*>&, swift::Demangle::__runtime::Demangler&)::$_26 const&)::{lambda(void*, swift::TypeLookupError::Command, void*)#1}::__invoke(void*, swift::TypeLookupError::Command, void*): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct(unsigned long, char)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(MetadataLookup.cpp.o):MetadataLookup.cpp:function swift::TypeLookupError::TypeLookupError<_gatherGenericParameters(swift::TargetContextDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::SmallVectorImpl<unsigned int>&, __swift::__runtime::llvm::SmallVectorImpl<void const*>&, swift::Demangle::__runtime::Demangler&)::$_26>(_gatherGenericParameters(swift::TargetContextDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::SmallVectorImpl<unsigned int>&, __swift::__runtime::llvm::SmallVectorImpl<void const*>&, swift::Demangle::__runtime::Demangler&)::$_26 const&)::{lambda(void*, swift::TypeLookupError::Command, void*)#1}::__invoke(void*, swift::TypeLookupError::Command, void*): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(MetadataLookup.cpp.o):MetadataLookup.cpp:function swift::TypeLookupError::TypeLookupError<_gatherGenericParameters(swift::TargetContextDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::SmallVectorImpl<unsigned int>&, __swift::__runtime::llvm::SmallVectorImpl<void const*>&, swift::Demangle::__runtime::Demangler&)::$_26>(_gatherGenericParameters(swift::TargetContextDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::SmallVectorImpl<unsigned int>&, __swift::__runtime::llvm::SmallVectorImpl<void const*>&, swift::Demangle::__runtime::Demangler&)::$_26 const&)::{lambda(void*, swift::TypeLookupError::Command, void*)#1}::__invoke(void*, swift::TypeLookupError::Command, void*): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct(unsigned long, char)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(MetadataLookup.cpp.o):MetadataLookup.cpp:function swift::TypeLookupError::TypeLookupError<_gatherGenericParameters(swift::TargetContextDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::SmallVectorImpl<unsigned int>&, __swift::__runtime::llvm::SmallVectorImpl<void const*>&, swift::Demangle::__runtime::Demangler&)::$_28>(_gatherGenericParameters(swift::TargetContextDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::ArrayRef<swift::MetadataOrPack>, swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::SmallVectorImpl<unsigned int>&, __swift::__runtime::llvm::SmallVectorImpl<void const*>&, swift::Demangle::__runtime::Demangler&)::$_28 const&)::{lambda(void*, swift::TypeLookupError::Command, void*)#1}::__invoke(void*, swift::TypeLookupError::Command, void*): error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct(unsigned long, char)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(ReflectionMirror.cpp.o):ReflectionMirror.cpp:function swift_keyPathSourceString: error: undefined reference to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(char const*) const'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Backtrace.cpp.o):Backtrace.cpp:function _swift_backtrace_demangle: error: undefined reference to '__cxa_demangle'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(MemAlloc.cpp.o):MemAlloc.cpp:function __swift::__runtime::llvm::allocate_buffer(unsigned long, unsigned long): error: undefined reference to 'operator new(unsigned long, std::align_val_t)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(MemAlloc.cpp.o):MemAlloc.cpp:function __swift::__runtime::llvm::deallocate_buffer(void*, unsigned long, unsigned long): error: undefined reference to 'operator delete(void*, std::align_val_t)'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(NodePrinter.cpp.o):NodePrinter.cpp:function (anonymous namespace)::NodePrinter::printGenericSignature(swift::Demangle::__runtime::Node*, unsigned int): error: undefined reference to 'std::__throw_bad_function_call()'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(NodePrinter.cpp.o):NodePrinter.cpp:function std::function<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > (unsigned long, unsigned long)>::operator()(unsigned long, unsigned long) const: error: undefined reference to 'std::__throw_bad_function_call()'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Remangler.cpp.o):Remangler.cpp:function std::pair<std::__detail::_Node_iterator<std::pair<swift::Demangle::__runtime::SubstitutionEntry const, unsigned int>, false, true>, bool> std::_Hashtable<swift::Demangle::__runtime::SubstitutionEntry, std::pair<swift::Demangle::__runtime::SubstitutionEntry const, unsigned int>, std::allocator<std::pair<swift::Demangle::__runtime::SubstitutionEntry const, unsigned int> >, std::__detail::_Select1st, std::equal_to<swift::Demangle::__runtime::SubstitutionEntry>, swift::Demangle::__runtime::SubstitutionEntry::Hasher, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_emplace<std::pair<swift::Demangle::__runtime::SubstitutionEntry const, unsigned int> >(std::integral_constant<bool, true>, std::pair<swift::Demangle::__runtime::SubstitutionEntry const, unsigned int>&&): error: undefined reference to 'std::__detail::_Prime_rehash_policy::_M_need_rehash(unsigned long, unsigned long, unsigned long) const'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Remangler.cpp.o):Remangler.cpp:function std::_Hashtable<swift::Demangle::__runtime::SubstitutionEntry, std::pair<swift::Demangle::__runtime::SubstitutionEntry const, unsigned int>, std::allocator<std::pair<swift::Demangle::__runtime::SubstitutionEntry const, unsigned int> >, std::__detail::_Select1st, std::equal_to<swift::Demangle::__runtime::SubstitutionEntry>, swift::Demangle::__runtime::SubstitutionEntry::Hasher, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_rehash_aux(unsigned long, std::integral_constant<bool, true>): error: undefined reference to 'std::__throw_bad_array_new_length()'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Remangler.cpp.o):Remangler.cpp:function std::_Hashtable<swift::Demangle::__runtime::SubstitutionEntry, std::pair<swift::Demangle::__runtime::SubstitutionEntry const, unsigned int>, std::allocator<std::pair<swift::Demangle::__runtime::SubstitutionEntry const, unsigned int> >, std::__detail::_Select1st, std::equal_to<swift::Demangle::__runtime::SubstitutionEntry>, swift::Demangle::__runtime::SubstitutionEntry::Hasher, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_rehash_aux(unsigned long, std::integral_constant<bool, true>): error: undefined reference to 'std::__throw_bad_alloc()'
/home/fpultar/.local/share/swiftly/toolchains/5.10.1/usr/lib/swift_static/linux/libswiftCore.a(Stubs.cpp.o):Stubs.cpp:function _swift_stdlib_getHardwareConcurrency: error: undefined reference to 'std::thread::hardware_concurrency()'
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
error: fatalError
[7/8] Linking swift-stat-link

That's easy, it's telling you what went wrong:

error: link command failed with exit code 1 (use -v to see invocation)
/usr/bin/ld.gold: error: cannot find -lstdc++

The linux toolchain depends on several system packages to be installed, which the Docker image makes sure to have. Did you install all those Ubuntu 22.04 packages listed in the first step of the linux instructions you linked? If so, it is possible the static compile needs more packages that should be installed also.

Thanks, I understand what the error was but find it an inconsistency with the installation. I fixed it by converting the official Dockerfile into a Bash script:

#!/bin/bash

# Maintainer and description
echo "Maintainer: Swift Infrastructure <swift-infrastructure@forums.swift.org>"
echo "Description: Script for setting up Swift programming language environment"

# Export environment variables
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true

# Update apt package list and install dependencies
apt-get -q update
apt-get -q install -y \
    binutils \
    git \
    unzip \
    gnupg2 \
    libc6-dev \
    libcurl4-openssl-dev \
    libedit2 \
    libgcc-13-dev \
    libpython3-dev \
    libsqlite3-0 \
    libstdc++-13-dev \
    libxml2-dev \
    libncurses-dev \
    libz3-dev \
    pkg-config \
    tzdata \
    zlib1g-dev

# Clean up the apt cache
rm -r /var/lib/apt/lists/*

# Define the Swift Signing Key and other arguments
SWIFT_SIGNING_KEY="52BB7E3DE28A71BE22EC05FFEF80A866B47A981F"
SWIFT_PLATFORM="ubuntu24.04"
SWIFT_BRANCH="swift-6.0.1-release"
SWIFT_VERSION="swift-6.0.1-RELEASE"
SWIFT_WEBROOT="https://download.swift.org"

# Export the environment variables for Swift setup
export SWIFT_SIGNING_KEY SWIFT_PLATFORM SWIFT_BRANCH SWIFT_VERSION SWIFT_WEBROOT

# Detect architecture and set OS_ARCH_SUFFIX accordingly
ARCH_NAME="$(dpkg --print-architecture)"
case "${ARCH_NAME##*-}" in
    'amd64')
        OS_ARCH_SUFFIX=''
        ;;
    'arm64')
        OS_ARCH_SUFFIX='-aarch64'
        ;;
    *)
        echo "error: unsupported architecture: '$ARCH_NAME'"
        exit 1
        ;;
esac

# Set Swift binary URLs
SWIFT_WEBDIR="$SWIFT_WEBROOT/$SWIFT_BRANCH/$(echo $SWIFT_PLATFORM | tr -d .)$OS_ARCH_SUFFIX"
SWIFT_BIN_URL="$SWIFT_WEBDIR/$SWIFT_VERSION/$SWIFT_VERSION-$SWIFT_PLATFORM$OS_ARCH_SUFFIX.tar.gz"
SWIFT_SIG_URL="$SWIFT_BIN_URL.sig"

# Install curl and clean up apt cache
apt-get -q update
apt-get -q install -y curl
rm -rf /var/lib/apt/lists/*

# Download Swift toolchain and signature
GNUPGHOME="$(mktemp -d)"
curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz
curl -fsSL "$SWIFT_SIG_URL" -o swift.tar.gz.sig

# Import Swift signing key and verify the downloaded toolchain
gpg --batch --quiet --keyserver keyserver.ubuntu.com --recv-keys "$SWIFT_SIGNING_KEY"
gpg --batch --verify swift.tar.gz.sig swift.tar.gz

# Unpack the toolchain and set permissions
tar -xzf swift.tar.gz --directory / --strip-components=1
chmod -R o+r /usr/lib/swift

# Clean up
rm -rf "$GNUPGHOME" swift.tar.gz.sig swift.tar.gz
apt-get purge --auto-remove -y curl

# Print installed Swift version
swift --version
1 Like