https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102525
Bug ID: 102525 Summary: error: failed to read compiled module: Bad file data when trying to use modules possible 98944 regression Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: e9leyland at outlook dot com Target Milestone: --- I create the precompiled headers for the system headers, one by one $ g++ -fmodules-ts -std=c++20 -x c++-system-header concepts $ g++ -fmodules-ts -std=c++20 -x c++-system-header limits $ g++ -fmodules-ts -std=c++20 -x c++-system-header iostream I gathered up the required system headers into Reverse $ cat Reverse import <concepts>; import <limits>; import <iostream>; $ g++ -fmodules-ts -std=c++20 -x c++-header Reverse $ ls gcm.cache/, Reverse.gcm I try to import the module header $ head Reverse.cpp import <Reverse>; $ make g++ -fmodules-ts -std=c++20 -I./ -o Reverseexec Reverse.cpp In module imported at Reverse.cpp:4:1: ./Reverse: error: failed to read compiled module: Bad file data ./Reverse: note: compiled module file is ‘gcm.cache/,/Reverse.gcm’ ./Reverse: fatal error: returning to the gate for a mechanical issue compilation terminated. make: *** [Makefile:2: Reverseexec] Error 1 I change the imports in Reverse.cpp and it compiles $ head Reverse.cpp import <concepts>; import <limits>; import <iostream>; $ make g++ -fmodules-ts -std=c++20 -o Reverse Reverse.cpp I found what seems to be a related bug. [Bug c++/98944] [modules] Failed to read compiled module with a non-exported partition. StevenSun2021 at hotmail dot com via Gcc-bugs Mon, 08 Feb 2021 22:49:45 -0800 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98944 $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/11/lto-wrapper.exe Target: x86_64-pc-cygwin Configured with: /mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-11.2.0/configure --srcdir=/mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-11.2.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --with-gcc-major-version-only --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --disable-bootstrap --enable-languages=c,c++,fortran,lto,objc,obj-c++,jit --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.0 (GCC) What am I doing incorrectly? Why am I getting this error, g++ -fmodules-ts -std=c++20 -I./ -o Reverseexec Reverse.cpp In module imported at Reverse.cpp:4:1: ./Reverse: error: failed to read compiled module: Bad file data ./Reverse: note: compiled module file is ‘gcm.cache/,/Reverse.gcm’ ./Reverse: fatal error: returning to the gate for a mechanical issue compilation terminated. make: *** [Makefile:2: Reverseexec] Error 1