Wed Oct 28 16:52:43 2020 UTC ()
Bootstrap: Fix bootstrap on FreeBSD 12.1, likely broken by an issue in lld.

It looks like lld doesn't want to statically link a libarchive without
resolving all of the symbols, even if only a few symbols are used.

In order to resolve all of the symbols, we need to also link with -lmd.
One generic way to do so is inspect Libs.private in the pkgconfig file.

While pkgsrc is likely not at fault here, having a dysfunctional bootstrap
is bad. We should check again in the future to see if this can be removed.

Actually fixes PR pkg/55400.


(maya)
diff -r1.294 -r1.295 pkgsrc/bootstrap/bootstrap
diff -r1.33 -r1.34 pkgsrc/pkgtools/pkg_install/files/add/Makefile.in
diff -r1.29 -r1.30 pkgsrc/pkgtools/pkg_install/files/create/Makefile.in

cvs diff -r1.294 -r1.295 pkgsrc/bootstrap/bootstrap (expand / switch to unified diff)

--- pkgsrc/bootstrap/bootstrap 2020/10/07 10:44:14 1.294
+++ pkgsrc/bootstrap/bootstrap 2020/10/28 16:52:43 1.295
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1#! /bin/sh 1#! /bin/sh
2 2
3# $NetBSD: bootstrap,v 1.294 2020/10/07 10:44:14 jperkin Exp $ 3# $NetBSD: bootstrap,v 1.295 2020/10/28 16:52:43 maya Exp $
4# 4#
5# Copyright (c) 2001-2011 Alistair Crooks <agc@NetBSD.org> 5# Copyright (c) 2001-2011 Alistair Crooks <agc@NetBSD.org>
6# All rights reserved. 6# All rights reserved.
7# 7#
8# Redistribution and use in source and binary forms, with or without 8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions 9# modification, are permitted provided that the following conditions
10# are met: 10# are met:
11# 1. Redistributions of source code must retain the above copyright 11# 1. Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer. 12# notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright 13# 2. Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in the 14# notice, this list of conditions and the following disclaimer in the
15# documentation and/or other materials provided with the distribution. 15# documentation and/or other materials provided with the distribution.
16# 16#
@@ -1225,44 +1225,49 @@ esac @@ -1225,44 +1225,49 @@ esac
1225 1225
1226# bootstrap sed if necessary 1226# bootstrap sed if necessary
1227case "$need_sed" in 1227case "$need_sed" in
1228yes) echo_msg "Bootstrapping sed" 1228yes) echo_msg "Bootstrapping sed"
1229 copy_src $pkgsrcdir/textproc/nbsed/files sed 1229 copy_src $pkgsrcdir/textproc/nbsed/files sed
1230 run_cmd "(cd $wrkdir/sed; env $BSTRAP_ENV CPPFLAGS='$CPPFLAGS -I../libnbcompat' LDFLAGS='$LDFLAGS -L../libnbcompat' LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir --program-transform-name='s,sed,nbsed,' && $bmake $make_quiet_flags -j$make_jobs)" 1230 run_cmd "(cd $wrkdir/sed; env $BSTRAP_ENV CPPFLAGS='$CPPFLAGS -I../libnbcompat' LDFLAGS='$LDFLAGS -L../libnbcompat' LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir --program-transform-name='s,sed,nbsed,' && $bmake $make_quiet_flags -j$make_jobs)"
1231 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/sed/sed $wrkdir/bin/sed" 1231 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/sed/sed $wrkdir/bin/sed"
1232 echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${TARGET_MKCONF} 1232 echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${TARGET_MKCONF}
1233 echo "TOOLS_PLATFORM.sed?= $wrkdir/bin/sed" >> ${BOOTSTRAP_MKCONF} 1233 echo "TOOLS_PLATFORM.sed?= $wrkdir/bin/sed" >> ${BOOTSTRAP_MKCONF}
1234 ;; 1234 ;;
1235esac 1235esac
1236 1236
1237# bootstrap pkg_install 1237# bootstrap pkg_install
 1238extra_libarchive_depends() {
 1239 $sedprog -n -e 's/Libs.private: //p' $wrkdir/libarchive/build/pkgconfig/libarchive.pc
 1240}
 1241
