Swift build failure with ninja and Xcode 11.5 default toolchain when building XCTest -- compiler mismatch?

Hi everybody,

A couple of days ago I stopped being able to build swift, which is weird.

The configuration is MacOS 10.5.5 with Xcode 11.5 (Version 11.5 (11E608c)) and the default toolchain (although I have had the same thing happen with other toolchains, and swift also won't build in the Big Sur partition with the Xcode beta but I get different errors, still maybe related to XCText, but that' s for another day.)

I ran update-checkout with everything in master (or swift/master for llvm). Then just run build-script, building with ninja in the build/Ninja-DebugAssert. I deleted the whole Ninja-DebugAssert directory to force a really clean build.

The specific error I'm getting is no such module at

import _SwiftAppKitOverlayShims

I have been trying to figure this out but I am still stuck. I am getting it consistently with different toolchains and stuff. I deleted the Xcode Beta, some other toolchains, Xcode itself, then reinstalled, ran Xcode-select -s to ensure I had the right stuff etc and I'm still getting a failure here.

The full error is below (twice, because it fails in parallel.)

Is anybody else seeing this or does anybody see something I am missing?

Like I said I got a failure in the Big Sur partition around the general area of XCTest with the Xcode beta and a fresh checkout but I decided to leave that alone for now.

Thanks!

Dan

[1115/1639][ 68%][1270.913s] Generating /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/XCTest.swiftmodule/x86_64-apple-macos.swiftmodule
FAILED: lib/swift/macosx/XCTest.swiftmodule/x86_64-apple-macos.swiftmodule lib/swift/macosx/XCTest.swiftmodule/x86_64-apple-macos.swiftdoc lib/swift/macosx/XCTest.swiftmodule/x86_64-apple-macos.swiftinterface 
cd /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/stdlib/public/Darwin/XCTest && /usr/local/Cellar/cmake/3.17.3/bin/cmake -E remove -f /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/XCTest.swiftmodule/x86_64-apple-macos.swiftmodule /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/XCTest.swiftmodule/x86_64-apple-macos.swiftdoc /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/XCTest.swiftmodule/x86_64-apple-macos.swiftinterface && /usr/local/Cellar/cmake/3.17.3/bin/cmake -E make_directory /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/XCTest.swiftmodule && /Applications/Xcode.app/Contents/Developer/usr/bin/python3 /Users/dfs/swift-source/swift/utils/line-directive @/Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/stdlib/public/Darwin/XCTest/Wn56x.txt -- /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./bin/swiftc -emit-module -o /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/XCTest.swiftmodule/x86_64-apple-macos.swiftmodule -avoid-emit-module-source-info -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -target x86_64-apple-macosx10.9 -resource-dir /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/../../../Developer/Library/Frameworks -Onone -g -D INTERNAL_CHECKS_ENABLED -D SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING -module-cache-path /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./module-cache -no-link-objc-runtime -enable-library-evolution -Xfrontend -enforce-exclusivity=unchecked -module-name XCTest -swift-version 5 -swift-version 5 -autolink-force-load -runtime-compatibility-version none -disable-autolinking-runtime-compatibility-dynamic-replacements -warn-swift3-objc-inference-complete -Xfrontend -verify-syntax-tree -Xfrontend -module-interface-preserve-types-as-written -warn-implicit-overrides -Fsystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/PrivateFrameworks/ -module-link-name swiftXCTest -whole-module-optimization -parse-as-library -I /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx -emit-module-interface-path /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx/XCTest.swiftmodule/x86_64-apple-macos.swiftinterface -Xfrontend -experimental-skip-non-inlinable-function-bodies @/Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/stdlib/public/Darwin/XCTest/Wn56x.txt
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/AppKit.swiftmodule/x86_64.swiftinterface:7:8: error: no such module '_SwiftAppKitOverlayShims'
import _SwiftAppKitOverlayShims
       ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/AppKit.swiftmodule/x86_64.swiftinterface:1:1: error: failed to build module 'AppKit' from its module interface; the compiler that produced it, 'Apple Swift version 5.2 (swiftlang-1103.8.25.8 clang-1103.0.30.20)', may have used features that aren't supported by this compiler, 'Swift version 5.3-dev (LLVM f9957f081870012, Swift 7976162e56d628a)'
// swift-interface-format-version: 1.0
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/AppKit.swiftmodule/x86_64.swiftinterface:7:8: error: no such module '_SwiftAppKitOverlayShims'
import _SwiftAppKitOverlayShims
       ^
[1116/1639][ 68%][1273.818s] Compiling /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/stdlib/public/Darwin/XCTest/OSX/x86_64/XCTest.o
FAILED: stdlib/public/Darwin/XCTest/OSX/x86_64/XCTest.o 
cd /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/stdlib/public/Darwin/XCTest && /Applications/Xcode.app/Contents/Developer/usr/bin/python3 /Users/dfs/swift-source/swift/utils/line-directive @/Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/stdlib/public/Darwin/XCTest/Wn56x.txt -- /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./bin/swiftc -c -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -target x86_64-apple-macosx10.9 -resource-dir /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/../../../Developer/Library/Frameworks -Onone -g -D INTERNAL_CHECKS_ENABLED -D SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING -module-cache-path /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./module-cache -no-link-objc-runtime -enable-library-evolution -Xfrontend -enforce-exclusivity=unchecked -module-name XCTest -swift-version 5 -swift-version 5 -autolink-force-load -runtime-compatibility-version none -disable-autolinking-runtime-compatibility-dynamic-replacements -warn-swift3-objc-inference-complete -Xfrontend -verify-syntax-tree -Xfrontend -module-interface-preserve-types-as-written -warn-implicit-overrides -Fsystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/PrivateFrameworks/ -module-link-name swiftXCTest -whole-module-optimization -parse-as-library -I /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/macosx -o /Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/stdlib/public/Darwin/XCTest/OSX/x86_64/XCTest.o @/Users/dfs/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/stdlib/public/Darwin/XCTest/Wn56x.txt
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/AppKit.swiftmodule/x86_64.swiftinterface:7:8: error: no such module '_SwiftAppKitOverlayShims'
import _SwiftAppKitOverlayShims
       ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/AppKit.swiftmodule/x86_64.swiftinterface:1:1: error: failed to build module 'AppKit' from its module interface; the compiler that produced it, 'Apple Swift version 5.2 (swiftlang-1103.8.25.8 clang-1103.0.30.20)', may have used features that aren't supported by this compiler, 'Swift version 5.3-dev (LLVM f9957f081870012, Swift 7976162e56d628a)'
