[PATCH 2/2] libcpp: Avoid remapping filenames within directives

Jeff Law jeffreyalaw@gmail.com
Tue Nov 1 19:32:47 GMT 2022


On 8/17/22 06:15, Richard Purdie via Gcc-patches wrote:
> Code such as:
#include __FILE__
>
> can interact poorly with file-prefix-map options when cross compiling. In
> general you're after to remap filenames for use in target context but the
> local paths should be used to find include files at compile time. Ingoring
> filename remapping for directives is one way to avoid such failures.
>
> libcpp/ChangeLog:
>
>      * macro.cc (_cpp_builtin_macro_text): Don't remap filenames within directives

So I went back and reviewed the old PR which introduced this code.  It 
was actually the Yocto project that got this code in to begin with :-)  
There wasn't really any discussion AFAICT about whether or not to remap 
in directives that I saw in the PR.


ISTM that given the change in behavior, we should probably document that 
we don't remap in directives.  Probably doc/invoke.texi.

With suitable documentation, this should be fine.  It seems like it 
ought to be independent of the first patch in this series which adds 
support for remapping relative paths.


jeff



More information about the Gcc-patches mailing list