Undefined symbols for architecture x86_64: swiftCompatibilityDynamicReplacements/swiftCompatibility51

When I invoke build-script like so:

./swift/utils/build-script --debug-swift -R --stdlib-deployment-targets=macosx-x86_64 --swift-darwin-supported-archs "x86_64" --extra-cmake-options="-DCMAKE_EXPORT_COMPILE_COMMANDS=1" --skip-ios --skip-watchos --skip-tvos --reconfigure

I get this error while building Swift:

+ /usr/local/bin/cmake --build /Users/danielzheng/swift-merge/build/Ninja-ReleaseAssert/swift-macosx-x86_64 -- -j36 all swift-test-stdlib-macosx-x86_64 swift-benchmark-macosx-x86_64
...
FAILED: bin/TestCPPToolLinkSwiftStaticLib
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -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 -fdiagnostics-color -Werror=switch -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -O3  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -target x86_64-apple-macosx10.9 -Xlinker -dead_strip validation-test/BuildSystem/swift-cmake/CMakeFiles/TestCPPToolLinkSwiftStaticLib.dir/CPPTool.cpp.o -o bin/TestCPPToolLinkSwiftStaticLib -L/Users/danielzheng/swift-merge/build/Ninja-ReleaseAssert/llvm-macosx-x86_64/./lib   -L/Users/danielzheng/.swiftenv/lib/swift/macosx   -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/lib/swift -Wl,-rpath,@executable_path/../lib -Wl,-rpath,/usr/lib/swift  lib/libTestPureSwiftStaticLib.a  lib/libTestCPPLib.a && :
ld: warning: directory not found for option '-L/Users/danielzheng/.swiftenv/lib/swift/macosx'
ld: warning: Could not find or use auto-linked library 'swiftCompatibility51'
ld: warning: Could not find or use auto-linked library 'swiftCompatibility50'
ld: warning: Could not find or use auto-linked library 'swiftCompatibilityDynamicReplacements'
Undefined symbols for architecture x86_64:
  "__swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements", referenced from:
      __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_TestPureSwiftStaticLib in libTestPureSwiftStaticLib.a(Klass.swift.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCompatibilityDynamicReplacements_$_TestPureSwiftStaticLib)
  "__swift_FORCE_LOAD_$_swiftCompatibility51", referenced from:
      __swift_FORCE_LOAD_$_swiftCompatibility51_$_TestPureSwiftStaticLib in libTestPureSwiftStaticLib.a(Klass.swift.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCompatibility51_$_TestPureSwiftStaticLib)
  "__swift_FORCE_LOAD_$_swiftCompatibility50", referenced from:
      __swift_FORCE_LOAD_$_swiftCompatibility50_$_TestPureSwiftStaticLib in libTestPureSwiftStaticLib.a(Klass.swift.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCompatibility50_$_TestPureSwiftStaticLib)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

Does anyone know how to fix this? Currently, I work around it by manually invoking ninja swift-frontend swift-stdlib at this point.

I'm on macOS 11.5.1 and Xcode 12.3 (12C33).