swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.73k stars 1.34k forks source link

[SR-15684] Xcode 13.2 CLI tools building swift in release mode: error: remark: Incremental compilation has been disabled: it is not compatible with whole module optimization #4365

Open swift-ci opened 2 years ago

swift-ci commented 2 years ago
Previous ID SR-15684
Radar https://feedbackassistant.apple.com/feedback/9832752
Original Reporter jayayres (JIRA User)
Type Bug

Attachment: Download

Environment xcodebuild Xcode 13.2, Build version 13C90 Monterey 12.1 M1 Max MBP
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 1 | |Component/s | Package Manager | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: e549b419adb482736a0b860db11495c1

Issue Description:

Using Xcode 13.2 command line tools, swift build -c release --arch arm64 --arch x86_64 is resulting in the error:

"error: remark: Incremental compilation has been disabled: it is not compatible with whole module optimization"

being fatal, while in Xcode 13.1 and earlier it was non-fatal.

Steps to reproduce:

Install Xcode 13.2 CLI tools. Unzip attached PackageBug.zip.

cd PackageBug ; ./build.sh

Unzip attached PackageBug.zip.

Adding in --verbose, one can see that both -incremental and -whole-module-optimization are passed in as flags to swiftc. On Xcode 13.1, the line "remark: Incremental compilation has been disabled: it is not compatible with whole module optimization" is present, but it is not fatal; it only becomes fatal on Xcode 13.2, but it seems like the issue is that both -incremental and -whole-module-optimization are passed in from SwiftPM.

artemcm commented 2 years ago

jayayres (JIRA User) I can't seem to reproduce this with 13.2 (not command-line-tools).

Have you tried it with a full Xcode or with an OSS Toolchain (https://www.swift.org/download/)?

mayoff commented 2 years ago

Here's a way to reproduce it:

  1. Get a 16" MacBook Pro M1 Max.

  2. Install macOS 12.1 (21C52).

  3. Install Xcode 13.2.1.xip.

  4. Use xcode-select to select Xcode 13.2.1.

  5. git clone https://github.com/apple/swift-protobuf.git

  6. cd swift-protobuf

  7. xcrun swift build -c release --product protoc-gen-swift --arch arm64 --arch x86_64

  8. echo $?

For me, the exit status ($?) is 1, indicating failure. Note, though, that the last line of output is

100%: Build succeeded 

and indeed ./.build/apple/Products/Release/protoc-gen-swift is an apparently complete, working executable.

In my testing, I have to build for both architectures simultaneously to produce the failure. Building for just one architecture at a time does not induce failure.

swift-ci commented 2 years ago

Comment by Jay Ayres (JIRA)

I can't reproduce this from within Xcode itself. I am confirming as well, for the PackageBug.zip example, that this fails from the command line with error code 1 when I do:

swift build -c release --arch arm64 --arch x86_64

but single-architecture builds do not fail.