// swift-interface-format-version: 1.0
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/AppKit.swiftmodule/x86_64.swiftinterface:7:8: error: no such module '_SwiftAppKitOverlayShims'
import _SwiftAppKitOverlayShims
       ^

1 Like

I have the same issue, but I believe that it is because now to build swift we have to use Xcode12, not sure, right now I'm switching toolchains and trying a clean build with Xcode 12 ...

cc @mishal_shah @compnerd

The overlay code was removed in da242bd2d4bfbbc1db1742ba58e66f1c168e6f22 (Jun 21). You can move to a slightly older compiler, or you can update your Xcode, I think both should work. We should update the README to address this...

3 Likes

Thanks Varun.

After xcode-select -s /Applications/Xcode-beta it builds on Macos 10.15.5.

The one oddity is that I get a warning:

ld: warning: dylib (/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework/XCTest) was built for newer macOS version (10.15) than being linked (10.9)

Which might have been there before and I did not notice it or should be ok anyway.

So the rule is, you need the Developer directory from Xcode 12 to build swift, right? And one from Xcode 11 will not work?

I might have had the Developer pointing at the wrong place earlier—I tried a couple of variations of xcode-select -s and might have messed that up.

Thank you for your help! Things are good again.

—Dan

You will need Xcode 12 beta to be able to build master and release/5.3 branch. This information can also be found in the README.md

macOS

To build for macOS, you need Xcode 12 beta. The required version of Xcode changes frequently, and is often a beta release. Check this document or the host information on https://ci.swift.org for the current required version.

1 Like

I think you should be fine, since whatever is getting linked is almost certainly going to be run on 10.15 or higher.

1 Like

I am able to get a successful build using the Xcode 12 beta on macOS Big Sur but I am missing the swift target and potentially some other schemes. I ran the build script with --xcode --debug. Has anyone seen this before?

Thanks!

The swift target was recently renamed to swift-frontend, does that show up for you?

2 Likes

It does, thank you!

When trying to debug the type checker using Xfrontend -debug-constraints I am getting an error unknown argument: '-Xfrontend' . Is there a different argument I should be using now?

Ah, that'll be because executing swift-frontend will now invoke the frontend directly instead of the driver. If you want to invoke the driver you'll need to change the scheme (under Edit Scheme > Run > Info > Executable) to run swiftc (or swift for immediate mode and subcommands). Note that these are both symlinks to swift-frontend, but the name of the executable changes what gets run (and what flags you're allowed to pass).

Though if you're just debugging the type checker, invoking the frontend directly may be more convenient, you can drop the -Xfrontend flags from the invocation, e.g:

swift-frontend -typecheck -debug-constraints main.swift
1 Like

Thank you! I got passed the first issue but now I am getting " error opening input file '/Users/vukradosavljevic/Desktop/test.swift. Previously when I would run it, it would request permission to access my Desktop but I am not seeing that now. And when I go to (System Preferences > Security & Privacy > Files and Folder) I am not seeing swift-frontend under the apps so I did not previously deny permission. Could this be something that's different on Big Sur with file/folder access? I will try a clean build on a mac running catalina and see if that works.

@hamishknight Does the swift-frontend target really requires bigSur macOS to run?
I'm hitting runs macOS 10.15.5, which is lower than swift-frontend’s minimum deployment target of 10.16 ...

Edit: Seems like not, I'm able to run now, but had to change the minimum target manually on the generated .xcodeproj :))

Ah yeah, that's just Xcode imposing the set minimum deployment target, the compiler binary itself shouldn't require macOS Big Sur to run, I'm still running it fine on macOS Mojave :)

1 Like

Hmm, could be a bug with macOS Big Sur, are you able to invoke it directly through Terminal?

1 Like

I got it working fine on Catalina I will try and test on Big Sur through the terminal.

It works through the terminal, I appreciate your help!

Great! Would you mind filing a bug over at https://feedbackassistant.apple.com/ for not being able to run the binary through Xcode on Big Sur?

Done!

1 Like

Apologies for reviving an old thread, but I want to mention a workaround that I use because I prefer living on the old toolchain but building against ToT for Swift. Before I share this, I want to emphasize just how dangerous this approach is to the stability of your toolchain. You should remember to undo these changes after you get the compiler stood up. The tools shipped with Xcode do not expect users to want to edit these files, and so anything that can happen here will happen. That said, we're interested in getting the compiler and resource libraries built, not actually using them, so:

You can directly edit the swiftinterface file for AppKit to remove the import declaration of _SwiftAppKitOverlayShims then rebuild.

2 Likes