Type conflicts with linkonce functions

Hi,

     Currently if the linker encounters a pair of linkonce function definitions with different types, it raises an error of the form:

llvm-ld: error: Cannot link file 'item.o.bc': Function '_ZN18st_select_lex_unit12first_selectEv' defined as both ' %struct.SELECT_LEX* (%struct.SELECT_LEX_UNIT*)' and ' %struct.SELECT_LEX* (%struct.SELECT_LEX_UNIT*)'

     I encountered the above while building mysql 5.0.51a after dealing with PR1860 - some of the source files appear to have slightly different definitions of the same type name, which makes the error message especially confusing. In any case, this doesn't seem right - I would expect the link to proceed regardless of the type mismatch. The patch below is intended to change the linker behaviour in the presence of a function type mismatch to add a bitcast but otherwise continue linking as normal.

     From what I can see, global variables are already handled this way.

Cheers,
Nathan

linkonce-mistype.patch (4.86 KB)

Your patch looks great, applied!
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080616/063909.html

Sorry for the delay,

-Chris

Hi,

Thanks for that, Chris. Following on from this, there's a related issue with alias type mismatches - it looks like the type errors here are obsolete as there's already code below to add the necessary bitcasts, but I'm not 100% certain what the original intent was. Attached patch to just remove the error checks works for me, at least.

Cheers,
Nathan

linker-alias-error.patch (1.6 KB)

Yep, your patch is right, applied:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080707/064844.html

Thanks Nathan,

-Chris