Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 211947 - app-shells/bash-3.2_p33: LD_FOR_BUILD uses LDFLAGS instead of LDFLAGS_FOR_BUILD
Summary: app-shells/bash-3.2_p33: LD_FOR_BUILD uses LDFLAGS instead of LDFLAGS_FOR_BUILD
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-01 04:42 UTC by Takashi YOSHII
Modified: 2008-03-02 02:10 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Takashi YOSHII 2008-03-01 04:42:28 UTC
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)
Comment 1 SpanKY gentoo-dev 2008-03-01 20:40:19 UTC
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
Comment 2 Takashi YOSHII 2008-03-02 02:10:06 UTC
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.