Trying CTU: error: multiple definitions are found for the same key in index

So I’m trying to use Cross Translation Unit Static Analysis as described in 2.1. Cross Translation Unit (CTU) Analysis — Clang 18.0.0git documentation

I believe I have correctly done the emit-ast and clang-extdef-mapping steps, it fails on the step “/usr/bin/clang++ --analyze -Xclang -analyzer-config -Xclang experimental-enable-naive-ctu-analysis=true -Xclang -analyzer-config -Xclang ctu-dir=. -Xclang -analyzer-output=plist-multi-file”

It fails with 'too many errors emitted" of the type “error: multiple definitions are found for the same key in index”

I am using clang --version
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

I’m not using CodeChecker as my project has a very complex structure.

Any suggestions on how to solve this?

I think I have a clue… the output externalDefMap.txt does indeed have, and indeed should have, multiple keys.

As some symbols are weak versions and some are strong.

Uh, that seems like a bug to me.
We should allow dupes for weak symbols.
Thanks for looking into this!

1 Like

Thanks,

Would it help if I make a formal bug report?

I suspect it will need a change to the output format to indicate such attributes.

Yes, I think so.
Please include steps to reproduce and with a short example triggering the issue.
I’m not sure when and who will fix it so better have a formal repro.

Did so clang-extdef-mapping-17 doesn't mark weak symbols as weak: error: multiple definitions are found for the same key in index · Issue #73068 · llvm/llvm-project · GitHub

…I’m not sure how to label it as static-analyzer though.