Bug 212987 - [exp-run] Mk/Uses/localbase.mk: set LIBS instead of LDFLAGS
Summary: [exp-run] Mk/Uses/localbase.mk: set LIBS instead of LDFLAGS
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Tijl Coosemans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-25 16:23 UTC by Tijl Coosemans
Modified: 2016-10-02 21:06 UTC (History)
2 users (show)

See Also:


Attachments
patch (2.32 KB, patch)
2016-09-25 16:23 UTC, Tijl Coosemans
no flags Details | Diff
patch2 (19.13 KB, patch)
2016-09-26 13:53 UTC, Tijl Coosemans
no flags Details | Diff
patch3 (26.88 KB, patch)
2016-09-27 13:15 UTC, Tijl Coosemans
no flags Details | Diff
patch4 (26.85 KB, patch)
2016-09-27 19:51 UTC, Tijl Coosemans
no flags Details | Diff
patch5 (30.01 KB, patch)
2016-09-28 13:05 UTC, Tijl Coosemans
no flags Details | Diff
patch6 (33.07 KB, patch)
2016-09-29 16:42 UTC, Tijl Coosemans
no flags Details | Diff
patch7 (36.93 KB, patch)
2016-09-29 20:59 UTC, Tijl Coosemans
no flags Details | Diff
Proposed patch (since 423014 revision) (868 bytes, patch)
2016-10-02 00:13 UTC, lightside
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tijl Coosemans freebsd_committer freebsd_triage 2016-09-25 16:23:18 UTC
Created attachment 175159 [details]
patch

USES=localbase currently adds -L${LOCALBASE}/lib to LDFLAGS but normally LDFLAGS appears too early on the command line causing some ports to link with their own libraries in LOCALBASE (if installed) instead of WRKSRC.  An example is databases/firebird25-client.  In its build log you can see -L${LOCALBASE}/lib appear before all other -L flags.

The attached patch sets LIBS instead and allows LDFLAGS to be set with USES=localbase:ldflags.  It also makes use of _USES_POST so -L${LOCALBASE}/lib is added as late as possible after anything a port Makefile might add.  This also allows things like 'USES=libedit localbase:ldflags' to work correctly.

An exp-run is needed to flush out ports that don't support LIBS.
Comment 2 Antoine Brodin freebsd_committer freebsd_triage 2016-09-26 09:42:18 UTC
New failures:

+ {"origin"=>"archivers/pigz", "pkgname"=>"pigz-2.3.3_1", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"audio/fplib", "pkgname"=>"fplib-20121001_3", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"audio/listener", "pkgname"=>"listener-2.2_1", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"benchmarks/glmark2", "pkgname"=>"glmark2-2014.03", "phase"=>"configure", "errortype"=>"configure_error"}
+ {"origin"=>"databases/rocksdb", "pkgname"=>"rocksdb-4.6.1", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"devel/efivar", "pkgname"=>"efivar-0.15", "phase"=>"build", "errortype"=>"makefile"}
+ {"origin"=>"dns/dnscrypt-wrapper", "pkgname"=>"dnscrypt-wrapper-0.2.1_3", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"ftp/twoftpd", "pkgname"=>"twoftpd-1.42_1", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"games/corewars", "pkgname"=>"corewars-0.9.13_5", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"games/endless-sky", "pkgname"=>"endless-sky-0.9.2", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"games/motogt", "pkgname"=>"motogt-20110505_6", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"games/nighthawk", "pkgname"=>"nighthawk-3.0.0_4", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"graphics/bmeps", "pkgname"=>"bmpp-4.3.6", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"graphics/lcms", "pkgname"=>"lcms-1.19_6,1", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"graphics/lcms2", "pkgname"=>"lcms2-2.7_2", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"graphics/libprojectm", "pkgname"=>"libprojectM-2.0.1_3", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"graphics/pngrewrite", "pkgname"=>"pngrewrite-1.4.0_2", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"graphics/py-ming", "pkgname"=>"py27-ming-0.4.7_1", "phase"=>"configure", "errortype"=>"configure_error"}
+ {"origin"=>"mail/neomutt", "pkgname"=>"neomutt-20160916", "phase"=>"configure", "errortype"=>"configure_error"}
+ {"origin"=>"misc/getopt", "pkgname"=>"getopt-1.1.6", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"multimedia/oqtencoder", "pkgname"=>"OQTEncoder-0.1_6", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"net-p2p/transmission-cli", "pkgname"=>"transmission-cli-2.92", "phase"=>"build", "errortype"=>"missing_header"}
+ {"origin"=>"net-p2p/transmission-daemon", "pkgname"=>"transmission-daemon-2.92", "phase"=>"build", "errortype"=>"missing_header"}
+ {"origin"=>"net/gnu-dico", "pkgname"=>"gnu-dico-2.3", "phase"=>"package", "errortype"=>"???"}
+ {"origin"=>"net/ldap2dns", "pkgname"=>"ldap2dns-0.4.2_2", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"sysutils/fusefs-unionfs", "pkgname"=>"fusefs-unionfs-1.0", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"sysutils/pciutils", "pkgname"=>"pciutils-3.5.1", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"sysutils/xen-tools", "pkgname"=>"xen-tools-4.7.0_4", "phase"=>"build", "errortype"=>"linker_error"}


