I want to compile sci-biology/emboss package statically. The Gentoo manuals are quiet on examples how LDFLAGS could be tweaked for this purpose. It seems the proper way would be: export LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-static" FEATURES=noclean USE="static static-libs minimal -png -X -mysql -pdf -png" emerge emboss See also https://superuser.com/questions/657152/gentoo-ldflags-optimizations-really-needed/683691 but I get the following: configure:2787: checking whether the C compiler works configure:2809: x86_64-pc-linux-gnu-gcc -O2 -pipe -O2 -pipe -march=native -ftree-vectorize -Wl,-O1 -Wl,--as-needed -Wl,-static conftest.c >&5 /apps/gentoo/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lgcc_s /apps/gentoo/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lgcc_s collect2: error: ld returned 1 exit status configure:2813: $? = 1 configure:2851: result: no configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "EMBOSS" | #define PACKAGE_TARNAME "EMBOSS" | #define PACKAGE_VERSION "6.6.0" | #define PACKAGE_STRING "EMBOSS 6.6.0" | #define PACKAGE_BUGREPORT "emboss-bug@emboss.open-bio.org" | #define PACKAGE_URL "http://emboss.open-bio.org/" | /* end confdefs.h. */ | | int | main () | { | | ; | return 0; | } configure:2856: error: in `/apps/gentoo/var/tmp/portage/sci-biology/emboss-6.6.0-r1/work/EMBOSS-6.6.0': configure:2858: error: C compiler cannot create executables The following ... works? export LDFLAGS="-Wl,-O1 -Wl,--as-needed -static" FEATURES=noclean USE="static static-libs minimal -png -X -mysql -pdf -png" emerge emboss but gives me only the emboss-internal libs linked in statically, the rest is linked dynamically although the *.a file do exist (I emerged the dev-libs/ packages with USE="static-libs"). $ ldd /apps/gentoo/usr/bin/water linux-vdso.so.1 (0x00007ffff7fb4000) libexpat.so.1 => /apps/gentoo/usr/lib64/libexpat.so.1 (0x00007ffff75e7000) libpcre.so.1 => /apps/gentoo/usr/lib64/libpcre.so.1 (0x00007ffff7371000) libz.so.1 => /apps/gentoo/usr/lib64/libz.so.1 (0x00007ffff715a000) libplplot.so.14 => /apps/gentoo/usr/lib64/libplplot.so.14 (0x00007ffff6eec000) libm.so.6 => /apps/gentoo/lib64/libm.so.6 (0x00007ffff6bd6000) libc.so.6 => /apps/gentoo/lib64/libc.so.6 (0x00007ffff6820000) libpthread.so.0 => /apps/gentoo/lib64/libpthread.so.0 (0x00007ffff6601000) libltdl.so.7 => /apps/gentoo/usr/lib64/libltdl.so.7 (0x00007ffff63f7000) libfreetype.so.6 => /apps/gentoo/usr/lib64/libfreetype.so.6 (0x00007ffff6139000) libcsirocsa.so.0 => /apps/gentoo/usr/lib64/libcsirocsa.so.0 (0x00007ffff5f31000) libqsastime.so.0 => /apps/gentoo/usr/lib64/libqsastime.so.0 (0x00007ffff5d2b000) /apps/gentoo/lib64/ld-linux-x86-64.so.2 (0x00007ffff7819000) libdl.so.2 => /apps/gentoo/lib64/libdl.so.2 (0x00007ffff5b27000) libbz2.so.1 => /apps/gentoo/usr/lib64/libbz2.so.1 (0x00007ffff5915000) libpng16.so.16 => /apps/gentoo/usr/lib64/libpng16.so.16 (0x00007ffff56dd000) $ $ ls -latr /apps/gentoo/usr/lib64/libpcre*.{so,a} -rw-r--r-- 1 mmokrejs mmokrejs 711026 Mar 1 12:13 /apps/gentoo/usr/lib64/libpcre2-8.a -rw-r--r-- 1 mmokrejs mmokrejs 664572 Mar 1 12:13 /apps/gentoo/usr/lib64/libpcre2-16.a -rw-r--r-- 1 mmokrejs mmokrejs 7226 Mar 1 12:13 /apps/gentoo/usr/lib64/libpcre2-posix.a lrwxrwxrwx 1 mmokrejs mmokrejs 23 Mar 1 12:13 /apps/gentoo/usr/lib64/libpcre2-posix.so -> libpcre2-posix.so.2.0.0 lrwxrwxrwx 1 mmokrejs mmokrejs 19 Mar 1 12:13 /apps/gentoo/usr/lib64/libpcre2-8.so -> libpcre2-8.so.0.7.0 lrwxrwxrwx 1 mmokrejs mmokrejs 20 Mar 1 12:13 /apps/gentoo/usr/lib64/libpcre2-16.so -> libpcre2-16.so.0.7.0 -rw-r--r-- 1 mmokrejs mmokrejs 650236 Mar 1 13:57 /apps/gentoo/usr/lib64/libpcre.a -rw-r--r-- 1 mmokrejs mmokrejs 7048 Mar 1 13:57 /apps/gentoo/usr/lib64/libpcreposix.a -rw-r--r-- 1 mmokrejs mmokrejs 53324 Mar 1 13:57 /apps/gentoo/usr/lib64/libpcrecpp.a lrwxrwxrwx 1 mmokrejs mmokrejs 19 Mar 1 13:58 /apps/gentoo/usr/lib64/libpcrecpp.so -> libpcrecpp.so.0.0.1 lrwxrwxrwx 1 mmokrejs mmokrejs 21 Mar 1 13:58 /apps/gentoo/usr/lib64/libpcreposix.so -> libpcreposix.so.0.0.5 lrwxrwxrwx 1 mmokrejs mmokrejs 16 Mar 1 13:58 /apps/gentoo/usr/lib64/libpcre.so -> libpcre.so.1.2.9 $ $ grep water /apps/gentoo/var/tmp/portage/sci-biology/emboss-6.6.0-r1/temp/build.log x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../ajax/core -I../ajax/acd -I../ajax/ajaxdb -I../ajax/core -I../ajax/ensembl -I../ajax/graphics -I../nucleus -DNO_AUTH -DAJ_LinuxLF -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/apps/gentoo/usr/include/plplot -O2 -pipe -O2 -pipe -march=native -ftree-vectorize -O2 -c -o water.o water.c /apps/gentoo/bin/bash ../libtool --tag=CC --mode=link x86_64-pc-linux-gnu-gcc -I/apps/gentoo/usr/include/plplot -O2 -pipe -O2 -pipe -march=native -ftree-vectorize -O2 -Wl,-O1 -Wl,--as-needed -static -o water water.o ../nucleus/libnucleus.la ../ajax/acd/libacd.la ../ajax/ajaxdb/libajaxdb.la ../ajax/ensembl/libensembl.la ../ajax/graphics/libajaxg.la ../ajax/core/libajax.la -lexpat -lpcre -lz -lplplot -lm libtool: link: x86_64-pc-linux-gnu-gcc -I/apps/gentoo/usr/include/plplot -O2 -pipe -O2 -pipe -march=native -ftree-vectorize -O2 -Wl,-O1 -o water water.o -Wl,--as-needed ../nucleus/.libs/libnucleus.a /apps/gentoo/var/tmp/portage/sci-biology/emboss-6.6.0-r1/work/EMBOSS-6.6.0/ajax/ajaxdb/.libs/libajaxdb.a /apps/gentoo/var/tmp/portage/sci-biology/emboss-6.6.0-r1/work/EMBOSS-6.6.0/ajax/acd/.libs/libacd.a ../ajax/acd/.libs/libacd.a /apps/gentoo/var/tmp/portage/sci-biology/emboss-6.6.0-r1/work/EMBOSS-6.6.0/ajax/graphics/.libs/libajaxg.a ../ajax/ajaxdb/.libs/libajaxdb.a /apps/gentoo/var/tmp/portage/sci-biology/emboss-6.6.0-r1/work/EMBOSS-6.6.0/ajax/ensembl/.libs/libensembl.a ../ajax/ensembl/.libs/libensembl.a ../ajax/graphics/.libs/libajaxg.a /apps/gentoo/var/tmp/portage/sci-biology/emboss-6.6.0-r1/work/EMBOSS-6.6.0/ajax/core/.libs/libajax.a ../ajax/core/.libs/libajax.a -lexpat -lpcre -lz -lplplot -lm As you can see, libtools discarded the "-static", hence I assume I really should have used "-Wl,-static" like I tried initially. So what is wrong with my gcc-7.3.0?
$ emerge --info Portage 2.3.24 (python 2.7.14-final-0, default/linux/amd64/17.0/no-multilib/prefix/kernel-3.2+, gcc-7.3.0, glibc-2.25-r10, 2.6.32-696.20.1.el6.x86_64 x86_64) ================================================================= System uname: Linux-2.6.32-696.20.1.el6.x86_64-x86_64-Intel-R-_Xeon-R-_CPU_E5-2695_v3_@_2.30GHz-with-centos-6.9-Final KiB Mem: 132048928 total, 46915228 free KiB Swap: 2097148 total, 2095420 free Timestamp of repository gentoo: Tue, 20 Feb 2018 14:00:01 +0000 Head commit of repository gentoo: 1f64762ca074542f9da3dc71e84b0d68c75dca06 sh bash 4.4_p19 ld GNU ld (Gentoo 2.30 p1) 2.30.0 app-shells/bash: 4.4_p19::gentoo dev-java/java-config: 2.2.0-r3::gentoo dev-lang/perl: 5.26.1-r1::gentoo dev-lang/python: 2.7.14-r1::gentoo, 3.4.6::gentoo, 3.5.4-r1::gentoo, 3.6.4::gentoo dev-util/cmake: 3.10.2::gentoo dev-util/pkgconfig: 0.29.2::gentoo sys-apps/baselayout: 2.4.1-r2::gentoo sys-apps/sandbox: 2.13::gentoo sys-devel/autoconf: 2.13::gentoo, 2.69-r4::gentoo sys-devel/automake: 1.14.1-r1::gentoo, 1.15.1-r1::gentoo sys-devel/binutils: 2.29.1-r1::gentoo, 2.30::gentoo sys-devel/gcc: 3.4.6-r2::gentoo, 4.1.2::gentoo, 4.2.4-r1::gentoo, 4.4.7::gentoo, 4.5.4::gentoo, 4.7.4::gentoo, 4.8.5::gentoo, 4.9.3::gentoo, 4.9.4::gentoo, 5.4.0-r4::gentoo, 6.3.0::gentoo, 7.1.0-r1::gentoo, 7.2.0-r1::gentoo, 7.3.0::gentoo sys-devel/gcc-config: 1.9.1::gentoo sys-devel/libtool: 2.4.6-r4::gentoo sys-devel/make: 4.2.1-r2::gentoo sys-kernel/linux-headers: 4.15::gentoo (virtual/os-headers) sys-libs/glibc: 2.25-r10::gentoo Repositories: gentoo location: /apps/gentoo/usr/portage sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 sync-rsync-verify-metamanifest: yes sync-rsync-extra-opts: haskell location: /apps/gentoo/var/lib/layman/haskell masters: gentoo priority: 50 science location: /apps/gentoo/var/lib/layman/science masters: gentoo priority: 50 ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="* -@EULA dlj-1.1 sun-bcla-java-vm Oracle-BCLA-JavaSE IBM-J1.6 skype-eula Nero-EULA-US AdobeFlash-10.3 skype-4.0.0.7-copyright AdobeFlash-11.x Intel-SDP OPERA-2014" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-O2 -pipe -O2 -pipe -march=native -ftree-vectorize" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /usr/share/maven-bin-3.3/conf" CONFIG_PROTECT_MASK="/apps/gentoo/etc/gentoo-release /etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /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="-O2 -pipe -O2 -pipe -march=native -ftree-vectorize" DISTDIR="/apps/gentoo/usr/portage/distfiles" FCFLAGS="-O2 -pipe" FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles force-prefix merge-sync multilib-strict news nostrip parallel-fetch preserve-libs protect-owned sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans unprivileged" FFLAGS="-O2 -pipe" GENTOO_MIRRORS="http://ftp.fi.muni.cz/pub/linux/gentoo/ http://gentoo.mirror.web4u.cz/ rsync://gentoo.mirror.dkm.cz/gentoo/ ftp://gentoo.mirror.web4u.cz/" LDFLAGS="-Wl,-O1 -Wl,--as-needed -static" LINGUAS="en_US en_GB en cs" MAKEOPTS="-j4" PKGDIR="/apps/gentoo/usr/portage/packages" PORTAGE_CONFIGROOT="/apps/gentoo/" 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="/apps/gentoo/var/tmp" USE="X alsa amd64 apache apache2 avx avx2 berkdb boost bzip2 cairo cgi cli coin cracklib crypt cryptlib cxx dbus device-mapper dhcp dri emboss encode fax fbcon ffmpeg fontconfig fortran gbm gd gdbm gimp glpk gnutls gtk hal hwdb iconv imaging innodb ithreads java javafx javascript jce jpeg jpg js jscript keymap ladspa lapack lcms libnotify lm_sensors mad mmx modules mpi mpich2 mysql ncurses nfs nls nptl nptlonly nscd objc openmp openssl pcre pdf perl php png policykit polkit postscript ppds pppd prefix python qt3support readline resolvconf seccomp server session slideshow sndfile sqlite sse sse2 sse3 sse4_1 sse4_2 ssl ssse3 static-libs suexec svg syslog tcl tcpd threads tiff tk truetype unicode usb v4l v4l2 vim-syntax vnc wavpack wifi x11 xcb xml xorg xrandr xv xvid xvmc 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" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-0" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_5" RUBY_TARGETS="ruby24 ruby25" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" 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" Unset: CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Created attachment 521732 [details] build.log
Created attachment 521734 [details] config.log
And with the incomplete documentation I meant https://wiki.gentoo.org/wiki/GCC_optimization#What_about_LDFLAGS.3F although I re-read some other Gentoo-hosted pages. The attached build.log and config.log are from the second attempt mentioned, giving me partly statically-linked binaries. I assume this attemnpt is not proper way to achieve static binariesbut as I sai, the first approach break much earlier (see $subject).
$ emerge -pv sys-devel/gcc These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild R ] sys-devel/gcc-7.3.0:7.3.0::gentoo USE="cxx fortran nls nptl objc openmp pch (pie) sanitize ssp vtv (-altivec) (-awt) -cilk -debug -doc (-fixed-point) (-gcj) -go -graphite (-hardened) (-jit) (-libssp) -mpx (-multilib) -objc++ -objc-gc -pgo -regression-test (-vanilla)" 0 KiB Total: 1 package (1 reinstall), Size of downloads: 0 KiB
(In reply to Martin Mokrejš from comment #0) > I want to compile sci-biology/emboss package statically. The Gentoo manuals > are quiet on examples how LDFLAGS could be tweaked for this purpose. > > It seems the proper way would be: > > export LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-static" LDFLAGS=-Wl,-static is not correct LDFLAGS=-static is. gcc's driver needs to decide how -lgcc is to ge used: as a shared library (libgcc_s.so, default) or a static library (libgcc.a, used with 'gcc -static' or -static-libgcc). With -Wl,-static you bypass gcc's driver and trick it into dynamic linking of libgcc.