I only saw this strange behaviour on my own laptop running a week old 16.0-CURRENT, but here’s one way of coping.

--- pkg-static ---
ccache cc -o pkg-static add.o alias.o annotate.o audit.o autoremove.o check.o clean.o config.o create.o delete.o event.o fetch.o globals.o info.o install.o key.o lock.o main.o plugins.o query.o register.o repo.o repositories.o rquery.o search.o set.o shell.o shlib.o ssh.o stats.o triggers.o unregister.o update.o updating.o upgrade.o utils.o version.o which.o -static -L/var/spool/workdirs/usr/ports/ports-mgmt/pkg/work/pkg-2.7.4/libpkg -lpkg_flat  -lelf -ljail -lm -pthread -larchive -lutil -lssl -lcrypto -lmd -lbz2 -lz -llzma -lprivatezstd
/usr/local/bin/x86_64-unknown-freebsd16.0-ld: warning: x86_64-gf2m.o: missing .note.GNU-stack section implies executable stack
/usr/local/bin/x86_64-unknown-freebsd16.0-ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/usr/local/bin/x86_64-unknown-freebsd16.0-ld: /usr/lib/liblzma.a(check.o): in function `lzma_sha256_init':
/usr/src/contrib/xz/src/liblzma/check/check.h:127:(.text+0x6c): undefined reference to `_libmd_SHA256_Init'
/usr/local/bin/x86_64-unknown-freebsd16.0-ld: /usr/lib/liblzma.a(check.o): in function `lzma_sha256_update':
/usr/src/contrib/xz/src/liblzma/check/check.h:144:(.text+0xc8): undefined reference to `_libmd_SHA256_Update'
/usr/local/bin/x86_64-unknown-freebsd16.0-ld: /usr/lib/liblzma.a(check.o): in function `lzma_sha256_finish':
/usr/src/contrib/xz/src/liblzma/check/check.h:151:(.text+0xf9): undefined reference to `_libmd_SHA256_Final'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** [pkg-static] Error code 1

Simply add -lmd after $(STATIC_LDFLAGS) of ports-mgmt/pkg/files/patch-src_Makefile.autosetup, like this:

--- src/Makefile.autosetup.orig	2022-12-11 18:22:41 UTC
+++ src/Makefile.autosetup
@@ -93,7 +93,7 @@ pkg-static: $(OBJS) $(top_builddir)/libpkg/libpkg_flat
 install: install-static
 
 pkg-static: $(OBJS) $(top_builddir)/libpkg/libpkg_flat.a
-	$(CC) -o $@ $(OBJS) $(STATIC_ARG) $(LDFLAGS) $(STATIC_LDFLAGS)
+	$(CC) -o $@ $(OBJS) $(STATIC_ARG) $(STATIC_LDFLAGS) -lmd
 
 install-static: pkg-static
 	install -d -m 755 $(DESTDIR)$(sbindir)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>