Failure logs:

http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/pigz-2.3.3_1.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/fplib-20121001_3.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/listener-2.2_1.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/glmark2-2014.03.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/rocksdb-4.6.1.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/efivar-0.15.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/dnscrypt-wrapper-0.2.1_3.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/twoftpd-1.42_1.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/corewars-0.9.13_5.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/endless-sky-0.9.2.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/motogt-20110505_6.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/nighthawk-3.0.0_4.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/bmpp-4.3.6.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/lcms-1.19_6,1.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/lcms2-2.7_2.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/libprojectM-2.0.1_3.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/pngrewrite-1.4.0_2.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/py27-ming-0.4.7_1.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/neomutt-20160916.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/getopt-1.1.6.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/OQTEncoder-0.1_6.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/transmission-cli-2.92.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/transmission-daemon-2.92.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/gnu-dico-2.3.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/ldap2dns-0.4.2_2.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/fusefs-unionfs-1.0.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/pciutils-3.5.1.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-25_19h17m10s/logs/errors/xen-tools-4.7.0_4.log
Comment 3 Tijl Coosemans freebsd_committer freebsd_triage 2016-09-26 13:53:04 UTC
Created attachment 175178 [details]
patch2

Add :ldflags or fix problems with LIBS.
Comment 4 Antoine Brodin freebsd_committer freebsd_triage 2016-09-27 08:31:27 UTC
New failures:

+ {"origin"=>"deskutils/fbreader", "pkgname"=>"fbreader-0.99.6_2", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"deskutils/owncloudclient", "pkgname"=>"owncloudclient-2.2.3", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"games/vegastrike", "pkgname"=>"vegastrike-0.5.1.r1_4", "phase"=>"configure", "errortype"=>"configure_error"}
+ {"origin"=>"graphics/dcraw", "pkgname"=>"dcraw-9.26", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"graphics/poppler-qt4", "pkgname"=>"poppler-qt4-0.46.0", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"graphics/poppler-qt5", "pkgname"=>"poppler-qt5-0.46.0", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"graphics/poppler-utils", "pkgname"=>"poppler-utils-0.46.0", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"mail/wmmaiload", "pkgname"=>"wmmaiload-2.3.0", "phase"=>"stage", "errortype"=>"linker_error"}
+ {"origin"=>"multimedia/lives", "pkgname"=>"lives-2.8.0", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"net-mgmt/ettercap", "pkgname"=>"ettercap-0.8.2,1", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"net-p2p/gtk-gnutella", "pkgname"=>"gtk-gnutella-1.1.10", "phase"=>"package", "errortype"=>"???"}
+ {"origin"=>"x11/qterminal", "pkgname"=>"qterminal-0.6.0", "phase"=>"build", "errortype"=>"linker_error"}


Failure logs:

http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-26_14h33m03s/logs/errors/fbreader-0.99.6_2.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-26_14h33m03s/logs/errors/owncloudclient-2.2.3.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-26_14h33m03s/logs/errors/vegastrike-0.5.1.r1_4.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-26_14h33m03s/logs/errors/dcraw-9.26.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-26_14h33m03s/logs/errors/poppler-qt4-0.46.0.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-26_14h33m03s/logs/errors/poppler-qt5-0.46.0.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-26_14h33m03s/logs/errors/poppler-utils-0.46.0.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-26_14h33m03s/logs/errors/wmmaiload-2.3.0.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-26_14h33m03s/logs/errors/lives-2.8.0.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-26_14h33m03s/logs/errors/ettercap-0.8.2,1.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-26_14h33m03s/logs/errors/gtk-gnutella-1.1.10.log
http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-26_14h33m03s/logs/errors/qterminal-0.6.0.log
Comment 5 Tijl Coosemans freebsd_committer freebsd_triage 2016-09-27 13:15:51 UTC
Created attachment 175196 [details]
patch3

Add :ldflags or fix problems with LIBS.
Comment 6 Antoine Brodin freebsd_committer freebsd_triage 2016-09-27 16:56:15 UTC
New failure:

+ {"origin"=>"games/vegastrike", "pkgname"=>"vegastrike-0.5.1.r1_4", "phase"=>"configure", "errortype"=>"configure_error"}


Failure log:

http://package18.nyi.freebsd.org/data/110amd64-default-PR212987/2016-09-27_13h47m54s/logs/errors/vegastrike-0.5.1.r1_4.log
Comment 7 Tijl Coosemans freebsd_committer freebsd_triage 2016-09-27 19:51:22 UTC
Created attachment 175201 [details]
patch4

Switch vegastrike to :ldflags.
Comment 8 Antoine Brodin freebsd_committer freebsd_triage 2016-09-28 05:43:15 UTC
A few issues I noticed:

- archivers/unmakeself no longer uses libarchive from ports
- net/axa no longer uses libedit from ports
- security/ike no longer uses libedit from ports
- net/ntp and net/ntp-devel no longer use libmd5 from ports
- multimedia/mpv no longer uses libenca and libjpeg
Comment 9 Tijl Coosemans freebsd_committer freebsd_triage 2016-09-28 13:05:52 UTC
Created attachment 175226 [details]
patch5

Add :ldflags or fix problems with LIBS.
Comment 10 Antoine Brodin freebsd_committer freebsd_triage 2016-09-29 11:41:26 UTC
I have this extra failure on 11.0 i386:

http://package18.nyi.freebsd.org/data/110i386-default-PR212987/2016-09-28_13h17m59s/logs/errors/ppsspp-1.3_1.log
Comment 11 Antoine Brodin freebsd_committer freebsd_triage 2016-09-29 13:56:25 UTC
New failures on 9.3 i386:

+ {"origin"=>"devel/sdl20", "pkgname"=>"sdl2-2.0.4", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"graphics/dcp2icc", "pkgname"=>"dcp2icc-0.1_1", "phase"=>"build", "errortype"=>"linker_error"}
+ {"origin"=>"mail/libetpan", "pkgname"=>"libetpan-1.7.2", "phase"=>"build", "errortype"=>"compiler_error"}
+ {"origin"=>"math/asymptote", "pkgname"=>"asymptote-2.37", "phase"=>"build", "errortype"=>"coredump"}

Failure logs:

http://package22.nyi.freebsd.org/data/93i386-default-PR212987/2016-09-29_12h24m04s/logs/errors/sdl2-2.0.4.log
http://package22.nyi.freebsd.org/data/93i386-default-PR212987/2016-09-29_12h24m04s/logs/errors/dcp2icc-0.1_1.log
http://package22.nyi.freebsd.org/data/93i386-default-PR212987/2016-09-29_12h24m04s/logs/errors/libetpan-1.7.2.log
http://package22.nyi.freebsd.org/data/93i386-default-PR212987/2016-09-29_12h24m04s/logs/errors/asymptote-2.37.log
Comment 13 Tijl Coosemans freebsd_committer freebsd_triage 2016-09-29 16:42:42 UTC
Created attachment 175276 [details]
patch6

Add :ldflags or fix problems with LIBS.

I haven't figured out the problem with math/asymptote on FreeBSD 9 i386.  It doesn't use localbase nor do any of its direct dependencies.  Are there any differences in linked libraries on FreeBSD 9 like you found on FreeBSD 11?
Comment 14 Antoine Brodin freebsd_committer freebsd_triage 2016-09-29 17:23:34 UTC
editors/texmacs no longer links against libiconv.so.2 on 9.3 i386

net/ocserv no longer links against libintl.so.8 on 9.3 i386

The rest looks similar
Comment 15 Tijl Coosemans freebsd_committer freebsd_triage 2016-09-29 20:59:45 UTC
Created attachment 175284 [details]
patch7

- Fix texmacs to link with libiconv
- Remove gettext dependency from ocserv.  It is configured with --disable-nls and doesn't need libintl.
Comment 16 Antoine Brodin freebsd_committer freebsd_triage 2016-09-30 18:35:47 UTC
Exp-run looks fine
Comment 17 commit-hook freebsd_committer freebsd_triage 2016-09-30 19:24:48 UTC
A commit references this bug:

Author: tijl
Date: Fri Sep 30 19:24:37 UTC 2016
New revision: 423014
URL: https://svnweb.freebsd.org/changeset/ports/423014

Log:
  Let USES=localbase add -L${LOCALBASE}/lib to LIBS instead of LDFLAGS.
  USES=localbase:ldflags can be used to set LDFLAGS.  Normally LDFLAGS
  appears too early on the command line causing some ports to link with
  their own libraries in LOCALBASE (if installed) instead of WRKSRC.

  Also make use of _USES_POST so -L${LOCALBASE}/lib is added as late as
  possible after anything a port Makefile might set.  Use _USES_POST
  instead of .include in libedit.mk and libarchive.mk so things like
  'USES=libedit localbase:ldflags' work correctly.

  Fix some issues with LIBS in some ports.

  Switch ports that don't support LIBS to localbase:ldflags.

  PR:		212987
  Exp-run by:	antoine
  Approved by:	portmgr (antoine)

