[clang] [clang-repl] fix vtable symbol duplication error (closes #141039) (PR #185648)
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 11 09:05:13 PDT 2026
vgvassilev wrote:
> > I believe we should be looking at why this function decides to emit the vtable twice:
> > https://github.com/llvm/llvm-project/blob/3548ec95178c00a2895a65b435945ce318396c8e/clang/lib/CodeGen/CodeGenModule.cpp#L3680
> >
> > The reset happens probably here
> > https://github.com/llvm/llvm-project/blob/3548ec95178c00a2895a65b435945ce318396c8e/clang/lib/CodeGen/CodeGenModule.cpp#L8496
>
> So, consulting claude ;/, the root cause is as you suggested, and there is a ~10 line fix to address it that is a bit more intrusive than the handling in the linkage. However, it gave this helpful note: "The LinkOnceODRLinkage fix mirrors how implicit template instantiation vtables already work across TUs and is arguably the right semantic fit. The DefinedVTables tracking approach is more precise and avoids the redundant emission entirely, but is more invasive. Whether to pursue it would be a question for the upstream review."
>
> How about this: I'll add the other fix in another commit (that removes the previous fix), and if you think it is more maintainable and is arguably the correct fix so that it doesn't intersect with linkage, we can squash before approval and merge. Make sense? I'll push commit in a few minutes.
Makes sense, however, we don't want to split to codepath between incremental C++ and static compilation. The more invasive approach goes towards this goal.
https://github.com/llvm/llvm-project/pull/185648
More information about the cfe-commits
mailing list