Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Feb 2020 00:34:16 +0000 (UTC)
From:      Matthias Andree <mandree@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r525006 - in head/sysutils/e2fsprogs: . files
Message-ID:  <202002030034.0130YGLX082150@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mandree
Date: Mon Feb  3 00:34:15 2020
New Revision: 525006
URL: https://svnweb.freebsd.org/changeset/ports/525006

Log:
  Be more careful about what and how we link.
  
  Only link what we need (--as-needed) to get unnecessary dependencies
  out of the executables.
  
  Be sure to properly link libc dynamically and the rest statically,
  especially libgcc (-static-libgcc, should fix powerpc* builds => [1])
  
  After two years, drop the "for now" LLD_UNSAFE=yes (r457508 by emaste@).
  
  As e2fsprogs dlopen()s libmagic these days, our LIBMAGIC override is
  useless.  Instead patch libmagic.so.1 -> libmagic.so (12.1 calls it
  libmagic.so.4; patch to lib/support/plausible.c).
  
  Refresh files/patch-misc__Makefile.in
  
  PR:		242798 [1]

Added:
  head/sysutils/e2fsprogs/files/patch-lib_support_plausible.c   (contents, props changed)
Modified:
  head/sysutils/e2fsprogs/Makefile
  head/sysutils/e2fsprogs/files/patch-misc__Makefile.in

Modified: head/sysutils/e2fsprogs/Makefile
==============================================================================
--- head/sysutils/e2fsprogs/Makefile	Sun Feb  2 21:43:40 2020	(r525005)
+++ head/sysutils/e2fsprogs/Makefile	Mon Feb  3 00:34:15 2020	(r525006)
@@ -3,7 +3,7 @@
 
 PORTNAME=	e2fsprogs
 PORTVERSION=	1.45.5
-PORTREVISION?=	2
+PORTREVISION?=	3
 CATEGORIES?=	sysutils
 MASTER_SITES=	KERNEL_ORG/linux/kernel/people/tytso/${PORTNAME}/v${PORTVERSION}
 
@@ -28,7 +28,6 @@ USE_CSTD=	gnu99
 USE_LDCONFIG=	${PREFIX}/lib/e2fsprogs
 .endif
 GNU_CONFIGURE=	yes
-LLD_UNSAFE=	yes
 
 # while we use the system blkid, we need to --enable-libblkid
 # so that the tools get built:
@@ -43,7 +42,7 @@ CONFIGURE_ARGS?=--disable-fsck \
 		--with-root-prefix='${PREFIX}' \
 		--without-included-gettext \
 		LDFLAGS='${LDFLAGS} -L${LOCALBASE}/lib -Wl,--rpath -Wl,${LOCALBASE}/lib/e2fsprogs'
-CONFIGURE_ENV?=	LIBS='${LIBS} -lexecinfo -lelf'
+CONFIGURE_ENV?=	LIBS='-Wl,--as-needed ${LIBS} -lexecinfo -lelf'
 CPPFLAGS+=	-I${WRKSRC}/lib -I${LOCALBASE}/include # -D_EXT2_USE_C_VERSIONS
 MAKE_ARGS+=	pkgconfigdir='${PREFIX}/libdata/pkgconfig'
 MAKE_ENV+=	CHECK_CMD=@true
@@ -79,7 +78,7 @@ LIB_DEPENDS+=	libss.so:devel/e2fsprogs-libss
 LIB_DEPENDS+=	libuuid.so:misc/e2fsprogs-libuuid
 
 LIBUNWIND_LIB_DEPENDS=	libunwind.so:devel/libunwind
-LIBUNWIND_LIBS+=	-lunwind
+LIBUNWIND_LIBS+=	-L${LOCALBASE}/lib -lunwind
 LIBUNWIND_LDFLAGS+=	-rdynamic
 LIBUNWIND_EXTRA_PATCHES=${FILESDIR}/extrapatch-e2fsck_sigcatcher.c
 
