Skip to content

bug: Ninja object paths collide for same-basename sources with different extensions #149

Description

@aman-sharma-dev

What happened?

The Ninja backend derives object paths by replacing each source suffix with .o. Within one target, source files that share a basename but use different extensions therefore map to the same output.

For example, src/start.c and src/start.S both generate _build/obj/app/src/start.o. Ninja rejects the generated manifest because multiple build rules declare the same output, so valid mixed C and assembly targets cannot build.

Expected behavior

Object paths should retain enough of the complete source filename to remain unique while preserving target namespacing:

  • src/start.c_build/obj/app/src/start.c.o
  • src/start.S_build/obj/app/src/start.S.o

The compilation database should use the same object paths as the Ninja manifest.

Reproduction steps

  1. Define one executable target containing src/start.c and src/start.S.
  2. Generate the Ninja build manifest.
  3. Inspect the object outputs or run ninja -n.
  4. Observe that both compile rules declare _build/obj/app/src/start.o, causing Ninja to reject the manifest with a duplicate-output error.

Version or commit

Upstream master before PR #133; reproduced at the parent of commit 5cc570d

Environment

Platform-independent Ninja manifest generation. Reproduced in the Python Ninja backend tests on Windows; the generated manifest was also checked with a real Ninja dry run.

Logs or diagnostics

Submission checks

  • I searched existing issues for a duplicate.
  • This report contains no security-sensitive details.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions