<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54269>54269</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[C++20] [Modules] Multiple definition in partitions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20,
clang:modules
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ChuanqiXu9
</td>
</tr>
</table>
<pre>
The following example would cause a multiple definition bug:
```
// mod.cppm
export module mod;
export import :parta;
export int useimpl() {
return a();
}
// parta.cppm
export module mod:parta;
export int a() {
return 3;
}
// main.cpp
#include <iostream>
import mod;
int main() {
std::cout << useimpl() << "\n";
}
```
And run the following command:
```
clang++ -std=c++20 --precompile -fprebuilt-module-path=. -c parta.cppm -o mod-parta.pcm
clang++ -std=c++20 --precompile -fprebuilt-module-path=. -c mod.cppm -o mod.pcm -fmodule-file=mod-parta.pcm
clang++ -std=c++20 -fprebuilt-module-path=. main.cpp mod.pcm mod-parta.pcm
```
It would show a multiple definition error:
```
/usr/bin/ld: /tmp/mod-b8409e.o: in function `a()':
mod.pcm:(.text+0x0): multiple definition of `a()'; /tmp/main-624958.o:main.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/mod-parta-31e801.o: in function `a()':
mod-parta.pcm:(.text+0x0): multiple definition of `a()'; /tmp/main-624958.o:main.cpp:(.text+0x0): first defined here
```
@urnathan @iains
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNVU2PmzAQ_TXmYoHAQEIOHPLRSD3srYdeDZjgytjUH93033dsSJrdTbZdqYdGFmY85s2b5xmnUd3P-svAcK-EUM9cnjA703ESDD8rJzrcUmcYpnh0wnK_3LGeS265krhxJ5RvUXpA6Rat0mXMJjnCwKPqknaaxnmRnSelrV90AAQTyncvPHwME4BOVFv6xi0tBjawSyBSIbLBaL3swPDTzDotMZ1914_R-rC83DILAd7n9orEGyr0HRL5H8KPlEsf_bKYc9kK1zHIfc-VsZrREeWfZvciy61giwNYeKR7RIz1KcBolfOS7mG8Vm9eRISgci_99Jb0q2MNz63ssHYS2xd106pxpLJ7VBGtoPKEyA4GjgO5QzubJMVxPGkGABMH8eMejMZxYeP5OOKJ2gH2Jzhubw4Ox8prEs8rUzv-20CX2l3C-ADwxbKxh-9h44fDP454qYhrrDvYd0_js11a1Qzq-UGnMq2VfqdXndHwbHwlHYU_QiiKox0neHoaTVWkG5Yo7-AS9062ARYgLt1G1lf4JQFvkyqx7Gwh-fSchqbc3uWn-tdYuxsGoEy8IsWmrAKFa-88CNBzbeyMzjo8MM3-Ns8gd5xnrEqzD2R7c0z_Xc73KgYVKdxRUHgUkipSDtgGR12dd5t8QyPLrWA1Knf7S92i8oDBfgola7z1dCch0MoLEQwTOS3qwdrJBMr-0jtxO7gmge7z6osflwlaUn1jLSR05MY4CECOZUFWm2ioqzbbsKJpylVWleWqb6qeZDRr24z2Wca6SNCGCePZwv11bTR_l5Fws83tmG_Hhbu_6w4Rr0lKSJqnVZblRbpOepoXAJ_nhOQU3kAWBpqLxBNMlD5Fug5c4T_PgFNwY81vJzWGnyQLqnl86uygdL0fHJXf-Ve3iUJmdUjrF4aOMvY">