Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 346953 - sys-apps/busybox: Linker failure during crosscompile (ld called directly)
Summary: sys-apps/busybox: Linker failure during crosscompile (ld called directly)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Embedded Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: portage-multilib
  Show dependency tree
 
Reported: 2010-11-27 13:04 UTC by Thomas Sachau
Modified: 2011-03-27 04:48 UTC (History)
2 users (show)

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


Attachments
build.log for busybox-1.17.4 (sys-apps:busybox-1.17.4:20101127-112634.log,6.11 KB, text/plain)
2010-11-27 13:05 UTC, Thomas Sachau
Details
build.log (sys-apps:busybox-1.18.1:20101222-181506.log,7.87 KB, text/plain)
2010-12-22 18:24 UTC, Thomas Sachau
Details
busybox-1.18.1-ldflags.patch (busybox-1.18.1-ldflags.patch,3.50 KB, text/plain)
2010-12-28 19:48 UTC, Nathan Phillip Brink (binki) (RETIRED)
Details
busybox-1.18.1-ldflags.patch (busybox-1.18.1-ldflags.patch,3.53 KB, patch)
2010-12-30 21:52 UTC, Nathan Phillip Brink (binki) (RETIRED)
Details | Diff
busybox-1.18.3.ebuild-kill-ld.patch (busybox-1.18.3.ebuild-kill-ld.patch,590 bytes, patch)
2011-03-26 21:40 UTC, Nathan Phillip Brink (binki) (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Sachau gentoo-dev 2010-11-27 13:04:54 UTC
sys-apps/busybox-1.17.4 fails do build due to a linker error, when i try to crosscompile a 32bit version on amd64. See attached build.log for details.

emerge --info:

Portage 2.2.0_alpha2-r1 (hardened/linux/amd64/10.0, gcc-4.5.1, glibc-2.12.1-r3, 2.6.36-hardened-r2 x86_64)
=================================================================
System uname: Linux-2.6.36-hardened-r2-x86_64-Intel-R-_Core-TM-2_Quad_CPU_Q6600_@_2.40GHz-with-gentoo-2.0.1
Timestamp of tree: Sat Nov 27 07:39:09 CET 2010
app-shells/bash:     4.1_p9
dev-java/java-config: 2.1.11-r2
dev-lang/python:     2.6.6-r1, 2.7
dev-util/cmake:      2.8.1-r2
sys-apps/baselayout: 2.0.1-r1
sys-apps/openrc:     0.6.5
sys-apps/sandbox:    2.4
sys-devel/autoconf:  2.13, 2.68
sys-devel/automake:  1.4_p6-r1, 1.9.6-r3, 1.10.3, 1.11.1
sys-devel/binutils:  2.20.1-r1
sys-devel/gcc:       4.4.5, 4.5.1-r1
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.4
sys-devel/make:      3.82
virtual/os-headers:  2.6.36.1 (sys-kernel/linux-headers)
Repositories: gentoo java-overlay enlightenment hardened-dev science sunrise multilib Meins
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/home/thomas/daten/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going --backtrack=6"
FEATURES="assume-digests binpkg-logs collision-protect distlocks fixlafiles fixpackages metadata-transfer news parallel-fetch preserve-libs protect-owned sandbox sfperms sign strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox"
GENTOO_MIRRORS="http://ftp.spline.inf.fu-berlin.de/mirrors/gentoo/ ftp://ftp.uni-erlangen.de/pub/mirrors/gentoo ftp://ftp.snt.utwente.nl/pub/os/linux/gentoo"
LANG="de_DE.UTF-8@euro"
LC_ALL="de_DE.UTF-8@euro"
LDFLAGS="-Wl,--as-needed -Wl,--hash-style=gnu"
LINGUAS="de"
MAKEOPTS="-j5 --load-average=8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage/layman/java-overlay /usr/local/portage/layman/enlightenment /usr/local/portage/layman/hardened-development /usr/local/portage/layman/science /usr/local/portage/layman/sunrise /usr/local/portage/layman/multilib /usr/local/portage"
SYNC="cvs://tommy@cvs.gentoo.org:/var/cvsroot"
USE="3dnow X alsa amd64 berkdb cli cracklib crypt cups custom-cflags custom-cxxflags custom-optimization cxx dri gpm hardened java5 java6 justify mmx modules mudflap multilib multilib_abi_amd64 multilib_abi_x86 ncurses nls nptl nptlonly nsplugin ogg opengl openmp pam pic pppd readline scanner session sse sse2 ssl sysfs tcpd unicode urandom vorbis xorg zlib" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="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" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" 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 ubx" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="de" MULTILIB_ABIS="amd64 x86" PHP_TARGETS="php5-2" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia" 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:  CPPFLAGS, CTARGET, FFLAGS, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Thomas Sachau gentoo-dev 2010-11-27 13:05:38 UTC
Created attachment 255577 [details]
build.log for busybox-1.17.4
Comment 2 Thomas Sachau gentoo-dev 2010-12-22 18:23:22 UTC
I now found the var to make the output verbose, which tells me, that the compile calls do just call "gcc" instead of using full gcc name and those calls dont include $CFLAGS, so they create 64bit output. The following linker call then fails due to mixing 64bit/32bit during the attempt to crosscompile busybox.

I will attach a new build.log which shows this issue.

Comment 3 Thomas Sachau gentoo-dev 2010-12-22 18:24:20 UTC
Created attachment 257776 [details]
build.log
Comment 4 Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2010-12-28 19:48:15 UTC
Created attachment 258280 [details]
busybox-1.18.1-ldflags.patch

Replaces calls to ld with calls to $(CC). Gets rid of the code which filters out -Wl flags from LDFLAGS.
Comment 5 Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2010-12-28 19:56:13 UTC
I think that this bug may be a blocker for bug 331933 because busybox's original Makefiles filter out any LDFLAGS arguments which start with -Wl .
Comment 6 Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2010-12-29 02:18:52 UTC
Regarding comment 2 , tommy[d] was wrong. The applets/usage binary is used during compiletime. Therefore, CC, CFLAGS, and LDFLAGS should not be respected when compiling a compilation-time binary such as applets/usage. Instead, the problem is that "ld" is being called directly. Instead, the compiler driver (gcc) should be called as discussed in bug 308373.
Comment 7 Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2010-12-30 21:52:18 UTC
Created attachment 258476 [details, diff]
busybox-1.18.1-ldflags.patch

This version fixes new calls to $(CC) which were missing $(CFLAGS).
Comment 8 Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2011-03-26 21:40:45 UTC
Created attachment 267327 [details, diff]
busybox-1.18.3.ebuild-kill-ld.patch

Sorry, I feel like I've been blind because I didn't see this simple fix.

The busybox package itself sets

LD              = $(CC) -nostdlib

in its Makefile. This gets overwritten by

-e "/^LD\>/s:=.*:= $(tc-getLD):"

in busybox-*.ebuild. So for a month or so I've been attacking the busybox mailing list with patches which replace $(LD) in busybox's Makefiles with $(CC) which solves a problem created by Gentoo's ebuilds :-/.

This patch does the right thing in the right place. Since busybox-*.ebuild already overrides the

CC              = $(CROSS_COMPILE)gcc

line with -e "/^CC\>/s:=.*:= $(tc-getCC):", the existing busybox LD variable should pick up this LD=$(CC) setting properly and real cross-compilation should still work.

I've tested that this produces a functional 32-bit busybox executable (which actually normally isn't installed) using portage-multilib and that normal compilation works.
Comment 9 SpanKY gentoo-dev 2011-03-27 04:48:28 UTC
that was set because people were complaining about the LD env var not being respected :P

but i dont care

http://sources.gentoo.org/sys-apps/busybox/busybox-1.18.3.ebuild?r1=1.1&r2=1.2