When cross compiling "bash", an intermediate program builtins/mkbuiltins are compiled by CC_FOR_BUILD and linked by LD_FOR_BUILD. But at that time, linker options are LDFLAGS(flags for target), instead of LDFLAGS_FOR_BUILD. This results in linking failure when flags for targets and host are incompatible. Reproducible: Always Steps to Reproduce: 1.Setup cross compiling environment according to "Gentoo embedded howto". 2.Set target specific LDFLAGS in target make.conf (eg. --sysroot=xxx, which doesn't usually enabled on host) 3.xmerge bash 2>&1 | egrep '^gcc .* -o mkbuiltins ' Actual Results: gcc -Wl,-z,relro -Wl,-O1 -rdynamic -O2 -m4 -pipe -o mkbuiltin # on my i686-pc-linux-gnu host, for sh4-unknown-linux-gnu target. Expected Results: gcc -rdynamic -g -DCROSS_COMPILING -o mkbuiltins mkbuiltins.o -ldl This is because LDFLAGS_FOR_BUILD comes from LDFLAGS as in builtins/Makefile.in LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(CFLAGS) LDFLAGS_FOR_BUILD = $(LDFLAGS) possible solution is LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ $(LOCAL_LDFLAGS) $(CFLAGS_FOR_BUILD) Following patch works for me. --- bash-3.2/builtins/Makefile.inorg 2008-02-27 03:58:47.000000000 +0900 +++ bash-3.2/builtins/Makefile.in 2008-02-27 03:59:40.000000000 +0900 @@ -63,7 +63,7 @@ LOCAL_DEFS = @LOCAL_DEFS@ LIBS = @LIBS@ LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(CFLAGS) -LDFLAGS_FOR_BUILD = $(LDFLAGS) +LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ $(LOCAL_LDFLAGS) $(CFLAGS_FOR_BUILD) LOCAL_LDFLAGS = @LOCAL_LDFLAGS@ #LIBS_FOR_BUILD = @LIBS_FOR_BUILD@ LIBS_FOR_BUILD = $(LIBS)
please do not post patches inline ... bugzilla destroys such text. always post patches as attachments. there were a few more places where LDFLAGS_FOR_BUILD was being used and i fixed those as well added to cvs and sent upstream, cheers http://sources.gentoo.org/app-shells/bash/bash-3.2_p33.ebuild?r1=1.4&r2=1.5 http://sources.gentoo.org/app-shells/bash/files/bash-3.2-ldflags-for-build.patch?rev=1.1
I've confirmed it had fixed, and successfully emerged. Thank you. metadata/timestamp was "Sun Mar 2 01:08:51 UTC 2008" (Sorry, but I don't known how to describe the version). > please do not post patches inline ... <snip> Thank you for your instructions.