NetBSD Problem Report #59506

From wiz@exadelic.gatalith.at  Thu Jul  3 09:34:16 2025
Return-Path: <wiz@exadelic.gatalith.at>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id EF53E1A923C
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  3 Jul 2025 09:34:15 +0000 (UTC)
Message-Id: <20250703090626.B0B0D2EBBAA7@exadelic.gatalith.at>
Date: Thu, 03 Jul 2025 11:06:26 +0200 (CEST)
From: Thomas Klausner <wiz@NetBSD.org>
Reply-To: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@NetBSD.org
Subject: static libarchive is missing zstd symbols
X-Send-Pr-Version: 3.95

>Number:         59506
>Category:       lib
>Synopsis:       static libarchive is missing zstd symbols
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 03 09:35:00 +0000 2025
>Originator:     Thomas Klausner
>Release:        NetBSD 10.99.14
>Organization:

>Environment:


Architecture: x86_64
Machine: amd64
>Description:
When linking pkgin against libarchive, it fails

  CCLD     pkgin
ld: /usr/lib/libarchive.a(archive_read_support_filter_zstd.o): in function `zstd_filter_close':
archive_read_support_filter_zstd.c:(.text+0x11): undefined reference to `ZSTD_freeDStream'
ld: /usr/lib/libarchive.a(archive_read_support_filter_zstd.o): in function `zstd_bidder_init':
archive_read_support_filter_zstd.c:(.text+0x42): undefined reference to `ZSTD_DStreamOutSize'
ld: archive_read_support_filter_zstd.c:(.text+0x7c): undefined reference to `ZSTD_createDStream'
ld: archive_read_support_filter_zstd.c:(.text+0xd9): undefined reference to `ZSTD_freeDStream'
ld: /usr/lib/libarchive.a(archive_read_support_filter_zstd.o): in function `zstd_filter_read':
archive_read_support_filter_zstd.c:(.text+0x1a4): undefined reference to `ZSTD_decompressStream'
ld: archive_read_support_filter_zstd.c:(.text+0x1af): undefined reference to `ZSTD_isError'
ld: archive_read_support_filter_zstd.c:(.text+0x1ee): undefined reference to `ZSTD_initDStream'
ld: archive_read_support_filter_zstd.c:(.text+0x1f9): undefined reference to `ZSTD_isError'
ld: archive_read_support_filter_zstd.c:(.text+0x27a): undefined reference to `ZSTD_getErrorName'
ld: archive_read_support_filter_zstd.c:(.text+0x2a6): undefined reference to `ZSTD_getErrorName'
*** [pkgin] Error code 1

since libarchive.a is missing some symbols:

nm /usr/lib/libarchive.a| grep U.ZSTD
                 U ZSTD_CCtx_reset
                 U ZSTD_CCtx_setParameter
                 U ZSTD_CStreamOutSize
                 U ZSTD_cParam_getBounds
                 U ZSTD_compressStream
                 U ZSTD_createCStream
                 U ZSTD_endStream
                 U ZSTD_freeCStream
                 U ZSTD_getErrorName
                 U ZSTD_initCStream
                 U ZSTD_isError
                 U ZSTD_maxCLevel
                 U ZSTD_minCLevel
                 U ZSTD_versionNumber
                 U ZSTD_createDStream
                 U ZSTD_decompressStream
                 U ZSTD_freeDStream
                 U ZSTD_getErrorName
                 U ZSTD_isError
                 U ZSTD_DStreamOutSize
                 U ZSTD_createDStream
                 U ZSTD_decompressStream
                 U ZSTD_freeDStream
                 U ZSTD_getErrorName
                 U ZSTD_initDStream
                 U ZSTD_isError
                 U ZSTD_DStreamOutSize
                 U ZSTD_createDStream
                 U ZSTD_decompressStream
                 U ZSTD_freeDStream
                 U ZSTD_getErrorName
                 U ZSTD_initDStream
                 U ZSTD_isError

In libarchive I see in src/external/bsd/libarchive/lib/libarchive/Makefile

# 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

This looks wrong for the static library
>How-To-Repeat:

Apply this to pkgsrc/pkgtools/pkgin/Makefile:

Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkgin/Makefile,v
retrieving revision 1.139
diff -u -r1.139 Makefile
--- Makefile	20 May 2025 08:21:45 -0000	1.139
+++ Makefile	3 Jul 2025 08:41:12 -0000
@@ -34,6 +34,13 @@

 USE_FEATURES=		nbcompat

+# link statically to make upgrades of itself easier
+CFLAGS+=		-static
+# needed by sqlite3
+LIBS+=		-lm -lpthread
+# needed by libarchive
+LIBS+=		-lz -lbz2 -llzma -larchive
+
 .include "../../mk/bsd.prefs.mk"

 SUBST_CLASSES.NetBSD+=	osrel

and build pkgin.
>Fix:
Please.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.