Build failure swift-5.7.3-RELEASE

I'm starting to wonder if the Swift compiler is expected to build to completion or if that is a rare event.

Here is my build script:

#!/bin/bash
mkdir swift-source
cd swift-source
git clone https://github.com/apple/swift.git
cd swift
git checkout  swift-5.7.3-RELEASE
cd ..
./swift/utils/update-checkout --clone
time nice swift/utils/build-script -j2 --preset=buildbot_linux,no_test \
install_destdir=~/swift-install installable_package=~/swift.tgz

Here is the error that I see:

[243/1486][ 16%][387.201s] Building CXX object lib/Demangling/CMakeFiles/swiftDemangling.dir/OldDemangler.cpp.o
FAILED: lib/Demangling/CMakeFiles/swiftDemangling.dir/OldDemangler.cpp.o 
/usr/bin/clang++ -DCMARK_STATIC_DEFINE -DGTEST_HAS_RTTI=0 -DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1 -DSWIFT_STDLIB_HAS_TYPE_PRINTING=1 -DSWIFT_SUPPORT_OLD_MANGLING=1 -DSWIFT_THREADING_LINUX -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Demangling -I/home/me/swift-source/swift/lib/Demangling -I/home/me/swift-source/swift/stdlib/public/SwiftShims -Iinclude -I/home/me/swift-source/swift/include -I/home/me/swift-source/llvm-project/llvm/include -I/home/me/swift-source/build/buildbot_linux/llvm-linux-aarch64/include -I/home/me/swift-source/llvm-project/clang/include -I/home/me/swift-source/build/buildbot_linux/llvm-linux-aarch64/tools/clang/include -I/home/me/swift-source/cmark/src/include -I/home/me/swift-source/build/buildbot_linux/cmark-linux-aarch64/src -I/home/me/swift-source/swift-corelibs-libdispatch/src/BlocksRuntime -I/home/me/swift-source/swift-corelibs-libdispatch -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 -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Werror=switch -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -O3 -DNDEBUG  -fno-exceptions -fno-rtti -Werror=gnu -Werror=c++98-compat-extra-semi -UNDEBUG -target aarch64-unknown-linux-gnu -O2 -g0 -funwind-tables -std=c++14 -MD -MT lib/Demangling/CMakeFiles/swiftDemangling.dir/OldDemangler.cpp.o -MF lib/Demangling/CMakeFiles/swiftDemangling.dir/OldDemangler.cpp.o.d -o lib/Demangling/CMakeFiles/swiftDemangling.dir/OldDemangler.cpp.o -c /home/me/swift-source/swift/lib/Demangling/OldDemangler.cpp
/home/me/swift-source/swift/lib/Demangling/OldDemangler.cpp:154:40: error: no member named 'value' in 'llvm::Optional<char>'
    while (!isEmpty() && (c2 = peek()).value() != c) {
                         ~~~~~~~~~~~~~ ^
/home/me/swift-source/swift/lib/Demangling/OldDemangler.cpp:155:27: error: no member named 'value' in 'llvm::Optional<char>'
      result.push_back(c2.value());
                       ~~ ^
/home/me/swift-source/swift/lib/Demangling/OldDemangler.cpp:158:33: error: no member named 'value' in 'llvm::Optional<char>'
    return c2.has_value() && c2.value() == c;
                             ~~ ^
/home/me/swift-source/swift/lib/Demangling/OldDemangler.cpp:158:15: error: no member named 'has_value' in 'llvm::Optional<char>'; did you mean 'hasValue'?
    return c2.has_value() && c2.value() == c;
              ^~~~~~~~~
              hasValue
/home/me/swift-source/llvm-project/llvm/include/llvm/ADT/Optional.h:288:18: note: 'hasValue' declared here
  constexpr bool hasValue() const { return Storage.hasValue(); }
                 ^
/home/me/swift-source/swift/lib/Demangling/OldDemangler.cpp:380:14: error: no member named 'has_value' in 'llvm::Optional<swift::Demangle::ValueWitnessKind>'; did you mean 'hasValue'?
      if (!w.has_value())
             ^~~~~~~~~
             hasValue
/home/me/swift-source/llvm-project/llvm/include/llvm/ADT/Optional.h:288:18: note: 'hasValue' declared here
  constexpr bool hasValue() const { return Storage.hasValue(); }
                 ^
/home/me/swift-source/swift/lib/Demangling/OldDemangler.cpp:385:55: error: no member named 'value' in 'llvm::Optional<swift::Demangle::ValueWitnessKind>'
                                           unsigned(w.value()));
                                                    ~ ^
