<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJztV9tu4zYQ_Rr5hbAhS7EdP_jBsddoiqTbLtJd9GlBUSOLDSUKJBXbf99D6pJsdrMtWqBAgQaKZA3HM2cu5BxnOr9sHkpihVZKn2R9ZFZWjSJW6bxVZFnGLeWsMfpoeMWErhrpxUIbQ8KpCztJVzIHE1ireJ3jKwRTUbJjpT7RExnGLbNa1_550S3jeY73ilgui4IM1a63y52Elm78wzJZB7MdEAbLvZfathWMCp0TJIAM644bx5xmR81KfjlJQ7Mo3kfx9t2Z-3As08Vo2JXcAbZSTPDWwjQruFStISaLEaAM9rzHQhrrhuhY1jpWaxdWLAFNHqXbzteUbesLq7gwmuVUyJqYko_EomU83d__dr_dfXiPz4OyFxc_3-5eiH42OuOZ8kbq_qbhyFgWJde3CO2J6ihZOXxCNiRSCIyiJPHIiIuS6ZqiZO1Tf4tk-zx18uAKN2ZRLVF6BXKiT1F3Pxoi55M5E03TLwBYd4VXOjcaWe7rMepH6U23zroH2serRenOOgOFKH33WqW3ZF3IXbrtFNmR3OfB7GdHZ4egfTgdmNVgA3-GXGtqJCX5gdC3Pp5P2qg8SuaQje6i1f6bkXT3isv6zWCfo5Aa8IhXL-PoV7_OQb-MjvbW38Q_Ri50G5zgeiv8YRl1jxY7X_6_GN-u26vjvhz79JW2UBxVSm5wseknjm0xDfj2ohMmPAiUzCDDXQy6hT8ppJBuOhwWX4mmFW-8eFSYNjg2emDTM-ttTV83la8Lm-oXgkZU34D7bFh8qfvll_W_Fyniy1qpRnHDXQlrs5do2NB6HmVolLereMDR5DfHf6iK42H3fz2_rqcftmSMNn6m5q3AcJUYYBfrqML8E4jigon0xI3sx2HxVsnHAyzd4szbzvGPSea46hz4174iODSQh8-YVoVEwlbeZTehcj9mMwyZcL4khxJz2T94JbnBeXqYCQwQL-qTfbgPJne9dH738cf0435xn_764Re8P7uZJocPd-8fHh4-7a63N6HecOxH6N_zlFzfvVtc3T1crQ_76z_39J0S3ILttIFOgAcEZ5inFtB6htCNy74zpvJYa-PbAWPdj9BTKTFRBbRLUg1DvegJpaLACFDTTFE1cBfbkJCFFFAHzwAFCVasn1eeR4C9WF8KR6Ks-9KjJbDAG_JKICEYPUGsyXajH-TEkLXBvtFgIhKDnmbsXp79OTE0dKBlrwkWjRzIlrpVYDOeQbjgIfAVOgtqHPJjfA-SgZhOvRTf4ypEEgLoLHSYpB9ih9dtHqjL4BkcxhIyU6IDgMO2SGJGNbI7ohSAHVBg8H0BxGMQRobdMaZwDQ4JmgOyKUEy-zr2YaGaJxCDGftJBxpXIQW-sCHhjeFi2GgVf_QcFxs898lT3By_QX1_B9NFf6gKVIB5shKIrycB1krUe8ZuQz3AIOG5lHlONaJ1_nhgiMC2mVPkLoB7IYdadll7rPXJN0XXh0NDWa2eaEDadRNM-C7xIg6wR5_sSb5J83W65hPeulKbTdkeNa8mrVGb0rkmDIrkgOuITmizGeqAF6Wehse0jwyvoYWQ08MiTdL5pNzwxXJVZMs05kWyTjkV8SJZFhy9d51nV_lyojgSbzfR4iZa7Cf_3KXcJHGSxPP5cr5K4qtktsjilNbrdRwXy3i-iqOrGAekVDNvZ6bNcWI2wSTyYbGopHX2eRHsF61FNCB0EhXY7F78zBg4f9goQ8lDKSp5_v5Pk0kAvwnI_wAqm09b>53231</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Compilation failure with modules that mix different compilation options
        </td>
    </tr>

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

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

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

<pre>
    The following simple modules based program compiles correctly with the commands below, however as soon as you add some different compilation options in the module and the consumer code things start to go haywire.
Examples of options that will cause a failure if you add it to the first command but not the second:
- Any macro define like `-DMYMACRO`
- `-fPIC`
- Probably many many others (I haven't had time to check each one), I assume each `-f` switch, etc.

greetings.cpp
```
export module greetings;
 
import <string>;
 
export std::string get_greeting_text()
{
    return "Hello, World!";
}
```

main.cpp
```
import <iostream>;
import greetings;

int main()
{
    std::cout << get_greeting_text() << '\n';
}
```

Compile commands:
```
clang++ -Wall -std=c++2a -stdlib=libc++ -fimplicit-modules -fimplicit-module-maps -fmodules --precompile -x c++-module greetings.cpp -o greetings.pcm
clang++ -fmodules -c greetings.pcm -o greetings.o
clang++ -Wall -std=c++2a -stdlib=libc++ -fimplicit-modules -fimplicit-module-maps -fprebuilt-module-path=. greetings.o main.cpp -o main
```

Failing commands:
```
clang++ -Wall -std=c++2a -stdlib=libc++ -fimplicit-modules -fimplicit-module-maps -fmodules --precompile -x c++-module -DMYMACRO greetings.cpp -o greetings.pcm
clang++ -fmodules -c greetings.pcm -o greetings.o
clang++ -Wall -std=c++2a -stdlib=libc++ -fimplicit-modules -fimplicit-module-maps -fprebuilt-module-path=. greetings.o main.cpp -o main
```

The error produced is systematically a variation of:
```
main.cpp:2:1: fatal error: module 'std_config' is defined in both '/home/hamiard/.cache/clang/ModuleCache/1LVJ3VD5M3URQ/std_config-2FRLOTTTWC8AB.pcm' and '/home/hamiard/.cache/clang/ModuleCache/28LE54LT49FD8/std_config-2FRLOTTTWC8AB.pcm'
```

I found that clang has an option `-fmodules-ignore-macro` which can help alleviate the problem in the specific case of macros, but this is technically duct tape, it really doesn't address the root issue. Mixing modules with different compile options should be totally fine except for a very few exceptional cases, shouldn't it ?

The other compilers seem handle such benign differences fine (except for a few critical macros) so I believe clang should as well. Not to mention this practically makes building large modules based projects almost strictly impossible. Is there as hidden setting or subtlety I yet don't know of that can help solve this problem or is this a bug ?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVttu4zYQ_Rr5hbBhS3ZsP_jBsddoiqS7XaS76FNAUSOLDSUKJBXbf99D6pLLbrZFHwoUaKBI1nA0c-ZCzkl1dtncF8RyrZQ-yerIrCxrRazUWaPIspRbylht9NHwkgld1tKLhTaGhFMXdpKu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