Bug 116805 - -fno-module-lazy breaks thread module when compiled after format module
Summary: -fno-module-lazy breaks thread module when compiled after format module
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 15.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: c++-modules
  Show dependency treegraph
 
Reported: 2024-09-21 18:47 UTC by Richard
Modified: 2024-09-24 01:13 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-09-24 00:00:00


Attachments
Collection of *.ii files (980.31 KB, application/x-zip-compressed)
2024-09-21 18:47 UTC, Richard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard 2024-09-21 18:47:23 UTC
Created attachment 59171 [details]
Collection of *.ii files

richard@microserver:~/scratch/broken> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/richard/gcc/lib/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --host=x86_64-pc-linux-gnu --prefix=/home/richard/gcc --enable-threads --enable-language=c,c++ --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.0.0 20240917 (experimental) (GCC) 

Issued commands below, *.ii files attached.

g++ -std=c++2b -fmodules-ts -fconcepts -fno-module-lazy -Wall -O3 -g -fPIC -save-temps -x c++-system-header format
g++ -std=c++2b -fmodules-ts -fconcepts -fno-module-lazy -Wall -O3 -g -fPIC -save-temps -x c++-system-header thread
g++ -std=c++2b -fmodules-ts -fconcepts -fno-module-lazy -Wall -O3 -g -fPIC -save-temps -c -o ex2.o -x c++ ex2.ixx
In module imported at ex2.ixx:3:1:
/home/richard/gcc/include/c++/15.0.0/thread: error: failed to read compiled module cluster 1884: Bad file data
/home/richard/gcc/include/c++/15.0.0/thread: note: compiled module file is ‘gcm.cache/./home/richard/gcc/include/c++/15.0.0/thread.gcm’
/home/richard/gcc/include/c++/15.0.0/thread: error: failed to read compiled module: Bad file data
/home/richard/gcc/include/c++/15.0.0/thread: fatal error: returning to the gate for a mechanical issue
compilation terminated.
make: *** [Makefile:80: ex2.o] Error 1

Source code:

export module sorttools.sorts:foobar;

import <thread>;

export namespace sorttools::sorts::foobar {

  class Pieces {
  public:        
    std::jthread hello{};
  };
  
}


On 15.0.0 removing the -fno-module-lazy flag will allow this to compile, as does swapping the order of format/thread.
Comment 1 Nathaniel Shead 2024-09-24 01:13:05 UTC
Confirmed.  I suspect this is a similar issue to PR114630, given it fails at the same point where Patrick's proposed workaround in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114630#c7 affects.