What we are doing in ELFTarget.h is dubious. In the file, we define
partial classes of <Arch>LinkingContexts to declare only a static member
function. We have different (complete) class definitions in other headers.
They would conflict if they exist in the same compilation unit (because
the ones defined in ELFTarget.h has only static member functions).
I don't think this is valid in C++.
Details
Diff Detail
Event Timeline
You're right - this is an ODR violation & your solution looks like it successfully corrects that.
(broader questions about an ideal architecture here - the design here seems a bit awkward - it's trying to avoid any one place including all of the FooLinkingContext.h but instead means we have a header that declares all the functions, so it loses the generality anyway. I'm not sure what a nice generalization would look like - there's always going to be some kind of "all the targets" registration point, likely)
We used to have a function containing if-else clause for each machine type to dispatch. And then it was replaced with this partial class implementation. Not sure which is better -- but I'll go with this patch for now to just convert invalid C++ code to valid code.