1238echo_msg "Bootstrapping pkgtools" 1242echo_msg "Bootstrapping pkgtools"
1239copy_src $pkgsrcdir/archivers/libarchive/files libarchive 1243copy_src $pkgsrcdir/archivers/libarchive/files libarchive
1240run_cmd "(cd $wrkdir/libarchive; env $BSTRAP_ENV \ 1244run_cmd "(cd $wrkdir/libarchive; env $BSTRAP_ENV \
1241$shprog ./configure $configure_quiet_flags --enable-static --disable-shared \ 1245$shprog ./configure $configure_quiet_flags --enable-static --disable-shared \
1242--disable-bsdtar --disable-bsdcpio --disable-posix-regex-lib --disable-xattr \ 1246--disable-bsdtar --disable-bsdcpio --disable-posix-regex-lib --disable-xattr \
1243--disable-maintainer-mode --disable-acl --without-zlib --without-bz2lib \ 1247--disable-maintainer-mode --disable-acl --without-zlib --without-bz2lib \
1244--without-iconv --without-lzma --without-lzo2 --without-lz4 \ 1248--without-iconv --without-lzma --without-lzo2 --without-lz4 \
1245--without-nettle --without-openssl --without-xml2 --without-expat --without-zstd \ 1249--without-nettle --without-openssl --without-xml2 --without-expat --without-zstd \
1246MAKE=$bmake && $bmake $make_quiet_flags -j$make_jobs)" 1250MAKE=$bmake && $bmake $make_quiet_flags -j$make_jobs)"
1247copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install 1251copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install
1248run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV \ 1252run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV \
1249CPPFLAGS='$CPPFLAGS -I${wrkdir}/libnbcompat -I${wrkdir}/libarchive/libarchive' \ 1253CPPFLAGS='$CPPFLAGS -I${wrkdir}/libnbcompat -I${wrkdir}/libarchive/libarchive' \
1250LDFLAGS='$LDFLAGS -L${wrkdir}/libnbcompat' \ 1254LDFLAGS='$LDFLAGS -L${wrkdir}/libnbcompat' \
1251LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C \ 1255LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C \
1252--enable-bootstrap --prefix=$prefix --sysconfdir=$sysconfdir \ 1256--enable-bootstrap --prefix=$prefix --sysconfdir=$sysconfdir \
1253--with-pkgdbdir=$pkgdbdir --infodir=$infodir \ 1257--with-pkgdbdir=$pkgdbdir --infodir=$infodir \
1254--mandir=$mandir $pkg_install_args && \ 1258--mandir=$mandir $pkg_install_args && \
1255STATIC_LIBARCHIVE=$wrkdir/libarchive/.libs/libarchive.a \ 1259STATIC_LIBARCHIVE=$wrkdir/libarchive/.libs/libarchive.a \
 1260STATIC_LIBARCHIVE_LDADD=`extra_libarchive_depends` \
