Bug 230212

Summary: graphics/freeimage: fail to link with lld as /usr/bin/ld on i386
Product: Ports & Packages Reporter: Ed Maste <emaste>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed Unable to Reproduce    
Severity: Affects Only Me CC: ndowens04
Priority: ---    
Version: Latest   
Hardware: i386   
OS: Any   
Bug Depends on:    
Bug Blocks: 214864    

Description Ed Maste freebsd_committer freebsd_triage 2018-07-30 23:57:33 UTC
The migration to the LLVM project's lld linker as the system linker (/usr/bin/ld) for FreeBSD is in progress - it is the case for arm64 and amd64 today, and i386 will switch once ports issues are addressed - see exp-run in PR214864.

Linking graphics/freeimage with lld produces errors of the form:

/usr/bin/ld: error: can't create dynamic relocation R_386_PC32 against symbol: malloc in readonly segment; recompile object files with -fPIC
>>> defined in /lib/libc.so.7
>>> referenced by BitmapAccess.cpp
>>>               ./Source/FreeImage/BitmapAccess.o:(FreeImage_Aligned_Malloc(unsigned int, unsigned int))

/usr/bin/ld: error: can't create dynamic relocation R_386_32 against symbol: .L.str.1 in readonly segment; recompile object files with -fPIC
>>> defined in ./Source/FreeImage/BitmapAccess.o
>>> referenced by BitmapAccess.cpp
>>>               ./Source/FreeImage/BitmapAccess.o:(FreeImage_Aligned_Malloc(unsigned int, unsigned int))

http://package18.nyi.freebsd.org/data/headi386PR214864-default/2018-07-30_18h09m59s/logs/errors/freeimage-3.16.0_6.log
Comment 1 Nathan 2018-09-04 20:19:15 UTC
How do i test this and see if I can fix it?
Comment 2 Nathan 2018-09-04 20:26:15 UTC
(In reply to Nathan from comment #1)
Nevermind found out how
Comment 3 Nathan 2018-09-10 00:44:37 UTC
@Ed Can you retest this as I've updated this port since and forcing LLD as linker, I don't get an error on i386
Comment 4 Nathan 2018-09-19 13:50:31 UTC
(In reply to Nathan from comment #3)
Yup. Retested again, this time while running inside 12-386, also inside 11.2-386;  moving /usr/bin/ld.lld /usr/bin/ld I got no linker error

BTW, looks like it is compiling the code with -fPIC now

Since this bug report, port has been updated in r479150
Comment 5 Ed Maste freebsd_committer freebsd_triage 2018-09-26 16:15:54 UTC
Confirmed, head builds on i386 with lld as /usr/bin/ld now.