https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127878
Bug ID: 127878
Summary: Module mapper file breaks makefile fragment
generation.
Product: gcc
Version: 16.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
Assignee: unassigned at gcc dot gnu.org
Reporter: joergboe at snafu dot de
Target Milestone: ---
There is one header file:
> echo '' > header.h
Translating it into a header unit cmi file:
> g++ -x c++-user-header header.h -c -std=c++20 -fmodules
> -flang-info-include-translate -flang-info-module-cmi
./header.h: note: writing CMI ‘gcm.cache/,/header.h.gcm’
One TU imports header.h and a named module:
> echo -e 'import "header.h";\nimport module;\n' > foo.cpp
Now I generate the makefile fragment:
> g++ foo.cpp -std=c++20 -fmodules -MM -flang-info-include-translate
> -flang-info-module-cmi
In module imported at foo.cpp:1:1:
./header.h: note: reading CMI ‘gcm.cache/,/header.h.gcm’
foo.o: foo.cpp gcm.cache/,/header.h.gcm
foo.o: module.c++-module ./header.h.c++-module
CXX_IMPORTS += module.c++-module ./header.h.c++-module
So far it works as expected.
Now I add a module mapper file that specifies the location of the header cmi
file:
> echo -e '$root gcm.cache\n./header.h ,/header.h.gcm' > module-mapper.modm
Generating the makefile fragment again:
> g++ foo.cpp -std=c++20 -fmodules -MM -flang-info-include-translate
> -flang-info-module-cmi -fmodule-mapper=module-mapper.modm
In module imported at foo.cpp:1:1:
./header.h: note: reading CMI ‘gcm.cache/,/header.h.gcm’
foo.cpp:2:1: fatal error: unknown compiled module interface: no such module
2 | import module;
| ^~~~~~
compilation terminated.
So it is impossible to generate the makefile fragments if the header unit cmi
files are not in the default place!