1256PKGSRC_MACHINE_ARCH="$machine_arch" $bmake $make_quiet_flags -j$make_jobs)" 1261PKGSRC_MACHINE_ARCH="$machine_arch" $bmake $make_quiet_flags -j$make_jobs)"
1257run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/add/pkg_add $wrkdir/sbin/pkg_add" 1262run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/add/pkg_add $wrkdir/sbin/pkg_add"
1258run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/admin/pkg_admin $wrkdir/sbin/pkg_admin" 1263run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/admin/pkg_admin $wrkdir/sbin/pkg_admin"
1259run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/create/pkg_create $wrkdir/sbin/pkg_create" 1264run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/create/pkg_create $wrkdir/sbin/pkg_create"
1260run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/info/pkg_info $wrkdir/sbin/pkg_info" 1265run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/info/pkg_info $wrkdir/sbin/pkg_info"
1261echo "PKG_ADD_CMD?= $wrkdir/sbin/pkg_add" >> ${BOOTSTRAP_MKCONF} 1266echo "PKG_ADD_CMD?= $wrkdir/sbin/pkg_add" >> ${BOOTSTRAP_MKCONF}
1262echo "PKG_ADMIN_CMD?= $wrkdir/sbin/pkg_admin" >> ${BOOTSTRAP_MKCONF} 1267echo "PKG_ADMIN_CMD?= $wrkdir/sbin/pkg_admin" >> ${BOOTSTRAP_MKCONF}
1263echo "PKG_CREATE_CMD?= $wrkdir/sbin/pkg_create" >> ${BOOTSTRAP_MKCONF} 1268echo "PKG_CREATE_CMD?= $wrkdir/sbin/pkg_create" >> ${BOOTSTRAP_MKCONF}
1264echo "PKG_INFO_CMD?= $wrkdir/sbin/pkg_info" >> ${BOOTSTRAP_MKCONF} 1269echo "PKG_INFO_CMD?= $wrkdir/sbin/pkg_info" >> ${BOOTSTRAP_MKCONF}
1265 1270
1266MAKECONF=$wrkdir/mk.conf 1271MAKECONF=$wrkdir/mk.conf
1267export MAKECONF 1272export MAKECONF
1268 1273