/home/me/swift-source/swift/lib/Demangling/OldDemangler.cpp:400:9: error: no member named 'has_value' in 'llvm::Optional<swift::Demangle::Directness>'; did you mean 'hasValue'?
        DEMANGLE_CHILD_AS_NODE_OR_RETURN(fieldOffset, Directness, depth + 1);
        ^
/home/me/swift-source/swift/lib/Demangling/OldDemangler.cpp:189:16: note: expanded from macro 'DEMANGLE_CHILD_AS_NODE_OR_RETURN'
    if (!_kind.has_value())                                                     \
               ^
/home/me/swift-source/llvm-project/llvm/include/llvm/ADT/Optional.h:288:18: note: 'hasValue' declared here
  constexpr bool hasValue() const { return Storage.hasValue(); }
                 ^
/home/me/swift-source/swift/lib/Demangling/OldDemangler.cpp:792:16: error: no member named 'has_value' in 'llvm::Optional<swift::Demangle::Node::Kind>'; did you mean 'hasValue'?
      if (kind.has_value()) return nullptr;
               ^~~~~~~~~
               hasValue
/home/me/swift-source/llvm-project/llvm/include/llvm/ADT/Optional.h:288:18: note: 'hasValue' declared here
  constexpr bool hasValue() const { return Storage.hasValue(); }
                 ^
/home/me/swift-source/swift/lib/Demangling/OldDemangler.cpp:810:15: error: no member named 'has_value' in 'llvm::Optional<swift::Demangle::Node::Kind>'; did you mean 'hasValue'?
    if (!kind.has_value()) kind = Node::Kind::Identifier;
              ^~~~~~~~~
              hasValue
/home/me/swift-source/llvm-project/llvm/include/llvm/ADT/Optional.h:288:18: note: 'hasValue' declared here
  constexpr bool hasValue() const { return Storage.hasValue(); }
                 ^
9 errors generated.
[244/1486][ 16%][456.251s] Building CXX object stdlib/public/SwiftRemot.../CMakeFiles/swiftRemoteMirror-linux-aarch64.dir/SwiftRemoteMirror.cpp.o
ninja: build stopped: subcommand failed.
ERROR: command terminated with a non-zero exit status 1, aborting

ERROR: command terminated with a non-zero exit status 1, aborting

Most likely you don't have the right tag of LLVM checked out, as update-checkout has the flag --tag to check out the right version. You can check with cd llvm-project and git status or git log. If not the 5.7.3 tag, check it out now with ./swift/utils/update-checkout --tag swift-5.7.3-RELEASE (I don't think the checkout script can clone and check out a tag at once, so you will need to add this second command to your build script).

My llvm is stable/20211026, which is 1 commit after swift-5.7.3-RELEASE.
OK, I'll update my script, thanks.

I still get a build error:

[12/31][ 38%][38.043s] Linking Swift static library lib/libPackageCollectionsSigning.a
FAILED: lib/libPackageCollectionsSigning.a Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Certificate/Certificate.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Certificate/CertificatePolicy.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/ASN1/ASN1.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/ASN1/ASN1Error.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/ASN1/PEMDocument.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/ASN1/SEC1PrivateKey.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/ASN1/SubjectPublicKeyInfo.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/ASN1/Types/ASN1BitString.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/ASN1/Types/ASN1Identifier.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/ASN1/Types/ASN1Integer.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/ASN1/Types/ASN1ObjectIdentifier.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/ASN1/Types/ASN1OctetString.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/BoringSSLKey.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/Key.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/Key+EC.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Key/Key+RSA.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/PackageCollectionSigning.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Signing/BoringSSLSigning.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Signing/Signature.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Signing/Signing.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Signing/Signing+ECKey.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Signing/Signing+RSAKey.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Utilities/Base64URL.swift.o Sources/PackageCollectionsSigning/CMakeFiles/PackageCollectionsSigning.dir/Utilities/Utilities.swift.o swift/PackageCollectionsSigning.swiftmodule

