https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120848

            Bug ID: 120848
           Summary: -fmodule-header -fmodules-ts -x c++-system-header
                    dives into symbolic links
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: piotr5 at netscape dot net
  Target Milestone: ---

I compiled gcc while my root directory is a bunch of symbolic links into the
directory /systemd/.
then a cpp file with 

import <print>;

will search for the module in 
gcm.cache/./systemd/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/print.gcm
whereas the command

g++ -std=c++26 -fmodule-header -fmodules-ts -x c++-system-header
/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/print

will create a file
gcm.cache/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/print.gcm
which naturally cannot be found by said sourcefile.
quick fix is to make systemd a symbolic link to ./ in gcm.cache

now the question is how to fix that bug properly.
the fix I'd prefer is if building gcc wouldn't look up link-redirection when
setting the include directories and others. but that might as well be the fault
of the gentoo build-system. next best solution is to discover the symlink and
populate gcm-cache accordingly by creating necessary reverse-symlinks. what is
a bad solution is to outright eliminate all symlinks before deciding on a
pathname inside the gcm.cache directory. recompiling gcc in a chroot
environment would render such a directory uselessly cluttered with outputs from
old version. as it is, I could provide that "resolved" path too, so there
wouldn't be any new functionality. i.e. what I want is to build the directory
structure I provide at command line and then add a symlink emulating the actual
directory structure. so if I give to the command-line the most symlink-heavy
path, partial resolving of symlink elements would still find the right file in
gcm.cache anyway...

anyway, however you approach this problem, keep in mind this is not a high
priority issue but rather a quality-of-life enhancement. if you do find a
solution, would be nice if it eventually found a way into stdlib for a future
standard as I do think other programs might struggle with similar issues in
linux filesystems...

Reply via email to