Skip to content

SwiftPM hangs indefinitely at "Planning build" on incremental builds since Swift 6.1 in some Ubuntu KVM environments #9441

@flyer2001

Description

@flyer2001

Description

SwiftPM hangs indefinitely during the "Planning build" phase on any incremental build on Linux with Swift 6.2. The issue occurs even on a
minimal fresh project created with swift package init.

Environment

  • Swift version: 6.2 (swift-6.2-RELEASE)
  • OS: Ubuntu 24.04.3 LTS (Noble Numbat)
  • Kernel: Linux 6.8.0-60-generic x86_64
  • Architecture: x86_64-unknown-linux-gnu

Steps to Reproduce

# 1. Create minimal project
cd /tmp
swift package init --type executable --name test-project
cd test-project

# 2. Initial build works fine
swift build
# Output: Build complete! (5-10 seconds)

# 3. Incremental build hangs indefinitely
swift build
# Hangs forever at "Planning build" phase, never completes

Expected Behavior

Incremental builds should complete quickly when no files have changed, similar to macOS behavior.

Actual Behavior

  • SwiftPM hangs indefinitely at "Planning build" phase
  • No output, no progress
  • Process never completes, requires kill -9
  • Happens on every incremental build attempt

Verbose Output

  $ swift build --verbose 2>&1 &
  $ sleep 10 && ps aux | grep swift-build
  # Shows process stuck at "Planning build"

What Works

✅ Initial clean build: swift build (first time)
✅ Build after full reset: swift package purge-cache && swift package reset && swift build

What Hangs

❌ Any subsequent swift build without cleaning (incremental build)
❌ swift test (same issue)
❌ swift build --target
❌ swift build -c release (release mode also hangs)
❌ swift build -Xswiftc -whole-module-optimization (doesn't help)

Workaround (Not Practical)

The only working solution is to completely reset before each build:

  pkill -9 swift 2>/dev/null || true
  swift package purge-cache
  swift package reset
  swift build

This adds 30-40 seconds to every build cycle, making development on Linux extremely slow.

Additional Context

  • Tested on both a complex project with dependencies and a minimal swift package init project
  • Issue affects all build commands, not just swift build
  • Occurs even with zero file changes between builds
  • Not specific to test targets (happens with regular executable targets too)
  • Both debug and release configurations exhibit the same behavior

Impact

This makes Swift development on Linux (CI/CD, server deployments) impractical. Every build requires a full clean rebuild taking 30-60 seconds
instead of 1-5 seconds for proper incremental builds.

Related Issues

I found similar historical reports but none specifically for Swift 6.2 on Linux:

None of these match the specific "Planning build" hang on incremental builds.

Question

Is this a known regression in Swift 6.2 on Linux? Are there environment variables or build flags that could disable/fix incremental compilation
for Linux?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions