Module Name:    src
Committed By:   martin
Date:           Tue Nov 26 09:44:36 UTC 2024

Modified Files:
        src/external/bsd/libarchive/lib/libarchive [netbsd-10]: Makefile
        src/tests/lib/libarchive [netbsd-10]: Makefile

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1017):

        external/bsd/libarchive/lib/libarchive/Makefile: revision 1.20
        tests/lib/libarchive/Makefile: revision 1.16

libarchive: Export only public symbols.

1. Build with -fvisibility=hidden -D__LIBARCHIVE_ENABLE_VISIBILITY,
   which is upstream's supported way to export only public symbols.
   => Verified that this only suppresses symbols which are _not_
      declared in libarchive's public header files.

2. Link with -Wl,--exclude-libs,libzstd so that statically linked
   libzstd symbols aren't exported.
   => Verified that this only suppresses libzstd symbols which are not
      part of libarchive at all.

This deletes exported symbols from a shared library -- but only those
that should never have been exported to begin with, and that can't be
used by normal libarchive applications without going out of their way
to get at internal symbols.  In fact, some of these symbols, like
blake2s_init, are likely to collide with other libraries or
applications.

So while this technically violates the letter of shlib major rules
and releng pullup rules by deleting exported symbols, I'm not bumping
and I intend to pull this up to 10 (and maybe 9) -- because I suspect
it is more likely that libarchive's private symbols will conflict
with other uses in real applications than that real applications will
rely on libarchive's private symbols.
PR lib/58829: libarchive exports excess symbols

tests/lib/libarchive: Link against libarchive statically.
The tests reach into libarchive guts, so they don't work with only
the public symbols, which are all that libarchive.so exports now.

PR lib/58829: libarchive exports excess symbols


To generate a diff of this commit:
cvs rdiff -u -r1.14.2.3 -r1.14.2.4 \
    src/external/bsd/libarchive/lib/libarchive/Makefile
cvs rdiff -u -r1.5.6.3 -r1.5.6.4 src/tests/lib/libarchive/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/libarchive/lib/libarchive/Makefile
diff -u src/external/bsd/libarchive/lib/libarchive/Makefile:1.14.2.3 src/external/bsd/libarchive/lib/libarchive/Makefile:1.14.2.4
--- src/external/bsd/libarchive/lib/libarchive/Makefile:1.14.2.3	Fri Nov  1 10:08:13 2024
+++ src/external/bsd/libarchive/lib/libarchive/Makefile	Tue Nov 26 09:44:36 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.14.2.3 2024/11/01 10:08:13 martin Exp $
+#	$NetBSD: Makefile,v 1.14.2.4 2024/11/26 09:44:36 martin Exp $
 
 .include <bsd.init.mk>
 
@@ -13,6 +13,16 @@ LIBDPLIBS+=	bz2	${NETBSDSRCDIR}/lib/libb
 		lzma	${NETBSDSRCDIR}/external/public-domain/xz/lib \
 		z	${NETBSDSRCDIR}/lib/libz
 
+# XXX Avoid exporting symbols of statically linked deps like zstd.
+# XXX Should do this in bsd.lib.mk, perhaps.
+.for _lib _dir in ${LIBDPLIBS}
+LDADD+=		-Wl,--exclude-libs,lib${_lib}
+.endfor
+
+# Avoid exporting private libarchive symbols.
+COPTS+=		-fvisibility=hidden
+CPPFLAGS+=	-D__LIBARCHIVE_ENABLE_VISIBILITY
+
 SRCS=		archive_acl.c \
 		archive_blake2sp_ref.c \
 		archive_blake2s_ref.c \

Index: src/tests/lib/libarchive/Makefile
diff -u src/tests/lib/libarchive/Makefile:1.5.6.3 src/tests/lib/libarchive/Makefile:1.5.6.4
--- src/tests/lib/libarchive/Makefile:1.5.6.3	Fri Nov  1 14:36:21 2024
+++ src/tests/lib/libarchive/Makefile	Tue Nov 26 09:44:36 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.5.6.3 2024/11/01 14:36:21 martin Exp $
+# $NetBSD: Makefile,v 1.5.6.4 2024/11/26 09:44:36 martin Exp $
 
 NOMAN=
 
@@ -18,7 +18,8 @@ CPPFLAGS+=-I${LIBARCHIVE}/libarchive/tes
 
 DPADD+=	${LIBARCHIVE} ${LIBEXPAT} ${LIBBZ2} ${LIBLZMA} ${LIBZ} \
 	${LIBCRYPTO} ${LIBPTHREAD}
-LDADD+=	-larchive -lexpat -lbz2 -llzma -lz -lcrypto -lpthread
+LDADD+=	-Wl,--push-state,-Bstatic,-larchive,--pop-state	# uses libarchive guts
+LDADD+=	-lexpat -lbz2 -llzma -lz -lcrypto -lpthread
 
 SRCS.h_libarchive= \
 test_main.c \

Reply via email to