Skip to content

[SR-4127] swiftc shouldn't rebuild downstream dependencies when private API changes #46710

Open
@ddunbar

Description

@ddunbar
Previous ID SR-4127
Radar None
Original Reporter @ddunbar
Type Bug

Attachment: Download

Environment

macOS

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, IncrementalBuild
Assignee None
Priority Medium

md5: 1f0e2aac39013f6dc1f73cf999e85e6f

Issue Description:

In the following test case, the second build should not recompile or relink bazTests, because the additional function added to the source does not change the public API of baz.

This requires a couple things to be fixed:

  1. The baz.swiftmodule currently does change in the test case.
  2. The baz.o file is rewritten, even though its contents are unchanged.

Test case is attached, steps to reproduce:

$ rm -rf .build
$ swift build -c release --build-tests
Compile Swift Module 'baz' (1 sources)
Compile Swift Module 'bazTests' (1 sources)
Linking ./.build/release/bazPackageTests.xctest/Contents/MacOS/bazPackageTests
$ (for f in .build/release/baz.{swiftmodule,build/baz.swift.o}; do printf "%s -- stat hash: %s -- content hash: %s\n" ${f} $(stat ${f} | md5) $(md5 < ${f}); done)
.build/release/baz.swiftmodule -- stat hash: 51b581c0e5b03d1ac6d76d6536b6c657 -- content hash: 2a13cb88f1d5100364fe882eae166d6c
.build/release/baz.build/baz.swift.o -- stat hash: 034c99c73f4ca317f8c2177f9bbe6321 -- content hash: ae38b556a84069586ff9c359d4749915
$ printf 'private func f%d() {}\n' $(wc -c < Sources/baz.swift) >> Sources/baz.swift 
$ swift build -c release --build-tests
Compile Swift Module 'baz' (1 sources)
Compile Swift Module 'bazTests' (1 sources)
$ (for f in .build/release/baz.{swiftmodule,build/baz.swift.o}; do printf "%s -- stat hash: %s -- content hash: %s\n" ${f} $(stat ${f} | md5) $(md5 < ${f}); done)
.build/release/baz.swiftmodule -- stat hash: 8654cc82d490935f8b0781ecff4e2078 -- content hash: 6f24a013ba83f16864ad410211b4caf5
.build/release/baz.build/baz.swift.o -- stat hash: 156d28f073b62c27f66d0eb2add5b60a -- content hash: ae38b556a84069586ff9c359d4749915

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfincremental compilation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions