https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122677
--- Comment #7 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #6)
> Nathaniel, the patch above should be correct, but I'm not sure how we do
> modules testing and how to test that it fixes the problem. I assume most of
> our tests don't use absolute paths, because that would require making
> assumptions about the test environment.
>
> We could just push the fix without a test, but that doesn't make me happy.
I experimented with the following testcase in g++.dg/modules/pr122677.C, which
works on my machine (it passes with the patch and fails without it), but has
some issues:
```
// { dg-additional-options "-fmodules -fmodule-mapper=|@g++-mapper-server\\
-r\\ [srcdir]/pr122677.gcm" }
// { dg-module-cmi =[srcdir]/pr122677.gcm/M.gcm }
export module M;
```
The issues are that this relies on the GCC source directory being readable (not
necessarily true if it's been e.g. mounted on a read-only drive, I guess), and
it'll only actually fail as long as the 'pr122677.gcm' directory hasn't been
created yet; once it's been built we don't hit the error problem. So ideally
the directory should be getting deleted by DejaGnu as well once the test
passes, but I'm not sure how to do this.
Perhaps someone with more Tcl knowledge than me could find the missing bits;
and ideally this should happen in the build directory too (not the source
directory) but I also wasn't able to quickly find a way to do that.
Otherwise this may be too much effort, I think the patch looks good too and
it's probably OK without a test.