@@ -247,12 +246,14 @@ post-build:
 # system are statically linked against anything that is outside the root fs,
 # else we're in trouble if e2fsck is needed for boot:
 # (we don't use e2fsck.static, since we can link libc.so dynamically)
+# NOTE: we need to link libgcc statically, it might be under /usr/local!
+# => do not add a -Bdynamic - but instead list the dynamic libraries
+# before the -Bstatic
 	cd ${WRKSRC}/e2fsck && ${RM} -f e2fsck \
 		&& ${MAKE_CMD} e2fsck V=1 \
-		LIBS="../lib/libsupport.a ../lib/libext2fs.a ../lib/libcom_err.a \
+		LIBS="-static-libgcc -lc -Bstatic ../lib/libsupport.a ../lib/libext2fs.a ../lib/libcom_err.a \
 		${_staticlibs} /usr/lib/libexecinfo.a /usr/lib/libelf.a \
-		${LOCALBASE}/lib/libblkid.a ${LOCALBASE}/lib/libuuid.a ${libintl} ../lib/libe2p.a" \
-		LIBMAGIC=/usr/lib/libmagic.a\ -lz
+		${LOCALBASE}/lib/libblkid.a ${LOCALBASE}/lib/libuuid.a ${libintl} ../lib/libe2p.a "
 # Regression check: avoid a port (not upstream!) regression from 1.40.5,
 # check that e2fsck isn't dynalinked against anything but libc.so:
 	@${ECHO_CMD} -n "===>  checking that e2fsck depends on no shared objects outside /lib: "

Added: head/sysutils/e2fsprogs/files/patch-lib_support_plausible.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/e2fsprogs/files/patch-lib_support_plausible.c	Mon Feb  3 00:34:15 2020	(r525006)
@@ -0,0 +1,11 @@
+--- lib/support/plausible.c.orig	2020-01-06 23:10:17 UTC
++++ lib/support/plausible.c
+@@ -62,7 +62,7 @@ static void *magic_handle;
+ static int magic_library_available(void)
+ {
+ 	if (!magic_handle) {
+-		magic_handle = dlopen("libmagic.so.1", RTLD_NOW);
++		magic_handle = dlopen("libmagic.so", RTLD_NOW);
+ 		if (!magic_handle)
+ 			return 0;
+ 

Modified: head/sysutils/e2fsprogs/files/patch-misc__Makefile.in
==============================================================================
--- head/sysutils/e2fsprogs/files/patch-misc__Makefile.in	Sun Feb  2 21:43:40 2020	(r525005)
+++ head/sysutils/e2fsprogs/files/patch-misc__Makefile.in	Mon Feb  3 00:34:15 2020	(r525006)
@@ -1,4 +1,4 @@
---- misc/Makefile.in.orig	2019-07-15 01:03:14 UTC
+--- misc/Makefile.in.orig	2020-01-06 23:10:17 UTC
 +++ misc/Makefile.in
 @@ -34,17 +34,17 @@ INSTALL = @INSTALL@
  
@@ -23,7 +23,7 @@
  UMANPAGES+=	@FUSE_CMT@ fuse2fs.1
  
  LPROGS=		@E2INITRD_PROG@
-@@ -146,14 +146,14 @@ profiled:
+@@ -147,14 +147,14 @@ profiled:
  
  mke2fs.conf: $(srcdir)/mke2fs.conf.in
  	if test -f $(srcdir)/mke2fs.conf.custom.in ; then \
@@ -41,7 +41,7 @@
  		>  default_profile.c
  findsuper: findsuper.o
  	$(E) "	LD $@"
-@@ -600,34 +600,9 @@ install: all $(SMANPAGES) $(UMANPAGES) installdirs
+@@ -605,34 +605,9 @@ install: all $(SMANPAGES) $(UMANPAGES) installdirs
  		(cd $(DESTDIR)$(man5dir); \
  			$(LN) $(LINK_INSTALL_FLAGS) ext4.5 $$i.5); \
  	done



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002030034.0130YGLX082150>