Skip to content

depfile: reconciling absolute paths with relative paths in build manifest #2721

@bradking

Description

@bradking

This issue supersedes #1251 as requested in #1251 (comment).


The ninja manual warns against mixing absolute and relative paths, but it is a serious limitation in common use cases, such as generated header files.

People often want their build systems to invoke the compiler with absolute paths to sources files and include directories. This produces output for IDEs to match error messages that reliably refer back to the original files. It also may affect paths recorded in debug information. While there may be tool-specific alternatives in some cases, this approach is simple and widely used. However, it means that depfiles report absolute paths that, in the case of generated headers, need to be reconciled with relative paths in the build manifest. Currently this does not happen.

Here is a script demonstrating the issue: ninja-bug.bash.txt

CMake currently works around this issue by naming both absolute and relative paths to the same file as outputs of the build statement producing it. It works at the cost of doubling the number of stat calls needed. However, #2667 proposes making such build statements an error. Therefore we need an alternative solution to support existing use cases.

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