Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 700884 - sys-libs/musl-1.1.24 : static libraries have all one object file with "no machine" instead of "ARM"
Summary: sys-libs/musl-1.1.24 : static libraries have all one object file with "no mac...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Anthony Basile
Depends on: 724484
  Show dependency tree
Reported: 2019-11-21 13:45 UTC by Johannes Geiss
Modified: 2022-06-18 00:52 UTC (History)
5 users (show)

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


Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Geiss 2019-11-21 13:45:10 UTC
Building a cross development system with the current (1.1.24) musl produces unusable static libraries.

Reproducible: Always

Steps to Reproduce:
export CT=armv7el-unknown-linux-musleabihf
crossdev --stable -oS gentoo -oO /usr/local/portage --target $CT

cat >HelloWorld.c <<EOF
#include <stdio.h>

int main(void)
    puts("Hello World!");
    return 0;

$CT-gcc -o HelloWorld HelloWorld.c
$CT-gcc -static -o HelloWorld HelloWorld.c

Actual Results:  
/usr/libexec/gcc/armv7el-unknown-linux-musleabihf/ld: skipping incompatible /usr/armv7el-unknown-linux-musleabihf/usr/lib/libc.a when searching for -lc

Expected Results:  
Static executable without the linking error.

Portage 2.3.76 (python 3.6.9-final-0, default/linux/amd64/17.1/desktop, gcc-9.2.0, glibc-2.29-r2, 4.19.82-gentoo-johannes-pc-linux x86_64)
System uname: Linux-4.19.82-gentoo-johannes-pc-linux-x86_64-Intel-R-_Core-TM-_i5-2500K_CPU_@_3.30GHz-with-gentoo-2.6
KiB Mem:     8069840 total,   2990700 free
KiB Swap:   16777212 total,  15815556 free
Timestamp of repository gentoo: Mon, 18 Nov 2019 08:15:01 +0000
Head commit of repository gentoo: fc591dd5e99544c66ce2308890dd033139394436
sh bash 4.4_p23-r1
ld GNU ld (Gentoo 2.32 p2) 2.32.0
app-shells/bash:          4.4_p23-r1::gentoo
dev-java/java-config:     2.2.0-r4::gentoo
dev-lang/perl:            5.28.2-r1::gentoo
dev-lang/python:          2.7.16::gentoo, 3.6.9::gentoo
dev-util/cmake:           3.14.6::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.32-r1::gentoo
sys-devel/gcc:            9.2.0-r2::gentoo
sys-devel/gcc-config:     2.1::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 4.19::gentoo (virtual/os-headers)
sys-libs/glibc:           2.29-r2::gentoo

    location: /usr/local/portage
    masters: gentoo
    priority: 10

    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://
    priority: 20
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1

    location: /var/lib/layman/pentoo
    masters: gentoo
    priority: 50

CFLAGS="-O2 -pipe -fno-stack-protector"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/gnupg/qualified.txt /var/bind"
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="-O2 -pipe -fno-stack-protector"
EMERGE_DEFAULT_OPTS="--alphabetical --nospinner --quiet-build --usepkg=y --binpkg-respect-use=y --verbose-conflicts --getbinpkg=y"
FCFLAGS="-O2 -pipe -fno-stack-protector"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg clean-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -fno-stack-protector"
INSTALL_MASK=" /usr/share/rocksndiamonds/levels"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
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"
USE="X Xaw3 a52 acl acpi alsa amd64 berkdb bluetooth boost branding bzip2 cairo calendar cdda cdr cjk cli collada colorio cron crypt css cups curl cxx cycles dbus declarative designer device-mapper dillo dlz doomsday dovecot-sasl dri drm dts dvd dvdr dvi dvi2tty efi-64 emboss encode exif expat extensions extras fam fastcgi fat fdk ffmpeg fftw flac fontconfig fortran fpm fuse gbm gd gdbm gflags gif gimp gmp gnuefi gphoto2 gpm graphics gtk hfs iconv icu id3tag imagemagick imap importd infinality ipv6 java jemalloc jfs joystick jpeg jpeg2k kdrive kpathsea latex lcms libass libkms libnotify libtirpc libxml2 lightdm llvm lzma mad man mdnsresponder-compat midi mikmod minizip mng mod mp3 mp4 mpeg multicall multilib musicbrainz ncurses nfs nfsv3 nfsv4 nfsv41 nls nptl nsplugin nss ntfs ntfsprogs objc ocr odbc ogg openexr opengl openimageio openmp pango pcre pdf pdo player png policykit postproc ppds printsupport pstricks pulseaudio python qmax qml qt5 readline reiser4 rss sasl sbcl science scripttools sdl seccomp secure-delete server sid sieve sndfile sound spell split-usr sqlite srt ssl startup-notification static-user svc svg system-cairo system-harfbuzz system-icu system-jpeg system-libevent system-libvpx system-sqlite systemd taglib tcpd theora threads tiff timidity truetype twolame udev udisks unicode upnp upower usb vamp videos vnc vorbis vpx warmstarts webkit widgets winbind wxwidgets x264 xattr xcb xetex xface xfs xft xml xmlreader xmlwriter xpm xv xvid zip zlib" ABI_X86="64" ADA_TARGET="gnat_2018" 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="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx f16c mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev keyboard mouse" KERNEL="linux" L10N="en en-US de de-DE" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LIRC_DEVICES="macmini" NETBEANS_MODULES="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" QEMU_USER_TARGETS="arm ppc" RUBY_TARGETS="ruby24 ruby25" USERLAND="GNU" VIDEO_CARDS="intel" 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"
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2019-11-21 17:23:12 UTC
I think musl will need an equivalent of strip avoidance:
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2019-11-21 17:24:42 UTC
As a workaround you can rebuild cross-musl package with FEATURES=nostrip to get working objects.
Comment 3 tt_1 2020-03-13 19:54:09 UTC
was this fixed in musl-1.2.0?
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2020-03-13 22:33:46 UTC
If you see no activity in the bug and no equivalent of:

    # Avoid stripping binaries not targeted by ${CHOST}. Or else
    # ${CHOST}-strip would break binaries build for ${CTARGET}.
    is_crosscompile && dostrip -x /

