<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/73068>73068</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-extdef-mapping-14 doesn't mark weak symbols as weak: error: multiple definitions are found for the same key in index
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
john-carter
</td>
</tr>
</table>
<pre>
The output of clang-extdef-mapping should mark symbols that are weak as weak.
[weak.zip](https://github.com/llvm/llvm-project/files/13432613/weak.zip)
Attached is a zip file with a Makefile.
It has two c file a.c and b.c with a weak function...
`int fn( void) __attribute__((weak));
`
.. overridden by a strong function...
If you "make" the static analyzer fails with "error: multiple definitions are found for the same key in index "
```
cc -c -o main.o main.c
cc -c -o a.o a.c
cc main.o a.o -o main
clang-17 -emit-ast -o main.c.ast main.c
clang-17 -emit-ast -o a.c.ast a.c
clang-17 -emit-ast -o b.c.ast b.c
./main
weak
sed -e "s|PWD|/home/johnc/inf/weak|g" compile_commands.template > compile_commands.json
cat compile_commands.json
[
{
"file" : "main.c",
"output" : "main.o",
"arguments" : ["/usr/bin/clang-17", "-c", "main.c"],
"directory": "/home/johnc/inf/weak"
},
{
"file" : "b.c",
"output" : "b.o",
"arguments" : ["/usr/bin/clang-17", "-c", "b.c"],
"directory": "/home/johnc/inf/weak"
},
{
"file" : "a.c",
"output" : "a.o",
"arguments" : ["/usr/bin/clang-17", "-c", "a.c"],
"directory": "/home/johnc/inf/weak"
}
]
clang-extdef-mapping-17 -p . main.c a.c b.c > externalDefMap.txt
cat externalDefMap.txt
9:c:@F@main /home/johnc/inf/weak/main.c
7:c:@F@fn /home/johnc/inf/weak/a.c
7:c:@F@fn /home/johnc/inf/weak/b.c
sed -i -e 's/\.c/.c.ast/g' externalDefMap.txt
cat externalDefMap.txt
9:c:@F@main /home/johnc/inf/weak/main.c.ast
7:c:@F@fn /home/johnc/inf/weak/a.c.ast
7:c:@F@fn /home/johnc/inf/weak/b.c.ast
sed -i -e "s|/home/johnc/inf/weak/||g" externalDefMap.txt
cat externalDefMap.txt
9:c:@F@main main.c.ast
7:c:@F@fn a.c.ast
7:c:@F@fn b.c.ast
clang-17 --analyze \
-Xclang -analyzer-config -Xclang experimental-enable-naive-ctu-analysis=true \
-Xclang -analyzer-config -Xclang ctu-dir=. \
-Xclang -analyzer-output=plist-multi-file \
main.c
error: multiple definitions are found for the same key in index
error: multiple definitions are found for the same key in index
error: multiple definitions are found for the same key in index
3 errors generated.
make: *** [Makefile:4: all] Error 1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMV02PozgT_jXOpQQCk4TkkEO6M0jvYaT3sNLurVWYIngabGSbns78-pUNdJLp3s7sfKxGSviqesrlx64Po7XyqIh2bHXHVocFDq7RZvdJNyoSaByZRamr0-6PhkAPrh8c6BpEi-oY0bOrqI467HupjmAbPbQVdGgewZ66UrcWXIMO0BB8JnwEtOEes-TAkv10Xd2Fb19kz1YHxjeNc71l2Z7xgvHiKF0zlLHQHeNF2z7Nt6g3-hMJx3hRy5Ys40WaLTO-TjPGixeLfHs51t45FA1VIC0gfJE9eCx8lq4BhI_4SP79yr3_OWjQgvusQYzaGAtAVUEZixkZJlcPSjipVRzPBtaJVA5qxfgGnrSsGN_CwwM6Z2Q5OHp4YHzD-MajvaN8y7K7F-j4EMegn8gYWVWkoDwBgnVGq-Mbw43-1nDSAzDOO3wkxjm4hsA6dNK7je3pCxmoUbZ29J5xTsZow7I9dEPrZN8SVFRLJb15G1av1oOqoNZmtIYdwSOdQCqQqqJnb-RqTdfJ9AuvQgAARAIiDR1KFU838VqMsf-fBZO6_wwzfBKGLZjmEFEnXYTWvZgXsX-7GuJNZZw08X21clIrZ7WY8eLsSFi-i8lbqiAiT4ll-f3__zyw_J7xotEdMV74wBKMF1LV0z5l-f3Rr5PQXS9behC661BVNnbU9S06ApZ9eC39ZPXMBLr3xD6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