Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 591096 - app-arch/libarchive-3.2.1-r5: USE=static-libs does not result in statically linked binaries
Summary: app-arch/libarchive-3.2.1-r5: USE=static-libs does not result in statically l...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo/BSD Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-12 08:40 UTC by Klaus Kusche
Modified: 2017-07-14 19:46 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Klaus Kusche 2016-08-12 08:40:20 UTC
According to bug 458500 (which is marked resolved fixed), 
USE=static-libs should result in statically linked bsdtar & bsdcpio.

It does not:
app-arch/libarchive-3.2.1-r5:0/13::gentoo  USE="bzip2 e2fsprogs expat iconv libressl lz4 lzma lzo static-libs threads xattr zlib -acl -nettle"

ldd /usr/bin/bsdtar
	linux-vdso.so.1 (0x000003be07929000)
	libarchive.so.13 => /usr/lib64/libarchive.so.13 (0x000003be07430000)
	libcrypto.so.38 => /usr/lib64/libcrypto.so.38 (0x000003be07012000)
	libexpat.so.1 => /usr/lib64/libexpat.so.1 (0x000003be06de1000)
	liblzo2.so.2 => /lib64/liblzo2.so.2 (0x000003be06baf000)
	liblzma.so.5 => /lib64/liblzma.so.5 (0x000003be0697b000)
	liblz4.so.1 => /usr/lib64/liblz4.so.1 (0x000003be0675f000)
	libbz2.so.1 => /lib64/libbz2.so.1 (0x000003be0654a000)
	libz.so.1 => /lib64/libz.so.1 (0x000003be0632e000)
	libc.so.6 => /lib64/libc.so.6 (0x000003be05f90000)
	libresolv.so.2 => /lib64/libresolv.so.2 (0x000003be05d79000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x000003be05b5d000)
	/lib64/ld-linux-x86-64.so.2 (0x000003be07709000)

A statically linked bsdtar is needed for system recovery purposes.

