Bug 230994 - graphics/lprof-devel: fails to build with LLD 7
Summary: graphics/lprof-devel: fails to build with LLD 7
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Dmitry Marakasov
URL:
Keywords: needs-patch
Depends on:
Blocks: 214864 230355
  Show dependency treegraph
 
Reported: 2018-08-29 11:51 UTC by Jan Beich
Modified: 2018-12-28 18:16 UTC (History)
3 users (show)

See Also:
amdmi3: maintainer-feedback+


Attachments
Fix LD error; Add License (929 bytes, patch)
2018-08-29 21:09 UTC, Nathan
no flags Details | Diff
Fix LD error; Add License (910 bytes, patch)
2018-08-29 22:13 UTC, Nathan
ndowens04: maintainer-approval? (amdmi3)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2018-08-29 11:51:53 UTC
$ poudriere jail -cj clang7 -a amd64 -v projects/clang700-import -m svn+https
$ poudriere testport -j clang7 graphics/lprof-devel
[...]
ld: error: undefined symbol: write_output
>>> referenced by vinflate.c
>>>               vinflate.o:(flush_output) in archive src/argyll/libargyll.a

ld: error: undefined symbol: write_output
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_codes) in archive src/argyll/libargyll.a

ld: error: undefined symbol: write_output
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_codes) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_codes) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_codes) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_codes) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_codes) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_codes) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_codes) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_stored) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_stored) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_stored) in archive src/argyll/libargyll.a

ld: error: undefined symbol: write_output
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_stored) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_dynamic) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_dynamic) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_dynamic) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_dynamic) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_dynamic) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_dynamic) in archive src/argyll/libargyll.a

ld: error: undefined symbol: get_16bits
>>> referenced by vinflate.c
>>>               vinflate.o:(inflate_dynamic) in archive src/argyll/libargyll.a

ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
c++: error: linker command failed with exit code 1 (use -v to see invocation)

See build log: https://ptpb.pw/zSZ1
Comment 1 Jan Beich freebsd_committer freebsd_triage 2018-08-29 11:54:06 UTC
Can be worked around via LLD_UNSAFE. I can't bisect LLD commits to figure out why LLD 6 built fine.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2018-08-29 12:04:52 UTC
In order to reproduce outside of clang700-import (e.g., on 11.2) try adding the following to Makefile.local:

  BUILD_DEPENDS+=	ld.lld70:devel/llvm70
  LDFLAGS+=	-fuse-ld=${LOCALBASE}/bin/ld.lld70

Example build log: https://ptpb.pw/JAre
Comment 3 Nathan 2018-08-29 21:09:54 UTC
Created attachment 196688 [details]
Fix LD error; Add License

graphics/lprof-devel:

* Fix LD errors
* Added License while here

Tested on 12-Current and built fine
Comment 4 Jan Beich freebsd_committer freebsd_triage 2018-08-29 22:08:59 UTC
Comment on attachment 196688 [details]
Fix LD error; Add License

> +LICENSE=	GPLv3

License headers in the source contain "or (at your option) any later version" clause, so you may want to add "+" suffix i.e., LICENSE=GPLv3+.

> +LDD_UNSAFE=	yes

Typo: LDD -> LLD
Comment 5 Nathan 2018-08-29 22:13:03 UTC
Created attachment 196693 [details]
Fix LD error; Add License
Comment 6 Dmitry Marakasov freebsd_committer freebsd_triage 2018-08-30 16:38:39 UTC
Approved, please commit.
Comment 7 Nathan 2018-08-30 16:40:40 UTC
Let me try something. Think I may have found a way to not use lld_undafe
Comment 8 Nathan 2018-08-30 16:47:02 UTC
I’m not on a PC but can if you remove LLD_UNSAFE and add:
CFLAGS+= -fPIC

This fixes linker issues. Figured this out on one port I’ve been working on
Comment 9 Nathan 2018-08-30 16:48:25 UTC
Seems adding fPIC solves the linker issues on 12. Atleast on ones I’ve tried
Comment 10 Jan Beich freebsd_committer freebsd_triage 2018-08-30 17:08:52 UTC
(In reply to Nathan from comment #9)
> Seems adding fPIC solves the linker issues on 12. Atleast on ones I’ve tried

Did you use LLD 7 which hasn't landed to -CURRENT yet? -fPIC doesn't help here, see https://ptpb.pw/r0Mf (clang700-import@r338392 amd64)
Comment 11 Ed Maste freebsd_committer freebsd_triage 2018-08-30 17:13:44 UTC
(In reply to Nathan from comment #9)
Indeed, one common failure with lld is 3rd party code for a shared object that isn't compiled with -fPIC, because that implies that the output will have relocations against .text which GNU ld allows by default and lld does not.

LLD_UNSAFE=yes is a big but easy hammer for this - just revert to GNU ld.

Adding -Wl,-z,notext to LDFLAGS is a medium hammer - link with lld but allow the text relocation.

Adding -fPIC CFLAGS is the most "correct" fix but introduces code and perhaps performance changes.

Note that this is not the only type of issue that prevents use of LLD, and some software will still fail to link with LLD with -fPIC.
Comment 12 Nathan 2018-08-30 17:16:07 UTC
(In reply to Jan Beich from comment #10)
Nope I have clang 6.0.1
Comment 13 Nathan 2018-09-11 00:47:30 UTC
I added  LDFLAGS=        -fuse-ld=${LOCALBASE/bin/ld.lldd70}
to this port's Makefile, I didn't get no error on amd64 12-cur
Comment 14 commit-hook freebsd_committer freebsd_triage 2018-12-28 18:16:28 UTC
A commit references this bug:

Author: amdmi3
Date: Fri Dec 28 18:15:55 UTC 2018
New revision: 488613
URL: https://svnweb.freebsd.org/changeset/ports/488613

Log:
  - Add license
  - Fix build with LLD

  PR:		230994
  Submitted by:	ndowens@yahoo.com
  Reported by:	jbeich@FreeBSD.org

Changes:
  head/graphics/lprof-devel/Makefile