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 -------------- next part -------------- A non-text attachment was scrubbed... Name: linkonce-mistype.patch Type: application/octet-stream Size: 4976 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080613/998021f3/attachment.obj> -------------- next part --------------
On Jun 12, 2008, at 11:56 PM, Nathan Keynes wrote:> 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.Your patch looks great, applied! http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080616/063909.html Sorry for the delay, -Chris
On 20/06/2008, at 3:30 PM, Chris Lattner wrote:> > On Jun 12, 2008, at 11:56 PM, Nathan Keynes wrote: > >> 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. > > Your patch looks great, applied! > http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080616/063909.htmlHi, 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 -------------- next part -------------- A non-text attachment was scrubbed... Name: linker-alias-error.patch Type: application/octet-stream Size: 1635 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080709/738b144d/attachment.obj> -------------- next part --------------