And then:

/home/me/swift-source/swiftpm/Sources/PackageCollectionsSigning/Certificate/Certificate.swift:119:46: error: cannot find type 'X509' in scope
    typealias Pointer = UnsafeMutablePointer<X509>
                                             ^~~~
/home/me/swift-source/swiftpm/Sources/PackageCollectionsSigning/Certificate/Certificate.swift:209:46: error: cannot find type 'X509_NAME' in scope
    typealias Pointer = UnsafeMutablePointer<X509_NAME>
                                             ^~~~~~~~~
/home/me/swift-source/swiftpm/Sources/PackageCollectionsSigning/Certificate/Certificate.swift:148:42: error: extra argument 'x509Name' in call
        return CertificateName(x509Name: subject)
                              ~~~~~~~~~~~^~~~~~~~
/home/me/swift-source/swiftpm/Sources/PackageCollectionsSigning/Certificate/Certificate.swift:148:31: error: missing arguments for parameters 'userID', 'commonName', 'organization', 'organizationalUnit' in call
        return CertificateName(x509Name: subject)
                              ^
/home/me/swift-source/swiftpm/Sources/PackageCollectionsSigning/Certificate/Certificate.swift:267:8: note: 'init(userID:commonName:organization:organizationalUnit:)' declared here
struct CertificateName {
       ^
/home/me/swift-source/swiftpm/Sources/PackageCollectionsSigning/Certificate/Certificate.swift:155:42: error: extra argument 'x509Name' in call
        return CertificateName(x509Name: issuer)
                              ~~~~~~~~~~~^~~~~~~
/home/me/swift-source/swiftpm/Sources/PackageCollectionsSigning/Certificate/Certificate.swift:155:31: error: missing arguments for parameters 'userID', 'commonName', 'organization', 'organizationalUnit' in call
        return CertificateName(x509Name: issuer)
                              ^
/home/me/swift-source/swiftpm/Sources/PackageCollectionsSigning/Certificate/Certificate.swift:267:8: note: 'init(userID:commonName:organization:organizationalUnit:)' declared here
struct CertificateName {
       ^
[15/31][ 48%][57.608s] Linking Swift shared library lib/libPackageModel.so
ninja: build stopped: subcommand failed.
/home/me/swift-source/build/buildbot_linux/ninja-build/ninja
--- bootstrap: error: Command '['/home/me/swift-source/build/buildbot_linux/ninja-build/ninja']' returned non-zero exit status 1.
ERROR: command terminated with a non-zero exit status 1, aborting

ERROR: command terminated with a non-zero exit status 1, aborting

Check what tag you have swift-crypto checked out at, it should be 1.1.5, not 2.2.3 as in current trunk.

If so, you may be better off checking out the 5.7 branch with --scheme release/5.7, rather than a tag, which may not work for repos that follow their own numbered tagging scheme. If you don't want to restart your whole build, you can just update all repos with numbered tags in this link instead.

That didn't work either.
It seems the "release" version of the compiler isn't ready for the public yet.

If you don't detail what error you got this time or what swift-crypto version you had checked out, we can't help you figure it out. The build must work, else there wouldn't be a shipping 5.7.3 compiler for several linux distros now.

Can you provide a build script that you know to be correct?
I've tried using --scheme, --tag, and even checking out each subdirectory manually e.g. release/5.4, but each time the build fails.

I think the one you provided initially should work, provided you clone trunk in your first checkout command, then check out the 5.7 branch with the scheme flag I gave you by running checkout again.

What went wrong when you tried that? You got pretty far if you were building the package manager before you got that crypto error last week. Once you made sure all those dependencies were checked out to the right tag, you still got the same error?

The build may be a bit fragile these days- I couldn't even get an unmodifed compiler to build on linux from trunk snapshot source a couple weeks ago- but we can't help you complete your build and fix any remaining problems without error logs.

If I recall, --scheme caused numerous errors. The --tag did not, but the compilation failed with numerous errors.

The only time I've gotten it to build to completion is when I used the bleeding-edge 5.9dev code. In that case, it was just the tests that failed.

update-checkout has to succeed before you start building, otherwise you'd be building an inconsistent checkout, which is almost certainly a cause of the build issues that you mentioned.