in the ebuild then probably not. Especially given that ebuild is EAPI=6.
Comment 5 Jory A. Pratt gentoo-dev 2020-05-21 00:21:35 UTC
Wed May 20 19:19
anarchy@bull ~ $ file HelloWorld
HelloWorld: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/, not stripped
Wed May 20 19:20
anarchy@bull ~ $ rm HelloWorld
Wed May 20 19:20
anarchy@bull ~ $ aarch64-gentoo-linux-musl-gcc -static -o HelloWorld HelloWorld.c
Wed May 20 19:20
anarchy@bull ~ $ file HelloWorld
HelloWorld: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped

I am unable to reproduce with aarch64, I will test with my armv7a toolchain and see if I can duplicate this there.
Comment 6 Jory A. Pratt gentoo-dev 2020-05-21 00:50:19 UTC
Wed May 20 19:48
anarchy@bull ~ $ armv7a-gentoo-linux-musleabihf-gcc -static -o HelloWorld-Static HelloWorld.c
Wed May 20 19:48
anarchy@bull ~ $ armv7a-gentoo-linux-musleabihf-gcc -o HelloWorld HelloWorld.c
Wed May 20 19:48
anarchy@bull ~ $ file HelloWorld*
HelloWorld:        ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/, not stripped
HelloWorld-Static: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped

Please crossdev -C armv7el-unknown-linux-musleabihf start fresh and test again. I am unable to duplicate even with the armv7a cross toolchain.
Comment 7 Michael 'veremitz' Everitt 2020-05-21 01:20:58 UTC
> /usr/libexec/gcc/armv7el-unknown-linux-musleabihf/ld: skipping incompatible
> /usr/armv7el-unknown-linux-musleabihf/usr/lib/libc.a when searching for -lc

Looks to me like a toolchain issue...
Comment 8 Sergei Trofimovich (RETIRED) gentoo-dev 2020-05-21 06:25:11 UTC
To be able to reproduce it you need your host binutils built with USE=-multitarget.
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2020-05-21 07:00:28 UTC
# PORTDIR_OVERLAY=/co crossdev -oO /co -t armv7a-gentoo-linux-musleabihf

 * crossdev version:      20200125
 * Host Portage ARCH:     amd64
 * Host Portage System:   x86_64-pc-linux-gnu (i686-pc-linux-gnu x86_64-pc-linux-gnu)
 * Target Portage ARCH:   arm
 * Target System:         armv7a-gentoo-linux-musleabihf
 * Stage:                 4 (C/C++ compiler)
 * USE=multilib:          no
 * Target ABIs:           default

 * binutils:              binutils-[latest]
 * gcc:                   gcc-[latest]
 * headers:               linux-headers-[latest]
 * libc:                  musl-[latest]

 * PORT_LOGDIR:           /var/log/portage
 * Portage flags:

 * leaving sys-devel/binutils in /co
 * leaving sys-devel/gcc in /co
 * leaving sys-kernel/linux-headers in /co
 * leaving sys-libs/musl in /co
 * leaving sys-devel/gdb in /co
 * enabling thin-manifests due to /bound/portage

The good hint is usually complains of binutils to try to strip it:

# LANG=C PORTDIR_OVERLAY=/co emerge -v1 cross-armv7a-gentoo-linux-musleabihf/musl
x86_64-pc-linux-gnu-strip: Unable to recognise the format of the input file `/var/tmp/portage/cross-armv7a-gentoo-linux-musleabihf/musl-1.2.0/image/usr/armv7a-gentoo-linux-musleabihf/usr/lib/libc.a(aio.lo)'
x86_64-pc-linux-gnu-strip: Unable to recognise the format of the input file `/var/tmp/portage/cross-armv7a-gentoo-linux-musleabihf/musl-1.2.0/image/usr/armv7a-gentoo-linux-musleabihf/usr/lib/libc.a(aio_suspend.lo)'
x86_64-pc-linux-gnu-strip: Unable to recognise the format of the input file `/var/tmp/portage/cross-armv7a-gentoo-linux-musleabihf/musl-1.2.0/image/usr/armv7a-gentoo-linux-musleabihf/usr/lib/libc.a(lio_listio.lo)'

Wrong strip should never be ran on binaries it does not understand. was another instance of this bug.