Changes:
  head/Mk/Uses/libarchive.mk
  head/Mk/Uses/libedit.mk
  head/Mk/Uses/localbase.mk
  head/archivers/pigz/Makefile
  head/archivers/unmakeself/Makefile
  head/audio/fplib/Makefile
  head/audio/listener/Makefile
  head/benchmarks/glmark2/Makefile
  head/databases/firebird25-server/Makefile
  head/databases/rocksdb/Makefile
  head/deskutils/fbreader/Makefile
  head/deskutils/owncloudclient/Makefile
  head/devel/efivar/files/patch-Make.rules
  head/devel/efivar/files/patch-src-Makefile
  head/devel/efivar/files/patch-src-test-Makefile
  head/devel/sdl20/Makefile
  head/dns/dnscrypt-wrapper/Makefile
  head/editors/texmacs/Makefile
  head/emulators/ppsspp/Makefile
  head/ftp/twoftpd/Makefile
  head/games/corewars/Makefile
  head/games/endless-sky/Makefile
  head/games/motogt/Makefile
  head/games/nighthawk/Makefile
  head/games/vegastrike/Makefile
  head/graphics/bmeps/Makefile
  head/graphics/dcp2icc/Makefile
  head/graphics/dcraw/Makefile
  head/graphics/lcms/Makefile
  head/graphics/lcms2/Makefile
  head/graphics/libprojectm/Makefile
  head/graphics/pngrewrite/Makefile
  head/graphics/poppler/files/patch-configure
  head/graphics/py-ming/Makefile
  head/mail/libetpan/files/
  head/mail/libetpan/files/patch-configure.ac
  head/mail/neomutt/Makefile
  head/mail/wmmaiload/Makefile
  head/misc/getopt/Makefile
  head/multimedia/lives/Makefile
  head/multimedia/mpv/Makefile
  head/multimedia/oqtencoder/Makefile
  head/net/axa/Makefile
  head/net/gnu-dico/Makefile
  head/net/ldap2dns/Makefile
  head/net/ntp/Makefile
  head/net/ntp-devel/Makefile
  head/net/ocserv/Makefile
  head/net/ocserv/files/patch-configure.ac
  head/net/ocserv/files/patch-libopts_m4_libopts.m4
  head/net-mgmt/ettercap/Makefile
  head/net-p2p/gtk-gnutella/Makefile
  head/net-p2p/transmission-cli/files/patch-configure
  head/net-p2p/transmission-cli/files/patch-daemon_Makefile.in
  head/security/ike/Makefile
  head/sysutils/android-file-transfer/Makefile
  head/sysutils/fusefs-unionfs/Makefile
  head/sysutils/pciutils/Makefile
  head/sysutils/xen-tools/Makefile
  head/x11/qterminal/Makefile
Comment 18 lightside 2016-10-02 00:13:32 UTC
Created attachment 175352 [details]
Proposed patch (since 423014 revision)

