Bug 221778 - devel/libcfg: port passes flags from ${LDFLAGS} to the compiler driver and directly to ${LD} (invalid)
Summary: devel/libcfg: port passes flags from ${LDFLAGS} to the compiler driver and di...
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: Rodrigo Osorio
URL:
Keywords:
Depends on:
Blocks: 214864
  Show dependency treegraph
 
Reported: 2017-08-24 21:36 UTC by Ed Maste
Modified: 2017-12-04 17:44 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (rodrigo)


Attachments
disable lld for devel/libcfg (1.53 KB, patch)
2017-08-24 21:36 UTC, Ed Maste
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2017-08-24 21:36:32 UTC
Created attachment 185730 [details]
disable lld for devel/libcfg

In general ${LDFLAGS} contains flags for the compiler driver and should be passed to the compiler driver, not directly to the linker.

libcfg tries to use it both ways, which is invalid -- in Rules.mk.in

$(LIBDYNAMICV): $(OBJECTS)
        $(LD) $(LDFLAGS) -shared -o $@ $(OBJECTS)
..
CCLD         = $(CC)
LINK         = $(CCLD) $(CFLAGS) $(LDFLAGS) -o $@

Found while trying to link with lld as /usr/bin/ld, because lld interpreted -fstack-protector as an invalid argument:

===>  Building for libcfg-0.6.2_3
...
ar: warning: creating libcfg+.a
ld: error: unknown argument: -fstack-protector
...

Even though this appears to work with GNU ld (ld.bfd) it produces a shared object with a bogus entry:

nuc% readelf -d work/stage/usr/local/lib/libcfg+.so

Dynamic section at offset 0x92c8 contains 15 entries:
  Tag                Type                  Name/Value
 0x000000007ffffffd AUXILIARY            Auxiliary library: [stack-protector]
...
nuc%
Comment 1 Rodrigo Osorio freebsd_committer freebsd_triage 2017-12-04 17:44:12 UTC
Committed, thanks.
Comment 2 commit-hook freebsd_committer freebsd_triage 2017-12-04 17:44:45 UTC
A commit references this bug:

Author: rodrigo
Date: Mon Dec  4 17:43:55 UTC 2017
New revision: 455529
URL: https://svnweb.freebsd.org/changeset/ports/455529

Log:
  devel/libcfg: set LLD_UNSAFE

  This port passes ${LDFLAGS} to both the compiler driver and directly
  to the linker, which is not valid. Revert to using ld.bfd for now which
  produces output with a bogus entry, but does not fail to link.

  Bump portrevision.

  PR:		221778
  Submitted by:	emaste@
  Approved by:	rodrigo@ (maintainer)

Changes:
  head/devel/libcfg/Makefile