Bug 245025 - ports-mgmt/pkg: Fails to link after ports r359159: undefined reference to `_libmd_SHA1_Init' (requires -lmd after -larchive)
Summary: ports-mgmt/pkg: Fails to link after ports r359159: undefined reference to `_l...
Status: Closed Unable to Reproduce
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-pkg (Nobody)
Keywords: needs-qa, regression
Depends on:
Reported: 2020-03-24 02:51 UTC by dewayne
Modified: 2021-08-18 12:15 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (pkg)


Note You need to log in before you can comment on or make changes to this bug.
Description dewayne 2020-03-24 02:51:05 UTC
I think we need to add, around line 58, -lmd (after -larchive) to 
to avoid 

/usr/bin/ld: /var/ports/usr/ports/ports-mgmt/pkg/work/pkg-1.13.2/libpkg/libpkg_flat.a(loslib.o): in function `os_tmpname':
loslib.c:(.text+0x78f): warning: warning: tmpnam() possibly used unsafely; consider using mkstemp()
/usr/bin/ld: /usr/lib/libarchive.a(archive_digest.o): in function `__archive_libmd_sha1init':
archive_digest.c:(.text+0x72): undefined reference to `_libmd_SHA1_Init'

This is on FreeBSD 12.1-STABLE #0 r359159M: Sat Mar 21 13:31:04 AEDT 2020
FreeBSD clang version 9.0.1
Comment 1 Baptiste Daroussin freebsd_committer 2020-03-24 17:03:52 UTC
I would need more information to be able to reproduce that, as I cannot do it for now.
Comment 2 dewayne 2020-03-25 02:18:31 UTC
(In reply to Baptiste Daroussin from comment #1)
If pkg links to archivers/libarchive then the problem is not reproducible; and this is my workaround ;)

In both the amd64 and i386 jails, there is no:
-  /usr/local/lib/libarchive*
-  base openssl (because we build with libressl).
Prior to building packages, we remove all remnants of prior builds, inluding various "pkg delete -y -a".  From here we rebuild everything.  (And yes, we do reinstall a previously working /usr/local/sbin/pkg-static into our bare bones build jails)

# make -C /usr/ports/ports-mgmt/pkg -VCFLAGS -Vspace -VLDFLAGS
-O2 -pipe -Wl,-m,elf_x86_64_fbsd -Wl,--strip-debug -Wl,--build-id=md5 -Wl,--hash-style=sysv -DOPENSSL_NO_SSL2 -DOPENSSL_NO_SSL3 -g0 -ggdb0 -DSTRIP_FBSDID -UDEBUGGING -UDEBUG -fno-math-errno -fomit-frame-pointer -fno-asynchronous-unwind-tables -march=core2 -Wno-error -fno-strict-aliasing

-Wl,--strip-debug -Wl,--build-id=md5 -Wl,--hash-style=sysv 

When I examine base's tar and pkg they are both linked to libmd, 
# ldd /usr/bin/tar /usr/sbin/pkg | grep -E ":|archiv|md"
        libarchive.so.7 => /usr/lib/libarchive.so.7 (0x178e5daf4000)
        libmd.so.6 => /lib/libmd.so.6 (0x178e5dc4f000)
        libarchive.so.7 => /usr/lib/libarchive.so.7 (0x801d1d000)
        libmd.so.6 => /lib/libmd.so.6 (0x806a80000)
(I selected tar because I know it also needs libarchive)

This is on a very recent FreeBSD12.1 r359159.  I don't know what else would be helpful to reproduce?
Comment 3 Baptiste Daroussin freebsd_committer 2021-08-18 12:15:51 UTC
I am not able to reproduce in any case, if it still happens to you, please feel free to reopen