Clean build of swift compiler fails due to missing DebugDescriptionMacro

I was trying to make a clean build of the swift compiler on my M2 MacBook Pro by running the following command:

utils/build-script --skip-build-benchmarks \
  --swift-darwin-supported-archs "$(uname -m)" \
  --release-debuginfo --swift-disable-dead-stripping \
  --bootstrapping=hosttools --sccache

Once I hit the following mark:

Building the standard library for: swift-test-stdlib-macosx-arm64
cmake --build /Users/jaap/Developer/swift-project/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64 -- -j12 all swift-test-stdlib-macosx-arm64 swift-libexec-macosx-arm64

This unfortunately fails with the following error:

/Users/jaap/Developer/swift-project/swift/stdlib/public/core/ObjectIdentifier+DebugDescription.swift:16:7: error: external macro implementation type 'SwiftMacros.DebugDescriptionMacro' could not be found for macro 'DebugDescription()'; No such file or directory
14 | @DebugDescription
15 | extension ObjectIdentifier {
16 |   var lldbDescription: String {
   |       `- error: external macro implementation type 'SwiftMacros.DebugDescriptionMacro' could not be found for macro 'DebugDescription()'; No such file or directory
17 |     return "ObjectIdentifier(\(_value))"
18 |   }

How can I avoid this? Am I missing something obvious perhaps or am I just having some bad luck? Help would be much appreciated! Not sure where to look for a solution in this case. I tried looking for hints like flags in build-scrip --help regarding macros or this specific feature that might disable it etc.

@JaapWijnen The --bootstrapping=hosttools option might need an Xcode 16 beta. For example, by setting the DEVELOPER_DIR environment variable.

env DEVELOPER_DIR="/Applications/Xcode-beta.app" \
  utils/build-script \
  --bootstrapping=hosttools \
  --reconfigure \
  --release-debuginfo \
  --sccache \
  --skip-build-benchmarks \
  --swift-darwin-supported-archs="$(uname -m)" \
  --swift-disable-dead-stripping

@Dave_Lee Should the standard library guard its use of the macro?

+#if compiler(>=6.0) && $DebugDescriptionMacro
 @DebugDescription
+#endif
 extension ObjectIdentifier {
1 Like

This got me at least some steps further thanks!
I then ran into the following error:

/Users/jaap/Developer/swift-project/swift-argument-parser/Sources/ArgumentParserTestHelpers/TestHelpers.swift:14:8: error: no such module 'XCTest'
 12 | import ArgumentParser
 13 | import ArgumentParserToolInfo
 14 | import XCTest
    |        `- error: no such module 'XCTest'
 15 |
 16 | @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)

Which made me think (after looking through build-script --help) I should probably add --xctest to the command. Which in turn required adding --lldb which I inferred from reading the following from the error output:

-- Vending swift-argument-parser
CMake Error at /opt/homebrew/Cellar/cmake/3.30.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find LLBuild (missing: libllbuild_LIBRARIES
  libllbuild_INCLUDE_DIRS llbuildSwift_LIBRARIES llbuildSwift_INCLUDE_DIRS)
Call Stack (most recent call first):
  /opt/homebrew/Cellar/cmake/3.30.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  cmake/modules/FindLLBuild.cmake:35 (find_package_handle_standard_args)
  CMakeLists.txt:62 (find_package)

Now I'm getting a huge amount of error output which I feel is foundation related. I added --foundation to my build-script command and then got:

/Users/jaap/Developer/swift-project/swift-driver/Sources/SwiftDriver/Execution/ArgsResolver.swift:20:29: error: compiling for macOS 10.15, but module 'Yams' has a minimum deployment target of macOS 14.0: /Users/jaap/Developer/swift-project/build/Ninja-RelWithDebInfoAssert/earlyswiftdriver-macosx-arm64/release/dependencies/yams/swift/Yams.swiftmodule
 18 | import struct TSCBasic.SHA256
 19 |
 20 | @_implementationOnly import Yams
    |                             `- error: compiling for macOS 10.15, but module 'Yams' has a minimum deployment target of macOS 14.0: /Users/jaap/Developer/swift-project/build/Ninja-RelWithDebInfoAssert/earlyswiftdriver-macosx-arm64/release/dependencies/yams/swift/Yams.swiftmodule
 21 |
 22 | /// How the resolver is to handle usage of response files
ninja: build stopped: subcommand failed.
Ninja invocation failed:
ERROR: command terminated with a non-zero exit status 1, aborting

Which is making me thing I'm missing some other important part of the equation related to the SDK? Which makes me feel like perhaps I'm able to skip foundation and xctest (and therefore llbuild perhaps?)
But also a little stuck because I'm not sure what's missing here.

Thanks for the help so far!

@benrimmington after trying some other things I've now run into the following when the build-script is trying to compile XCTest:

/Users/jaap/Developer/swift-project/swift-corelibs-xctest/Sources/XCTest/Public/XCTestMain.swift:21:23: error: no such module 'SwiftFoundation'
    @_exported import SwiftFoundation

This is what my command looks like atm:

env DEVELOPER_DIR="/Applications/Xcode-beta.app" \
  utils/build-script \
  --bootstrapping=hosttools \
  --reconfigure \
  --release-debuginfo \
  --darwin-deployment-version-osx 14.2 \
  --sccache \
  --skip-build-benchmarks \
  --swift-darwin-supported-archs="$(uname -m)" \
  --swift-disable-dead-stripping \
  --llbuild \
  --foundation \
  --xctest

When I ran the build-script recently, I only included the options I listed earlier (minus --sccache which I'm not using).

Foundation.framework is included within macOS, and XCTest.framework is included within Xcode, so you shouldn't need any extra options.

Have you installed the separate "Command Line Tools for Xcode" package? Apparently it can interfere with Xcode builds, possibly causing XCTest to not be found.

You could also try --clean instead of --reconfigure, when switching between Xcode versions. Otherwise, I don't know why you're seeing those build failures.

1 Like

@benrimmington Perfect! In Xcode that was still set to the version from 15.2 instead of the beta. That fixed it. Was able to remove the --foundation --llbuild and --xctest flags. Thanks a lot!