swiftlang / swiftlang/swift-java

Compiling an unrelated executable compiles StaticBuildConfigPluginExecutable

Open
#776 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

build
Dominant language
Swift
Stars
1.2k
Forks
123
Avg merge
1d 7h
Merged PRs (30d)
16

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Package.swift reproducer described in the issue, which adds swiftlang/swift-java as an unused dependency, then run swift run Target and inspect the build log. Confirm whether StaticBuildConfigPluginExecutable and related SwiftSyntax and Subprocess targets are built despite the unused dependency; the issue does not specify a repository-side fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.