Skip to content

[clang] No relative path support for precompiled headers #144470

@matts1

Description

@matts1
Contributor

To reproduce:

touch a.h
clang++ -x c++-header a.h -Xclang -fmodule-file-home-is-cwd -o a.pcm
clang++ -module-file-info a.pcm | grep "Input file"    

Got: /absolute/path/to/a.h
Want: a.h

The same applies to input pcm files, though I don't have a simple reproducer for that.
When I add -fmodule-file=obj/buildtools/third_party/libc++/std/module.pcm, I find that the module info output contains Imports module 'std': /absolute/path/to/obj/buildtools/third_party/libc++/std/module.pcm

(And yes, I checked - the file itself contains absolute paths, it's not just output by the tool)

This is a problem for us, because we want to use remote execution, which requires that our paths be relative.

Activity

added
clangClang issues not falling into any other category
on Jun 17, 2025
added
clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
clang:modulesC++20 modules and Clang Header Modules
and removed
clangClang issues not falling into any other category
on Jun 17, 2025
llvmbot

llvmbot commented on Jun 17, 2025

@llvmbot
Member

@llvm/issue-subscribers-clang-driver

Author: Matt (matts1)

To reproduce: ``` touch a.h clang++ -x c++-header a.h -Xclang -fmodule-file-home-is-cwd -o a.pcm clang++ -module-file-info a.pcm | grep "Input file" ```

Got: /absolute/path/to/a.h
Want: a.h

The same applies to input pcm files, though I don't have a simple reproducer for that.
When I add -fmodule-file=obj/buildtools/third_party/libc++/std/module.pcm, I find that the module info output contains Imports module 'std': /absolute/path/to/obj/buildtools/third_party/libc++/std/module.pcm

(And yes, I checked - the file itself contains absolute paths, it's not just output by the tool)

This is a problem for us, because we want to use remote execution, which requires that our paths be relative.

llvmbot

llvmbot commented on Jun 17, 2025

@llvmbot
Member

@llvm/issue-subscribers-clang-modules

Author: Matt (matts1)

To reproduce: ``` touch a.h clang++ -x c++-header a.h -Xclang -fmodule-file-home-is-cwd -o a.pcm clang++ -module-file-info a.pcm | grep "Input file" ```

Got: /absolute/path/to/a.h
Want: a.h

The same applies to input pcm files, though I don't have a simple reproducer for that.
When I add -fmodule-file=obj/buildtools/third_party/libc++/std/module.pcm, I find that the module info output contains Imports module 'std': /absolute/path/to/obj/buildtools/third_party/libc++/std/module.pcm

(And yes, I checked - the file itself contains absolute paths, it's not just output by the tool)

This is a problem for us, because we want to use remote execution, which requires that our paths be relative.

matts1

matts1 commented on Jun 18, 2025

@matts1
ContributorAuthor

After hooking up a debugger, root cause appears to be that:

  • getEmittingModule returns null when -x c++-header is set because PP.getLangOpts().isCompilingModule() returns false.
  • This is then propogated to ASTWriter.WritingModule, which checks if WritingModule is null before configuring path normalization.

Also, I considered using relocatable precompiled headers, but looking at the documentation, they appear to serve a completely different purpose.

changed the title [-][clang] fmodule-file-home-is-cwd doesn't work[/-] [+][clang] No relative path support for precompiled headers[/+] on Jun 20, 2025
matts1

matts1 commented on Jun 20, 2025

@matts1
ContributorAuthor

I think that we should allow the use of -fmodule-file-home-is-cwd when using precompiled headers as well as modules.

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

    clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'clang:modulesC++20 modules and Clang Header Modules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @matts1@frederick-vs-ja@llvmbot

        Issue actions

          [clang] No relative path support for precompiled headers · Issue #144470 · llvm/llvm-project