Failure when building Swift project

While following @harlanhaskins and @codafi talk to start contributing, I get the following error message when running the following command

$ utils/build-script --xcode --debug --clean

# Lots of output omitted

** BUILD SUCCEEDED **

+ /usr/local/bin/cmake --build /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64 --target ZERO_CHECK --config Debug -- -parallelizeTargets -jobs 8 -target ALL_BUILD -target swift-test-stdlib-macosx-x86_64 -target swift-benchmark-macosx-x86_64
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project Swift.xcodeproj build -target ZERO_CHECK -parallelizeTargets -configuration Debug -hideShellScriptEnvironment -parallelizeTargets -jobs 8 -target ALL_BUILD -target swift-test-stdlib-macosx-x86_64 -target swift-benchmark-macosx-x86_64

User defaults from command line:
    HideShellScriptEnvironment = YES
    IDEBuildOperationMaxNumberOfConcurrentCompileTasks = 8

Build settings from command line:
    TOOLCHAINS = default

Build Preparation
Build task concurrency set to 8 via user default IDEBuildOperationMaxNumberOfConcurrentCompileTasks

note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Build system information
error: Multiple commands produce '/Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib':
1) Target 'BlocksRuntimeStub-macosx-arm64' has link command with output '/Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib'
2) Target 'BlocksRuntimeStub-macosx-arm64e' has link command with output '/Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib'
3) Target 'BlocksRuntimeStub-macosx-x86_64' has link command with output '/Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib'


warning: unexpected mutating task ('CodeSign /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib') with no relation to prior mutator ('CodeSign /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib') (in target 'BlocksRuntimeStub-macosx-arm64' from project 'Swift')
warning: unexpected mutating task ('CodeSign /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib') with no relation to prior mutator ('CodeSign /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib') (in target 'BlocksRuntimeStub-macosx-arm64' from project 'Swift')
warning: duplicate output file '' on task: CodeSign /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib (in target 'BlocksRuntimeStub-macosx-x86_64' from project 'Swift')
warning: duplicate output file '/Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib' on task: Ld /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib normal (in target 'BlocksRuntimeStub-macosx-x86_64' from project 'Swift')
warning: duplicate output file '' on task: Ld /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib normal (in target 'BlocksRuntimeStub-macosx-x86_64' from project 'Swift')
warning: duplicate output file '' on task: RegisterExecutionPolicyException /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib (in target 'BlocksRuntimeStub-macosx-x86_64' from project 'Swift')
warning: duplicate output file '' on task: CodeSign /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib (in target 'BlocksRuntimeStub-macosx-arm64e' from project 'Swift')
warning: duplicate output file '' on task: CodeSign /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib (in target 'BlocksRuntimeStub-macosx-arm64e' from project 'Swift')
warning: duplicate output file '/Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib' on task: Ld /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib normal (in target 'BlocksRuntimeStub-macosx-arm64e' from project 'Swift')
warning: duplicate output file '' on task: Ld /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib normal (in target 'BlocksRuntimeStub-macosx-arm64e' from project 'Swift')
warning: duplicate output file '' on task: RegisterExecutionPolicyException /Volumes/Projects8TB/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/libBlocksRuntime.dylib (in target 'BlocksRuntimeStub-macosx-arm64e' from project 'Swift')
** BUILD FAILED **

The only other error is I see in the in output is

xcodebuild: error: invalid option '--version'

Steps to reproduce:

  1. Fork the github.com/apple/swift
  2. Clone the fork into an external hard drive (my computer doesn't have enough space)
  3. Run swift/utils/update-checkout --clone
  4. Run cd swift
  5. Run utils/build-script --xcode --debug

Machine Environment

Xcode: Version 12.4 (12D4e)
OS: macOS Big Sur Version 11.2.1 (20D74)
cmake: Version 3.20.0
ninja: Version 1.10.2
Python: python3 --version == 3.9.1

$ pwd
/Volumes/Projects8TB
$ ls -l | awk '{print $9}'                                                                                                                                                                                                                                                                                                                                             
build
cmark
indexstore-db
llbuild
llvm-project
ninja
sourcekit-lsp
swift
swift-argument-parser
swift-corelibs-foundation
swift-corelibs-libdispatch
swift-corelibs-xctest
swift-crypto
swift-driver
swift-format
swift-integration-tests
swift-stress-tester
swift-syntax
swift-tools-support-core
swift-xcode-playground-support
swiftpm
yams

Looks like the build-script is trying to emit libBlocksRuntime for multiple target architectures into the host arch’s build folder. Thanks for reporting this. I believe you can work around it by building exclusively for your host arch with --swift-darwin-supported-archs “x86_64” (or arm64e if you’re one of the lucky few with an Apple Silicon mac). You may additionally need to provide --reconfigure or even nuke your build folder and try again for this to take effect.

@compnerd Do you know why the build rule is screwed up here?

Additionally you can follow the detailed guide to first contribution in the docs of the project, there may be that you would have to use additional flags like --swift-darwin-supported-archs “x86_64” mentioned by @codafi
Here is the like for the docs: swift/GettingStarted.md at main · apple/swift · GitHub

1 Like

@codafi - the first and foremost thing (because pedantry is critical for this) - it is not emitting libBlocksRuntime, but the Blocks Runtime stubs. This implies that the problem is the handling for tests on Darwin is incorrect.

Unfortunately, Darwin is particularly special and has a completely separate path from the rest of the platforms (Windows, android, Linux, BSD, PS4, etc) due to fat binaries. This is handled via _add_swift_target_library_single. That seems to work its way to add_library followed by set_target_properties(... PROPERTIES OUTPUT_NAME ...) which will cause the output name to collide :frowning_face:

Once I deleted I started over, I received similar errors this issue. Removing --test as suggested here by you worked. Thank you @LucianoPAlmeida.

I thought something like that might be happening from other similar errors during application development, but wasn't sure how to narrow it down. Luckily, Luciano's links and suggestion worked.

Terms of Service

Privacy Policy

Cookie Policy