cvs diff -r1.33 -r1.34 pkgsrc/pkgtools/pkg_install/files/add/Makefile.in (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/add/Makefile.in 2015/12/27 12:36:42 1.33
+++ pkgsrc/pkgtools/pkg_install/files/add/Makefile.in 2020/10/28 16:52:43 1.34
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile.in,v 1.33 2015/12/27 12:36:42 joerg Exp $ 1# $NetBSD: Makefile.in,v 1.34 2020/10/28 16:52:43 maya Exp $
2 2
3srcdir= @srcdir@ 3srcdir= @srcdir@
4 4
5prefix= @prefix@ 5prefix= @prefix@
6exec_prefix= @exec_prefix@ 6exec_prefix= @exec_prefix@
7sbindir= @sbindir@ 7sbindir= @sbindir@
8mandir= @mandir@ 8mandir= @mandir@
9datarootdir= @datarootdir@ 9datarootdir= @datarootdir@
10 10
11man1dir= $(mandir)/man1 11man1dir= $(mandir)/man1
12cat1dir= $(mandir)/cat1 12cat1dir= $(mandir)/cat1
13 13
14CC= @CC@ 14CC= @CC@
@@ -19,27 +19,27 @@ CFLAGS= @CFLAGS@ @@ -19,27 +19,27 @@ CFLAGS= @CFLAGS@
19LDFLAGS= @LDFLAGS@ -L../lib 19LDFLAGS= @LDFLAGS@ -L../lib
20 20
21BOOTSTRAP= @bootstrap@ 21BOOTSTRAP= @bootstrap@
22SSL_SUPPORT= @ssl_support@ 22SSL_SUPPORT= @ssl_support@
23 23
24.if empty(BOOTSTRAP) 24.if empty(BOOTSTRAP)
25LIBS= -linstall -lnetpgpverify -larchive -lbz2 -lz -lfetch 25LIBS= -linstall -lnetpgpverify -larchive -lbz2 -lz -lfetch
26.if !empty(SSL_SUPPORT) 26.if !empty(SSL_SUPPORT)
27LIBS+= -lssl -lcrypto 27LIBS+= -lssl -lcrypto
28CPPFLAGS+= -DHAVE_SSL 28CPPFLAGS+= -DHAVE_SSL
29.endif 29.endif
30LIBS+= @LIBS@ 30LIBS+= @LIBS@
31.else 31.else
32LIBS= -linstall ${STATIC_LIBARCHIVE} @LIBS@ 32LIBS= -linstall ${STATIC_LIBARCHIVE} ${STATIC_LIBARCHIVE_LDADD} @LIBS@
33CPPFLAGS+= -DBOOTSTRAP 33CPPFLAGS+= -DBOOTSTRAP
34.endif 34.endif
35 35
36INSTALL= @INSTALL@ 36INSTALL= @INSTALL@
37 37
38PROG= pkg_add 38PROG= pkg_add
39 39
40OBJS= main.o perform.o 40OBJS= main.o perform.o
41 41
42all: $(PROG) 42all: $(PROG)
43 43
44.c.o: 44.c.o:
45 $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $< 45 $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $<

cvs diff -r1.29 -r1.30 pkgsrc/pkgtools/pkg_install/files/create/Makefile.in (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/create/Makefile.in 2015/12/27 12:36:42 1.29
+++ pkgsrc/pkgtools/pkg_install/files/create/Makefile.in 2020/10/28 16:52:43 1.30
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile.in,v 1.29 2015/12/27 12:36:42 joerg Exp $ 1# $NetBSD: Makefile.in,v 1.30 2020/10/28 16:52:43 maya Exp $
2 2
3srcdir= @srcdir@ 3srcdir= @srcdir@
4 4
5prefix= @prefix@ 5prefix= @prefix@
6exec_prefix= @exec_prefix@ 6exec_prefix= @exec_prefix@
7sbindir= @sbindir@ 7sbindir= @sbindir@
8mandir= @mandir@ 8mandir= @mandir@
9datarootdir= @datarootdir@ 9datarootdir= @datarootdir@
10 10
11man1dir= $(mandir)/man1 11man1dir= $(mandir)/man1
12cat1dir= $(mandir)/cat1 12cat1dir= $(mandir)/cat1
13 13
14BOOTSTRAP= @bootstrap@ 14BOOTSTRAP= @bootstrap@
@@ -23,27 +23,27 @@ INSTALL= @INSTALL@ @@ -23,27 +23,27 @@ INSTALL= @INSTALL@
23 23
24PROG= pkg_create 24PROG= pkg_create
25 25
26SSL_SUPPORT= @ssl_support@ 26SSL_SUPPORT= @ssl_support@
27CPPFLAGS= @CPPFLAGS@ -I. -I$(srcdir) -I../lib 27CPPFLAGS= @CPPFLAGS@ -I. -I$(srcdir) -I../lib
28OBJS= main.o perform.o pl.o util.o build.o 28OBJS= main.o perform.o pl.o util.o build.o
29 29
30.if empty(BOOTSTRAP) 30.if empty(BOOTSTRAP)
31LIBS= -linstall -lnetpgpverify -larchive -lbz2 -lz -lfetch @LIBS@ 31LIBS= -linstall -lnetpgpverify -larchive -lbz2 -lz -lfetch @LIBS@
32.if !empty(SSL_SUPPORT) 32.if !empty(SSL_SUPPORT)
33LIBS+= -lssl -lcrypto 33LIBS+= -lssl -lcrypto
34.endif 34.endif
35.else 35.else
36LIBS= -linstall ${STATIC_LIBARCHIVE} @LIBS@ 36LIBS= -linstall ${STATIC_LIBARCHIVE} ${STATIC_LIBARCHIVE_LDADD} @LIBS@
37CPPFLAGS+= -DBOOTSTRAP 37CPPFLAGS+= -DBOOTSTRAP
38.endif 38.endif
39 39
40all: $(PROG) 40all: $(PROG)
41 41
42.c.o: 42.c.o:
43 $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $< 43 $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -c $<
44 44
45$(PROG): $(OBJS) 45$(PROG): $(OBJS)
46 $(CCLD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 46 $(CCLD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
47 47
48clean: 48clean:
49 rm -f $(OBJS) $(PROG) 49 rm -f $(OBJS) $(PROG)