In my opinion, this proposal about "set LIBS instead of LDFLAGS" is wrong, because it based on half-truth:
(comment #0):
> USES=localbase currently adds -L${LOCALBASE}/lib to LDFLAGS but normally
> LDFLAGS appears too early on the command line causing some ports to link with
> their own libraries in LOCALBASE (if installed) instead of WRKSRC.  An example
> is databases/firebird25-client.  In its build log you can see
> -L${LOCALBASE}/lib appear before all other -L flags.

For example, based on ports in /usr/ports/audio directory:
-8<--
% cd /usr/ports && find audio/*/Makefile | xargs grep -e "^LIBS.*LOCALBASE}/lib"
audio/adplay/Makefile:LIBS+=		-L${LOCALBASE}/lib -lbinio
audio/ario/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/deadbeef/Makefile:LIBS+=		-L${LOCALBASE}/lib -lexecinfo -lintl
audio/easytag/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/extace/Makefile:LIBS+=		-L${LOCALBASE}/lib -lm
audio/firefly/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/gbemol/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/gmpc-alarm/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/gmpc-discogs/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/gmpc-lastfm/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/gmpc-lyricwiki/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/gmpc-mdcover/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/gmpc-shout/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/gnomoradio/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/gqmpeg/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/gqradio/Makefile:LIBS+=		-L${LOCALBASE}/lib -lm -lX11
audio/gvolwheel/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/jack-rack/Makefile:LIBS+=		-L${LOCALBASE}/lib -lm
audio/jack/Makefile:LIBS+=		-L${LOCALBASE}/lib -L${BDB_LIB_DIR}
audio/libcddb/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/mp3plot/Makefile:LIBS+=		-L${LOCALBASE}/lib -lboost_system
audio/paprefs/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/pms/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/rhythmbox/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/ripperx/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/rplay/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/spiralsynthmodular/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/volumeicon/Makefile:LIBS+=		-L${LOCALBASE}/lib
audio/wavpack/Makefile:LIBS+=		-L${LOCALBASE}/lib
-->8-

The other part of truth is LDFLAGS usage:
-8<--
% cd /usr/ports && find audio/*/Makefile | xargs grep -e "^LDFLAGS.*LOCALBASE}/lib"
audio/audiere/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/aumix/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/beast/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/blop/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/calf/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/denemo/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/dssi/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/ecasound/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib -pthread
audio/ezstream/Makefile:LDFLAGS+=	-lpthread -L${LOCALBASE}/lib
audio/faac/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/faad/Makefile:LDFLAGS+=	-lpthread -L${LOCALBASE}/lib
audio/freealut/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/ghostess/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/gigedit/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/glame/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib -lltdl
audio/gmpc-mserver/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/gmtp/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/gnome-media/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/gnome-music/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/gogglesmm/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib -pthread
audio/goobox/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/grip/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/gspeakers/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/gtick/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/gtkpod/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/icecast-kh/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/id3lib/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/idjc/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/julius/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib ${ICONV_LIB}
audio/ksmp3play/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/lash/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/last.fm/Makefile:LDFLAGS+=	-lz -L${LOCALBASE}/lib -lX11
audio/libcanberra/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/libebur128/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/libgig/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/libmp3splt/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/libnjb/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/libofa/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/libshairport/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/lingot/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/linuxsampler/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/madplay/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib -lz
audio/mate-media/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/milkytracker/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/mixer.app/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib -lXpm -lXext -lX11
audio/mixmos/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/moc/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib -L${BDB_LIB_DIR}
audio/mp-player/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib -lmikmod -lpthread -lncurses -lpanel
audio/mp3blaster/Makefile:LDFLAGS+=	-lpthread -L${LOCALBASE}/lib
audio/mp3splt-gtk/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/mp3splt/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/mp3stat/Makefile:LDFLAGS+=	-Wl,--rpath,${LOCALBASE}/lib
audio/mpg321/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/mpiosh/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib ${ICONV_LIB}
audio/muse/Makefile:LDFLAGS+=	-lpthread -L${LOCALBASE}/lib -lintl
audio/musicbox-tag-editor/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/musicpd/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib -L${LOCALBASE}/lib/sidplay/builders
audio/normalize/Makefile:LDFLAGS+=		-L${LOCALBASE}/lib
audio/ocp/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/openal/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/osalp/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/pd/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib -pthread
audio/pianobar/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/pidgin-musictracker/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/playgsf/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/pocketsphinx/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/portaudio/Makefile:LDFLAGS+=	-lpthread -L${LOCALBASE}/lib
audio/pulseaudio/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/py-pyliblo/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/rosegarden/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/rubberband/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/scrobbler/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/sdl_mixer/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/sdl_sound/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/smasher/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/snd/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/sooperlooper/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/sound-juicer/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/soundtracker/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/sox/Makefile:LDFLAGS+=	-lpthread -L${LOCALBASE}/lib
audio/sphinx3/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/sphinxbase/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/streamripper/Makefile:LDFLAGS+=	-Lcdk-${CDK_VERSION} -L${LOCALBASE}/lib
audio/streamtranscoder/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/sweep/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/swhplugins/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/tagtool/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib -lpthread -logg -lm
audio/terminatorx/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/timidity++/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib -Wl,--export-dynamic
audio/umodplayer/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/umurmur/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/vorbis-tools/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/vorbisgain/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/whysynth/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/xhippo/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/xmixer/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib -lX11
audio/xmms-ahx/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/xmms-flac/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/xmms-wavpack/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/xmp/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/xsynth-dssi/Makefile:LDFLAGS+=	-L${LOCALBASE}/lib
audio/zinf/Makefile:LDFLAGS+=	-lpthread -L${LOCALBASE}/lib
-->8-

Therefore, this is not uncommon to use LDFLAGS to add ${LOCALBASE}/lib to libraries search path.
The comment #2 confirms above statement for some previously converted ports to USES+=localbase.
Actually, the failures were indication of wrong proposal used by PR's submitter, but this didn's stop him to fix ports (i.e. adding localbase:ldflags instead of localbase), which were ok.

Moreover, the importance of this proposal is not "Affects Only Me", but "Affects Some People" or even "Affects Many People". For example, the ports r423014 changes affected some my patches in following PRs, related to audio/pulseaudio: bug 210548 and bug 211684.

If you look descriptions of LDFLAGS and LIBS for audio/pulseaudio port's configure script:
-8<--
# cd /usr/ports/audio/pulseaudio
# make extract
# cd work/pulseaudio-8.0
# ./configure --help | grep -w -h1 -e LIBS -e LDFLAGS
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
-->8-

Then you may understand, that LDFLAGS is proper place for -L flags. The assumption about LIBS for -L flags is wrong here, because USES+=localbase doesn't work after ports r423014 changes and requires to use USES+=localbase:ldflags instead.

The more correct proposal, in my opinion, is to use LDFLAGS+=-L${LOCABASE}/lib in Mk/Uses/localbase.mk by implicit default, while proposing libs and ldflags arguments to add -L${LOCABASE}/lib for either case (e.g. possible usage of: USES+=localbase, USES+=localbase:ldflags, USES+=localbase:libs, USES+=localbase:ldflags,libs). I attached some variant of it, related to Mk/Uses/localbase.mk file. Since this PR already affected many ports, this may require either to revert committed changes and/or change concrete ports, which may require USES+=localbase:libs instead of USES+=localbase:ldflags (proposed implicit default, which used before this proposal).
Comment 19 lightside 2016-10-02 00:22:32 UTC
(In reply to comment #18)
> (proposed implicit default, which used before this proposal).
(proposed explicit default, which used before this proposal).
Comment 20 lightside 2016-10-02 01:21:52 UTC
(In reply to comment #18)
> Moreover, the importance of this proposal is not "Affects Only Me", but
> "Affects Some People" or even "Affects Many People". For example, the
> ports r423014 changes affected some my patches in following PRs, related to
> audio/pulseaudio: bug 210548 and bug 211684.
I reverted USES+=localbase proposal in mentioned PRs to not depend on such unverified changes (i.e. which is POLA violation, based on changes for defaults).
Comment 21 lightside 2016-10-02 03:14:59 UTC
(In reply to comment #20)
> (i.e. which is POLA violation, based on changes for defaults).
Maybe this is not POLA in its meaning, but ports r423014 changes for defaults might have description in port's CHANGES file, if you intended to propose new USES+=localbase usage.
Comment 22 Tijl Coosemans freebsd_committer freebsd_triage 2016-10-02 10:44:33 UTC
Ports must be buildable while they are installed.  That means the order of -L flags is important.  It must always be -Lpath/in/workdir -L/usr/local/lib.  If it's the other way around the linker may pick up installed libraries instead of freshly built ones.  The typical linker command line is 'cc $upstream_LDFLAGS $LDFLAGS $upstream_LIBS $LIBS' where $upstream_LIBS may contain -Lpath/in/workdir.  Therefore it is safest to add -L/usr/local/lib to LIBS and USES=localbase should do the safest thing by default.  The reason more ports use LDFLAGS is because support for LIBS in bsd.port.mk is relatively recent.

For pulseaudio I think the reason plain USES=localbase doesn't work is because CONFIGURE_ENV in the port Makefile overrides LIBS.  Remove that and add 'LIBS+=-lm -lintl' below the CPPFLAGS+= line.
Comment 23 lightside 2016-10-02 14:53:40 UTC
(In reply to comment #22)
> Ports must be buildable while they are installed.  That means the order of -L
> flags is important.
I aware, that such issue may exist, which may depend from concrete build system.

(In reply to comment #22)
> For pulseaudio I think the reason plain USES=localbase doesn't work is because
> CONFIGURE_ENV in the port Makefile overrides LIBS.  Remove that and add
> 'LIBS+=-lm -lintl' below the CPPFLAGS+= line.
Yes, the USES+=localbase after ports r423014 doesn't work, because of LIBS="-lm -lintl" define for CONFIGURE_ENV. If remove LIBS="-lm -lintl" from CONFIGURE_ENV and add LIBS+="-lm -lintl" to Makefile, it will work with new USES+=localbase, as well as without such changes (except for CPPFLAGS and LDFLAGS removal), but USES+=localbase:ldflags usage. Previously, it also worked with USES+=localbase, because of LDFLAGS+=-L${LOCALBASE}/lib defaults.

Some excerpts for cases (based on audio/pulseadio v9.0):
LIBS+=-L${LOCALBASE}/lib -lm -lintl
-8<--
libtool: relink: cc -shared  -fPIC -DPIC  utils/.libs/libpulsedsp_la-padsp.o   -Wl,-rpath -Wl,/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib/pulseaudio ./.libs/libpulse.so -L/usr/local/lib /usr/ports/audio/pulseaudio/work/pulseaudio-9.0/src/.libs/libpulsecommon-9.0.so ./.libs/libpulsecommon-9.0.so -lX11-xcb -lX11 -lxcb -lICE -lSM -lXtst -ljson-c -lwrap -lsndfile -ldbus-1 /usr/local/lib/libgdbm.so -lexecinfo -lpthread -lrt -lm -lintl  -O2 -fstack-protector -Wl,-z -Wl,nodelete -fstack-protector -Wl,-rpath -Wl,/usr/local/lib   -Wl,-soname -Wl,libpulsedsp.so -o .libs/libpulsedsp.so
-->8-

LDFLAGS+=-L${LOCALBASE}/lib
LIBS+=-lm -lintl
-8<--
libtool: relink: cc -shared  -fPIC -DPIC  utils/.libs/libpulsedsp_la-padsp.o   -Wl,-rpath -Wl,/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib/pulseaudio -L/usr/local/lib ./.libs/libpulse.so /usr/ports/audio/pulseaudio/work/pulseaudio-9.0/src/.libs/libpulsecommon-9.0.so ./.libs/libpulsecommon-9.0.so -lX11-xcb -lX11 -lxcb -lICE -lSM -lXtst -ljson-c -lwrap -lsndfile -ldbus-1 /usr/local/lib/libgdbm.so -lexecinfo -lpthread -lrt -lm -lintl  -O2 -fstack-protector -Wl,-z -Wl,nodelete -fstack-protector -Wl,-rpath -Wl,/usr/local/lib   -Wl,-soname -Wl,libpulsedsp.so -o .libs/libpulsedsp.so
-->8-

As you may see, the place of -L/usr/local/lib (which is -L${LOCALBASE}/lib) doesn't matter in mentioned cases, because of ./.libs usage for *.so files (e.g. ./.libs/libpulse.so).

The cause of comment #18 is your changes for defaults in Mk/Uses/localbase.mk file. If you proposed USES+=localbase:libs and didn't change defaults, then this might not happen (as well as USES+=localbase:ldflags, instead of USES+=localbase changes for other ports).
I may adapt and use new USES+=localbase:ldflags instead, after ports r423014 changes, but I chose not to use it for currently proposed patches in PRs, where CPPFLAGS and LDFLAGS usage is fine already (according to `./configure --help` descriptions).
Comment 24 lightside 2016-10-02 15:17:10 UTC
Comment on attachment 175352 [details]
Proposed patch (since 423014 revision)

(In reply to comment #18)
> (e.g. possible usage of: USES+=localbase, USES+=localbase:ldflags,
> USES+=localbase:libs, USES+=localbase:ldflags,libs)
The "USES+=localbase:ldflags,libs" may be not practical. I just didn't want to contrapose LDFLAGS and LIBS to each other in description.
I removed maintainer-approval request, because this is just variant of patch to support my opinion in comment #18, based on previous approach with using (committed) proposal in this PR.
Comment 25 lightside 2016-10-02 17:11:44 UTC
(In reply to comment #23)
> Some excerpts for cases (based on audio/pulseadio v9.0)
Some other excerpts, without "relink" stage for cases:
LIBS+=-L${LOCALBASE}/lib -lm -lintl
-8<--
/bin/sh ../libtool  --tag=CC   --mode=link cc -std=gnu11 -D_THREAD_SAFE   -O2 -pipe  -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -Wall -W -Wextra -Wno-long-long -Wno-overlength-strings -Wundef -Wformat=2 -Wsign-compare -Wformat-security -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing -Wwrite-strings -Wno-unused-parameter -ffast-math -fno-common -fdiagnostics-show-option -fdiagnostics-color=auto    -Wl,-z,nodelete -avoid-version -disable-static -fstack-protector -o libpulsedsp.la -rpath /usr/local/lib/pulseaudio utils/libpulsedsp_la-padsp.lo -lpthread /usr/local/lib/libintl.so -Wl,-rpath -Wl,/usr/local/lib libpulse.la libpulsecommon-9.0.la -lgdbm -lexecinfo -lpthread -lrt -L/usr/local/lib -lm -lintl
libtool: link: cc -shared  -fPIC -DPIC  utils/.libs/libpulsedsp_la-padsp.o   -Wl,-rpath -Wl,/usr/ports/audio/pulseaudio/work/pulseaudio-9.0/src/.libs -Wl,-rpath -Wl,/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib/pulseaudio ./.libs/libpulse.so -L/usr/local/lib /usr/ports/audio/pulseaudio/work/pulseaudio-9.0/src/.libs/libpulsecommon-9.0.so ./.libs/libpulsecommon-9.0.so -lX11-xcb -lX11 -lxcb -lICE -lSM -lXtst -ljson-c -lwrap -lsndfile -ldbus-1 /usr/local/lib/libgdbm.so -lexecinfo -lpthread -lrt -lm -lintl  -O2 -fstack-protector -Wl,-z -Wl,nodelete -fstack-protector -Wl,-rpath -Wl,/usr/local/lib   -Wl,-soname -Wl,libpulsedsp.so -o .libs/libpulsedsp.so
-->8-

LDFLAGS+=-L${LOCALBASE}/lib
LIBS+=-lm -lintl
-8<--
/bin/sh ../libtool  --tag=CC   --mode=link cc -std=gnu11 -D_THREAD_SAFE   -O2 -pipe  -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -Wall -W -Wextra -Wno-long-long -Wno-overlength-strings -Wundef -Wformat=2 -Wsign-compare -Wformat-security -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing -Wwrite-strings -Wno-unused-parameter -ffast-math -fno-common -fdiagnostics-show-option -fdiagnostics-color=auto    -Wl,-z,nodelete -avoid-version -disable-static -L/usr/local/lib  -fstack-protector -o libpulsedsp.la -rpath /usr/local/lib/pulseaudio utils/libpulsedsp_la-padsp.lo -lpthread /usr/local/lib/libintl.so -Wl,-rpath -Wl,/usr/local/lib libpulse.la libpulsecommon-9.0.la -lgdbm -lexecinfo -lpthread -lrt -lm -lintl
libtool: link: cc -shared  -fPIC -DPIC  utils/.libs/libpulsedsp_la-padsp.o   -Wl,-rpath -Wl,/usr/ports/audio/pulseaudio/work/pulseaudio-9.0/src/.libs -Wl,-rpath -Wl,/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib/pulseaudio -L/usr/local/lib ./.libs/libpulse.so /usr/ports/audio/pulseaudio/work/pulseaudio-9.0/src/.libs/libpulsecommon-9.0.so ./.libs/libpulsecommon-9.0.so -lX11-xcb -lX11 -lxcb -lICE -lSM -lXtst -ljson-c -lwrap -lsndfile -ldbus-1 /usr/local/lib/libgdbm.so -lexecinfo -lpthread -lrt -lm -lintl  -O2 -fstack-protector -Wl,-z -Wl,nodelete -fstack-protector -Wl,-rpath -Wl,/usr/local/lib   -Wl,-soname -Wl,libpulsedsp.so -o .libs/libpulsedsp.so
-->8-

If -L search path is for -l library, then this is not an issue for "libpulse.la libpulsecommon-9.0.la" files after -L/usr/local/lib. Also, the audio/pulseaudio port didn't install *.la files to /usr/local/lib directory to possible cause this, otherwise.
Comment 26 lightside 2016-10-02 17:42:23 UTC
(In reply to comment #23)
> If -L search path is for -l library, then this is not an issue for
> "libpulse.la libpulsecommon-9.0.la" files after -L/usr/local/lib.
Checked with empty (or with random contents) libpulse.la file in /usr/local/lib. This is not an issue.

(In reply to comment #22)
> The reason more ports use LDFLAGS is because support for LIBS in bsd.port.mk
> is relatively recent.
I think, this depends from concrete build system. See comment #18 for description of LDFLAGS and LIBS, for example.
Comment 27 Tijl Coosemans freebsd_committer freebsd_triage 2016-10-02 18:09:10 UTC
(In reply to lightside from comment #23)
> As you may see, the place of -L/usr/local/lib (which is -L${LOCALBASE}/lib)
> doesn't matter in mentioned cases, because of ./.libs usage for *.so files
> (e.g. ./.libs/libpulse.so).

It's only using .so files here due to patching done by USES=libtool.  In relink mode unpatched libtool uses "-Lpath/in/stagedir -lpulse".  If you replace the .so files on the command line with something like that you can see that -L/usr/local/lib appears too early in the LDFLAGS case.  Here it also appears too early in the LIBS case (before libpulsecommon-9.0.so) because libtool does all sorts of silly things (which is why USES=libtool patches it).

> The cause of comment #18 is your changes for defaults in Mk/Uses/localbase.mk
> file. If you proposed USES+=localbase:libs and didn't change defaults, then
> this might not happen (as well as USES+=localbase:ldflags, instead of
> USES+=localbase changes for other ports).

LDFLAGS often works in clean test environments like poudriere so nobody would use localbase:libs.  There would always have to be some poor user running into problems trying to build the port while an older version is installed and filing a bug for a maintainer to consider localbase:libs.  Maintainers should try LIBS first and only use LDFLAGS if LIBS isn't supported by the build system.  Letting USES=localbase set LIBS by default accomplishes that.

> I may adapt and use new USES+=localbase:ldflags instead, after ports r423014
> changes, but I chose not to use it for currently proposed patches in PRs,
> where CPPFLAGS and LDFLAGS usage is fine already (according to `./configure
> --help` descriptions).

You should take LIBS out of CONFIGURE_ENV and use regular USES+=localbase.  Don't trust --help descriptions.  The LDFLAGS description is wrong for an unpatched libtool.  What matters is the code.  And the code says LIBS is better than LDFLAGS for -L flags so that is what we use.  Ports should use LIBS for both -L and -l flags except when the build system doesn't support LIBS.
Comment 28 lightside 2016-10-02 18:51:37 UTC
(In reply to comment #27)
> You should take LIBS out of CONFIGURE_ENV and use regular USES+=localbase.
> Don't trust --help descriptions.  The LDFLAGS description is wrong for an
> unpatched libtool.  What matters is the code.  And the code says LIBS is better
> than LDFLAGS for -L flags so that is what we use.  Ports should use LIBS for
> both -L and -l flags except when the build system doesn't support LIBS.
Thanks for suggestion, but I disagree, if concrete build system is ok for LDFLAGS usage (with or without patched libtool). This is way better, than custom patches for LIBS, because of some (strong) opinion about this.
The LDFLAGS and LIBS have their intended usage and shouldn't be opposite to each other, in my opinion (and based on some converted ports from USES+=localbase to USES+=localbase:ldflags).
Comment 29 lightside 2016-10-02 21:06:30 UTC
Comment on attachment 175352 [details]
Proposed patch (since 423014 revision)

(In reply to comment #28)
> This is way better, than custom patches for LIBS
Need to note, that sometimes this is necessary, even for some reordering of linked libraries (like in devel/tig case, but some proposed patch fixes this in bug 211850). May be even patch(es) for LDFLAGS is possible, while LIBS is better to use instead. This depends from concrete case and how concrete build system was developed. This is different from opinion about conversion of LDFLAGS cases to LIBS in all costs.

I think, no reaction from portmgr(s) speaks for itself. I did my own conclusions and do not force you to think otherwise. Thanks for attention and explanation about your position.
I obsoleted attachment #175352 [details], because no point to propose it, when PR is closed (and no other people to support it).