Skip to content

SwiftPM does not rebuild modules after upgrading toolchain #9350

@jmschonfeld

Description

@jmschonfeld

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

I have a checkout of a package that was previously built and I upgraded my toolchain to a newer version. After upgrading the toolchain, I ran swift test again, and the build failed because modules were not rebuilt.

Expected behavior

SwiftPM should see that the build folder was built with an outdated compiler version and needs to rebuild swift modules that aren't ABI stable.

Actual behavior

SwiftPM build fails with:

<unknown>:0: error: compiled module was created by an older version of the compiler; rebuild 'FoundationEssentials' and try again: C:\Users\jmschonfeld\Documents\Repos\swift-foundation\.build\aarch64-unknown-windows-msvc\debug\Modules-tool\FoundationEssentials.swiftmodule
<unknown>:0: error: compiled module was created by an older version of the compiler; rebuild 'FoundationEssentials' and try again: C:\Users\jmschonfeld\Documents\Repos\swift-foundation\.build\aarch64-unknown-windows-msvc\debug\Modules-tool\FoundationEssentials.swiftmodule
<unknown>:0: error: compiled module was created by an older version of the compiler; rebuild 'FoundationEssentials' and try again: C:\Users\jmschonfeld\Documents\Repos\swift-foundation\.build\aarch64-unknown-windows-msvc\debug\Modules-tool\FoundationEssentials.swiftmodule
<unknown>:0: error: compiled module was created by an older version of the compiler; rebuild 'FoundationEssentials' and try again: C:\Users\jmschonfeld\Documents\Repos\swift-foundation\.build\aarch64-unknown-windows-msvc\debug\Modules-tool\FoundationEssentials.swiftmodule
<unknown>:0: error: compiled module was created by an older version of the compiler; rebuild 'FoundationEssentials' and try again: C:\Users\jmschonfeld\Documents\Repos\swift-foundation\.build\aarch64-unknown-windows-msvc\debug\Modules-tool\FoundationEssentials.swiftmodule
<unknown>:0: error: compiled module was created by an older version of the compiler; rebuild 'FoundationEssentials' and try again: C:\Users\jmschonfeld\Documents\Repos\swift-foundation\.build\aarch64-unknown-windows-msvc\debug\Modules-tool\FoundationEssentials.swiftmodule
error: emit-module command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: compiled module was created by an older version of the compiler; rebuild 'FoundationEssentials' and try again: C:\Users\jmschonfeld\Documents\Repos\swift-foundation\.build\aarch64-unknown-windows-msvc\debug\Modules-tool\FoundationEssentials.swiftmodule
<unknown>:0: error: compiled module was created by an older version of the compiler; rebuild 'FoundationEssentials' and try again: C:\Users\jmschonfeld\Documents\Repos\swift-foundation\.build\aarch64-unknown-windows-msvc\debug\Modules-tool\FoundationEssentials.swiftmodule

And then appears to hang

Steps to reproduce

  1. Checkout a package
  2. swift test
  3. Upgrade your toolchain
  4. swift test

Swift Package Manager version/commit hash

October 28th Swift 6.2 development snapshot

Swift & OS version (output of swift --version ; uname -a)

Swift version 6.2-dev (LLVM aeffdf35e6603d0, Swift 678ec6ec6001c6a)
Target: aarch64-unknown-windows-msvc
Build config: +assertions

on a Windows 11 VM (but uname -a does not exist on platforms like Windows)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions