Skip to content

Compiling an unrelated executable compiles StaticBuildConfigPluginExecutable #776

@stackotter

Description

@stackotter

I'm encountering a rather annoying issue which is causing swift-java's StaticBuildConfigPluginExecutable target to be built when building unrelated SwiftPM targets that don't import anything from swift-java at all.

I believe this is a SwiftPM issue, but I figured I'd report it here first in case anyone else has encountered the issue and found a workaround.

I'll file a SwiftPM issue once I've got a more minimal reproducer.

Reproducing

Add swiftlang/swift-java to a package (without actually using it anywhere);

// swift-tools-version: 6.1

import PackageDescription

let package = Package(
    name: "SwiftJavaUser",
    platforms: [.macOS(.v10_15)],
    dependencies: [
        .package(
            url: "https://github.com/swiftlang/swift-java",
            .upToNextMinor(from: "0.4.0")
        ),
    ],
    targets: [
        .executableTarget(name: "Target"),
    ]
)

Build and run an executable target that has nothing to do with swift-java;

swift run Target

Observe that StaticBuildConfigPluginExecutable related targets (such as SwiftSyntax and Subprocess) appear in the build log, and that the target takes significantly longer to build than if you remove the unused swift-java dependency.

SwiftPM itself even states that the swift-java dependency is unused (which is a bit contradictory).

Here's a simple Swift package that reproduces the issue: SwiftJavaUser.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions