Skip to content

Incremental static-library builds retain removed source objects #136

Description

@alz458

Incremental static-library builds retain removed source objects

When a source is removed from a static-library target and deleted from disk, rebuilding can retain its old object in the archive. An application that references its function can still link, while a clean build fails.

Reproduced on macOS with Python 3.13 at commit 76970c97c67f3c14c627e4420c0a3f02b6de66ed:

  1. Define a static library containing keep.c and removed.c, and an executable that depends on the library and calls a function in removed.c.
  2. Build successfully.
  3. Delete removed.c and remove it from the target's sources.
  4. Rebuild in the existing build directory: the executable still links.
  5. Build into a fresh directory: linking correctly fails because the function is missing.

Expected: both builds reject the reference to the removed function.
Actual: ar t shows removed.o still in the incrementally rebuilt archive.

The generated ar rcs $out $in command updates supplied members but retains omitted members. Recreating the archive when its Ninja edge runs resolves this inconsistency.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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