Download raw body.
devel/libtool: remove path from LD= in generated script
On Thu, Nov 21, 2024 at 01:37:37PM +0000, Stuart Henderson wrote:
> Ports infrastructure writes a wrapper script to ${WRKDIR}/bin/ld if
> variables are set which cause extra linker flags to be used - e.g.
> USE_NOBTCFI, USE_NOEXECONLY, USE_WXNEEDED - or if a non-default
> linker is used - USE_LLD.
>
> Currently, the majority of ports don't have a linker script written
> out because they don't use these flags.
>
> I've just tried a test bulk build where I wanted to use linker flags,
> so I added this to bsd.port.mk:
>
> _LINKER_FLAGS += --threads=3
>
> As this changes the linker flags for every port, it causes an ld wrapper
> to be written (to WRKDIR/bin/ld) in many ports where it wasn't before.
>
> This showed up that devel/libtool generates the gnu libtool script with
> LD=/path/to/ld set to whichever ld was used during build _of libtool_.
> So in the case of this test build, I had:
>
> $ grep ^LD= /usr/local/bin/libtool | uniq
> LD="/pobj/libtool-2.4.2/bin/ld"
> LD=""
>
> In this case, it will just totally fail if used to link another port
> when libtool's wrkdir has been cleaned, making the problem more obvious.
> I ran into it in comms/sigrok/libsigrok:
>
>
> However, in the normal case _without_ my test diff, we have
>
> $ grep ^LD= /usr/local/bin/libtool | uniq
> LD="/usr/bin/ld"
> LD=""
>
> This still gives a slight problem - using the full path means the
> wrapper (if present) is no longer called. So, if a port using
> USE_LIBTOOL=gnu calls the libtool script to run the linker, afaict it
> won't handle the linker-related USE_* variables mentioned above.
>
> Does this make sense? I've built everything that uses USE_LIBTOOL=gnu
> with a libtool package including the change.
I don't understand why you used sed like that instead of just doing
the following..
Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/libtool/Makefile,v
retrieving revision 1.91
diff -u -p -u -p -r1.91 Makefile
--- Makefile 21 Sep 2023 09:49:59 -0000 1.91
+++ Makefile 26 Nov 2024 02:13:06 -0000
@@ -4,7 +4,7 @@ COMMENT-ltdl= GNU libtool system indepen
VERSION= 2.4.2
DISTNAME= libtool-${VERSION}
PKGNAME-ltdl= libltdl-${VERSION}
-REVISION= 2
+REVISION= 3
CATEGORIES= devel
SITES= ${SITE_GNU:=libtool/}
@@ -28,6 +28,7 @@ USE_LIBTOOL= No
CONFIGURE_STYLE= gnu
CONFIGURE_ENV= GREP=/usr/bin/grep \
+ LD=ld \
ac_cv_f77_compiler_gnu=yes \
lt_cv_prog_compiler_c_o_F77=yes \
lt_cv_prog_compiler_pic_works_F77=yes \
Index: pkg/PLIST-ltdl
===================================================================
RCS file: /cvs/ports/devel/libtool/pkg/PLIST-ltdl,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 PLIST-ltdl
--- pkg/PLIST-ltdl 11 Mar 2022 18:50:40 -0000 1.8
+++ pkg/PLIST-ltdl 26 Nov 2024 02:13:06 -0000
@@ -3,7 +3,7 @@ include/libltdl/lt_dlloader.h
include/libltdl/lt_error.h
include/libltdl/lt_system.h
include/ltdl.h
-lib/libltdl.a
+@static-lib lib/libltdl.a
lib/libltdl.la
@lib lib/libltdl.so.${LIBltdl_VERSION}
share/aclocal/
devel/libtool: remove path from LD= in generated script