title: Is it possible to use a C++ named module without an object file?
body: <p>I'm trying to compile a simple empty module example (using gcc 11.2):</p>
  <pre><code>// my_module.cc:
  export my_module;
  
  
  // main.cc:
  import my_module;
  int main() { return 0; }
  </code></pre>
  <p>Using these compilation commands:</p>
  <pre class="lang-sh prettyprint-override"><code>g++ my_module.cc -std=c++20 -fmodules-ts -c
  g++ main.cc -std=c++20 -fmodules-ts my_module.o
  </code></pre>
  <p>This compiles fine.</p>
  <p>However, even though the module is empty, I need the module's object file (<code>my_module.o</code>) when compiling <code>main.cc</code>, because the linker wants the function <code>_ZGIW9my_moduleEv</code>. I'm assuming this function is meant to perform initialization for static variables or something similar, as it will call <code>__static_initialization_and_destruction_0</code> if I define static variables in the module.</p>
  <p>My question is, does every module really need an object file? Is there any way to mark a named module as &quot;doesn't need initialization, all my functions are inline&quot;?</p>
  <p>I think that header units could be used like this, but they're supposedly meant only as a transitory solution and have other downsides like macro hygiene.</p>