<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/147148>147148</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang++ requires '-x c++' with '-emit-module-interface' when compiling a .cppm file
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Iritscen
      </td>
    </tr>
</table>

<pre>
    Despite .cppm seemingly being labeled as a C++ suffix in the clang source code, clang currently requires `-x c++` to be specified when compiling a .cppm file as a module interface.  Using the invocation:

clang++ -std=c++20 -Xclang -emit-module-interface -c my_module.cppm -o my_module.pcm

causes clang to emit:
```
fatal error: module interface compilation does not support input
      file format of file
 '/var/folders/np/v5mwm5js05j85jkcx13r43900000gq/T/my_module-c11c6b.pcm':
 'Precompiled'
```

However the following invocations work:
clang -cc1 -std=c++20 -emit-module-interface my_module.cppm -o my_module.pcm

and:
clang++ -std=c++20 -Xclang -emit-module-interface -x c++ -c my_module.cppm -o my_module.pcm

and:
clang++ -std=c++20 -c my_module.cppm

The last command is not compiling the source as a .pcm, but the point is that the .cppm file is recognized as C++ without needing to be prompted with '-x c++' unless '-emit-module-interface' is used, with the exception that invoking 'clang -cc1' instead of clang++ works without the -x argument.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVM-PszYQ_Wucy4jImACbA4fsrlB76-Gr1Ftl7AG8a2w-_0iy_esrA03Sr9tqVYQUZbBn3pv3Zrj3ajCIDSmfSfm64zGM1jU_OxW8QLPrrPxoXtHPKiDsxTxP4BEnZQb9AR0qM4DmHWqUwD1weCHsmbBn8LHv1RWUgTAiCM3NAN5GJxCElUjYyxYU0Tk0QX-Aw-9ROfRAKppdQayZSEUhWOgQ_IxC9QolXEY0IOw0K50A8A1YrzSuKCYro0ZQJqDrucA9wK8-HU1glDlbwYOyhhQnQtO7QNmQZz5IUrxu5RmF7LcVaYaTCtmaOrulhkzA9PH7Gl5xZPYhMotpq8GjR7-xDhZStg1ARbeXnnoeuAZ0zjpSnP5BZGO9oAdp0YOxAXycZ-sCKDPHQOgJlmdpR2_dxAPYfvmbvhFWE9aeuSOs7a2W6DxhrZlTsJwuU_nmafn2VL69i2teuENxpOkZvhPWfiOsvVHLRJ6LqlsYsnqlkrL_4nBFiTLF_86P0NNP9oJndIsWvdXaXpIyd1U8XKx7X_NtnRci_0SXz_X4khjcyIcC_1f5m0m_bIIv1v0x23r524iguQ_JBBM3EtQq_30SUku3KVvmYNXmBboYlm-zVSaka2Hka-RhcpSHpNxg1B_rNP81yxcVRhsDGESpVvN2CLOz0xzSNKowJt0fZpbVEI1G75f4p91LZ5SH6JNLXtYkCRBeBc6LvReMyRbvqShh9d0My2XjA3KZrP3YzOQdf4OcMmZX4G6IE5qw38mmkMfiyHfY5HWZ16zMa7obm5qzg5RF1SNiySWWshQ5Ph2f-PH4xA7VTjWMspLWtMwP-bGg-yqnvSxZV8m866q8JgeKE1d6r_V52ls37JT3EZv8UOeHp92yJf2yZhnbALO0cV2TLmRdHDw5UK188PcUQQWNzSO_-5b8seM3Hf613_-xN3fR6WYMYfbJn6wlrB1UGGO3F3YirE2Itp9sdvYNRSCsXRim9bGRPDfszwAAAP__4zQO7A">