Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 420949

Summary: Genkernel fails to build busybox for non-default linker ABI
Product: Gentoo Hosted Projects Reporter: Light <sgsdxzy>
Component: genkernelAssignee: Gentoo Genkernel Maintainers <genkernel>
Status: RESOLVED TEST-REQUEST    
Severity: normal CC: agshew, bugzilla-gentoo, steev
Priority: Normal    
Version: unspecified   
Hardware: AMD64   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: genkernel log

Description Light 2012-06-13 08:50:09 UTC
I am using gentoo-sources 3.4.0. Genkernel fails to build busybox 1.20.1 for x32 ABI, saying ld: i386:x64-32 architecture of input file `applets/applets.o' is incompatible with i386:x86-64 output. However, if I emerge busybox with static and mdev USE flags, it builds and works fine. So I think this isn't an ordinary compilation failure of busybox, but has something to do with genkernel itself.

Reproducible: Always

Steps to Reproduce:
genkernel all( or intramfs)
Actual Results:  
compilation fails

Expected Results:  
I should compile busybox as emerge does.

I am sure the compiled kernel itself works-I can boot using the generated kernel, just busybox and thus initramfs fails to build. It doesn't matter much but is annoying.
Comment 1 Light 2012-06-13 08:52:05 UTC
Created attachment 315171 [details]
genkernel log
Comment 2 Steev Klimaszewski (RETIRED) gentoo-dev 2012-06-19 18:35:36 UTC
Ditto here, exact same output.
Comment 3 Robert Trace 2012-06-23 05:49:39 UTC
This occurs because genkernel is forcibly overriding the default linker.

* busybox: >> Compiling...
COMMAND: make V=1 CC="gcc" LD="ld" AS="as" all 
...
  gcc -Wp,-MD,applets/.applets.o.d   -std=gnu99 -Iinclude -Ilibbb  -include include/autoconf.h -D_GNU_SOURCE -DNDEBUG -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D"BB_VER=KBUILD_STR(1.20.1)" -DBB_BT=AUTOCONF_TIMESTAMP  -Wall -Wshadow -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter -Wunused-function -Wunused-value -Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement -Wold-style-definition -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections -fno-guess-branch-probability -funsigned-char -static-libgcc -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -Os     -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(applets)"  -D"KBUILD_MODNAME=KBUILD_STR(applets)" -c -o applets/applets.o applets/applets.c
   ld  -r -o applets/built-in.o applets/applets.o
ld: i386:x64-32 architecture of input file `applets/applets.o' is incompatible with i386:x86-64 output
make[1]: *** [applets/built-in.o] Error 1
make: *** [applets_dir] Error 2

ld is trying to create 64-bit (x86_64) object code as output for applets/built-in.o, but applets/applets.o has been built as 32-bit (x32) code and those two don't match up.

By default, busybox will use "$(CC) -nostdlib" as the default linker unless it's overridden (as you can see in the busybox Makefile).  If you add '--utils-ld="x86_64-pc-linux-gnu-gcc -nostdlib"' to the genkernel command-line then busybox will build.

This would seem to be a non-ideal workaround only, however.
Comment 4 SpanKY gentoo-dev 2012-11-11 20:22:02 UTC
i imagine if you update your CHOST to x86_64-pc-linux-gnux32, this starts working

i also think this bug will bite anyone whose ABI=xxx setting does not match the default ABI that the linker produces.  if genkernel pulled in ${LDFLAGS_${ABI}}, it could work.

or the whole bug is semi-moot once busybox itself moves away from invoking the linker directly to the compiler driver ...
Comment 5 Ben Kohler gentoo-dev 2017-09-08 14:26:21 UTC
*** Bug 466840 has been marked as a duplicate of this bug. ***
Comment 6 Thomas Deutschmann (RETIRED) gentoo-dev 2019-07-16 18:37:06 UTC
In genkernel-4, cross-compile support was reworked. Could you please give it a try?