emerge --info
Portage 2.3.0 (python 2.7.12-final-0, default/linux/amd64/13.0/no-multilib, gcc-5.4.0, glibc-2.23-r2, 4.6.5-hardened-r1 x86_64)
=================================================================
System uname: Linux-4.6.5-hardened-r1-x86_64-Intel-R-_Core-TM-_i7-3940XM_CPU_@_3.00GHz-with-gentoo-2.2
KiB Mem:    32902668 total,  31256928 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Wed, 10 Aug 2016 03:50:01 +0000
sh bash 4.3_p46
ld GNU ld (Gentoo 2.26.1 p1.0) 2.26.1
app-shells/bash:          4.3_p46::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.24.0-r1::gentoo
dev-lang/python:          2.7.12::gentoo, 3.5.2::gentoo
dev-util/cmake:           3.6.1::gentoo
dev-util/pkgconfig:       0.29.1::gentoo
sys-apps/baselayout:      2.2-r1::gentoo
sys-apps/openrc:          0.21.3::gentoo
sys-apps/sandbox:         2.10-r2::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r2::gentoo
sys-devel/automake:       1.13.4-r1::gentoo, 1.14.1-r1::gentoo, 1.15-r2::gentoo
sys-devel/binutils:       2.26.1::gentoo
sys-devel/gcc:            5.4.0::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r2::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.7::gentoo (virtual/os-headers)
sys-libs/glibc:           2.23-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.de.gentoo.org/gentoo-portage
    priority: -1000

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA dlj-1.1 AdobeFlash-11.x Oracle-BCLA-JavaSE google-chrome googleearth Vivaldi FraunhoferFDK"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -mtune=native -flto -fuse-linker-plugin -O3 -fomit-frame-pointer -fweb -ftracer -fivopts -frename-registers -maccumulate-outgoing-args -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -mtune=native -flto -fuse-linker-plugin -O3 -fomit-frame-pointer -fweb -ftracer -fivopts -frename-registers -maccumulate-outgoing-args -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--quiet-build --quiet-fail --with-bdeps=y"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs collision-protect config-protect-if-modified distlocks ebuild-locks fixlafiles keeptemp keepwork merge-sync news noclean parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://linux.rz.rub.de/download/gentoo-mirror http://ftp.spline.inf.fu-berlin.de/mirrors/gentoo http://distfiles.gentoo.org"
LANG="en_DE.iso885915"
LC_ALL="en_DE.iso885915"
LDFLAGS="-march=native -mtune=native -flto -fuse-linker-plugin -O3 -fomit-frame-pointer -fweb -ftracer -fivopts -frename-registers -maccumulate-outgoing-args -pipe"
MAKEOPTS="-j8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/portage"
USE="64bit X a52 aac adobe-cff alsa amd64 apng applet archive ass avx bzip2 cairo cdda cdparanoia clang cli clipboard clockdiff contrast cups curl cxx dbus dconf demosaic detex devfs-compat dga divx dns dot dri dri3 drm dts dvd dvdnav dvdr dvi dvipdfm egl encode epspdf exif expat extra faad fdk ffmpeg fftw flac fontconfig foomaticdb fts3 g3dvl gallium gbm gdk-pixbuf gegl gif gimp glamor gles gles1 gles2 glib glibc-omitfp gmp graphics gs gstreamer gtk gtk2 gudev harfbuzz hpack-tools hpn htmlreport http http2 hwdb iconv icu imagemagick inotify javascript jbig jemalloc jemalloc3 jit jpeg jpeg2k kpathsea lasi latex latex3 lcdfilter lcms leaps_timezone lensfun libkms libnotify libopts libressl libsamplerate libwww lightning llvm llvm-gcc llvm-shared-libs lz4 lzma lzo mad metric midi minizip mmap mms mmx mmxext mng modern-top modules mp3 mpeg mpfr mta mudflap multicall natspec ncat ncurses ndiff nping nptl nscd nsplugin offensive ogg oldnet opencl opengl openmax openmp openvg opus orc pam pango pax_kernel pcap pcre pdf pic plugins png policykit postproc postscript ppds proprietary-codecs pstricks pth ptpax quicktime r600-llvm-compiler rar raw readline realmedia right_timezone rle rpc rtc rule_generator sanitize scanner schroedinger scope seccomp secure-delete session smp sndfile sound sqlite sqlite3 sse sse2 sse3 sse4 sse4_1 sse4_2 ssh ssl ssse3 svc svg symlink sync-plugin-portage system-cairo system-ffmpeg system-harfbuzz system-icu system-jpeg system-jsoncpp system-libevent system-libvpx system-sqlite systemd t1lib texi2html theora threads thunar tiff tools tracepath tremor truetype udev udisks unicode unlock-notify unwind usb user-session utils v4l v4l2 vaapi vdpau vim-with-x vorbis vpx webkit2 webp wext wifi wmf wmp wxwidgets x264 x265 xa xattr xcb xcomposite xetex xkb xmp xorg xpm xrandr xtpax xulrunner xv xvid xvmc zenmap zip zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" CURL_SSL="libressl" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard evdev synaptics" KERNEL="linux" L10N="en" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer pdfimport" LINGUAS="en" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python3_5 python2_7" RUBY_TARGETS="ruby22" SANE_BACKENDS="epson" USERLAND="GNU" VIDEO_CARDS="radeon radeonsi amdgpu" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
USE_PYTHON="2.7"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Felix Janda 2016-08-12 09:43:39 UTC
The static-libs use flag controls whether libarchive.a is built or not.
The non-existing static use flag would control whether bsdtar is linked
statically. It does not seem too difficult to add support for static
linking to the ebuild.
Comment 2 Klaus Kusche 2016-08-12 10:37:23 UTC
(In reply to Felix Janda from comment #1)
> The static-libs use flag controls whether libarchive.a is built or not.
> The non-existing static use flag would control whether bsdtar is linked
> statically. It does not seem too difficult to add support for static
> linking to the ebuild.

That was my understanding of "static" and "static-libs", too.

But according to bug 458500, at least in 2013 when that bug was fixed,
"static-libs" for libarchive resulted in both static lib's and static exe's,
and the ability to build static exe's was lost since then.

Of course you may split that into separate "static" and "static-libs" flags.
Comment 3 Klaus Kusche 2016-08-12 10:56:54 UTC
Hmmm, it's not just a one-liner in the ebuild, it needs a closer look...

I changed 
--enable-bsdtar=$(tc-is-static-only && echo static || echo shared)
to
--enable-bsdtar=static
in the ebuild and re-emerged.

According to the build log, libtool is called with --static for linking bsdtar,
but libtool still builds a dynamically linked bsdtar, 
although the corresponding .a libs exist in /usr/lib.
Comment 4 Felix Janda 2016-08-12 13:11:48 UTC
Passing -static to libtool does not seem to produce static binaries.
In this case I think that just libarchive is linked statically into
bsdtar. Instead the flag -all-static is required. After replacing
-static by -all-static in the Makefile.am, the upstream build system
indeed seems to produce static binaries provided that static versions
of all dependencies are installed.

So a possible fix would be to add a patch for Makefile.am, pass
--enable-bsdtar=static,... when the static use flag is enabled and
the dependencies adjusted. Not quite a one-line change...
Comment 5 Klaus Kusche 2016-08-25 11:49:47 UTC
(In reply to Felix Janda from comment #4)
> Passing -static to libtool does not seem to produce static binaries.
> In this case I think that just libarchive is linked statically into
> bsdtar. Instead the flag -all-static is required. After replacing
> -static by -all-static in the Makefile.am, the upstream build system
> indeed seems to produce static binaries provided that static versions
> of all dependencies are installed.
> 
> So a possible fix would be to add a patch for Makefile.am, pass
> --enable-bsdtar=static,... when the static use flag is enabled and
> the dependencies adjusted. Not quite a one-line change...

As "dar" does not work as expected here 
and Gnu tar offers no way to build a static executable *with compression*:
Any hope to get a fixed (statically linked, including compression libs) 
bsdtar any time soon?
Comment 6 Felix Janda 2016-09-25 17:36:31 UTC
Sorry for the wait. I've just opened a pull request:

https://github.com/gentoo/gentoo/pull/2412
Comment 7 Adam Feldman gentoo-dev 2016-09-26 03:49:33 UTC
(In reply to Felix Janda from comment #6)
> Sorry for the wait. I've just opened a pull request:
> 
> https://github.com/gentoo/gentoo/pull/2412

Thanks for the patch.  I'll see if I can allocate some time in the next couple of days to review it.
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-05-21 12:04:48 UTC
I'm sorry but it's unclear to me from the mail — what is the exact use case for statically linked tar? Static linking is a bad idea in most of the cases, and usually indicates working around some kind of issue.
Comment 9 Klaus Kusche 2017-05-21 13:47:42 UTC
I use bsdtar with compression for system backup and restore,
which means that it should be possible to run bsdtar on a system 
booted from a default live CD or USB stick to restore a crashed / .

And at least at the time this bug report was written,
Gentoo's default live system did not contain all the shared lib's
needed by bsdtar (especially not the compression my backups use), 
so it was impossible to restore my backup
(I didn't check recently if the situation has changed,
I also asked for the lib's to be included on the live system).

In general, all desaster recovery tools should be statically linked
to minimize dependencies and to gurantee stand-alone execution
in a minimal or version-incompatible environment.
Comment 10 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-05-21 13:58:28 UTC
Doesn't busybox have self-sufficient tar+compression tools? bsdtar is not really intended as a 'system recovery tool'.
Comment 11 Klaus Kusche 2017-05-21 14:22:38 UTC
I didn't check busybox, but I don't think so.

Not even standard GNU tar is sufficient!

There are two main criteria:

* Correct backup & restore of xattr's.
I have a hardened system, hence the paxctl attributes of executables
are stored in xattr's, and without correctly restored xattr's,
a restored root file system won't even boot 
(GNU tar has failed here, Schilling's tar also messed xattr's up).

* On-the-fly compression at disk/ssd speed (>= 200 MB/s).
The "standard" compression tools (.z, .bz, .xz, ...) 
typically run at 10 MB/s or less, which is way too slow.
I use lz4, which is fast enough, but not directly supported
by most other tar's.

Moreover, bsdtar directly uses the compression libs
to perform in-process compression without moving the data around, 
whereas most other tar's pipe the data to a separate compression program,
which is significantly slower.
Comment 12 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-07-14 19:46:41 UTC
I'm sorry but I'm not convinced to support static linking here, especially considering that it requires patching the build system. Since nobody else from the team has replied positively for almost a year, I'm going to assume it's not going to get accepted, and so close the bug as WONTFIX.