<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>211947</bug_id>
          
          <creation_ts>2008-03-01 04:42 0000</creation_ts>
          <short_desc>app-shells/bash-3.2_p33: LD_FOR_BUILD uses LDFLAGS instead of LDFLAGS_FOR_BUILD</short_desc>
          <delta_ts>2008-03-02 02:10:06 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Applications</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>takasi-y@ops.dti.ne.jp</reporter>
          <assigned_to>base-system@gentoo.org</assigned_to>
          

      

      
          <long_desc isprivate="0">
            <who>takasi-y@ops.dti.ne.jp</who>
            <bug_when>2008-03-01 04:42:28 0000</bug_when>
            <thetext>When cross compiling &quot;bash&quot;, 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 &quot;Gentoo embedded howto&quot;.
2.Set target specific LDFLAGS in target make.conf (eg. --sysroot=xxx, which doesn&apos;t usually enabled on host)
3.xmerge bash 2&gt;&amp;1  | egrep &apos;^gcc .* -o mkbuiltins &apos; 

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)</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2008-03-01 20:40:19 0000</bug_when>
            <thetext>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&amp;r2=1.5
http://sources.gentoo.org/app-shells/bash/files/bash-3.2-ldflags-for-build.patch?rev=1.1</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>takasi-y@ops.dti.ne.jp</who>
            <bug_when>2008-03-02 02:10:06 0000</bug_when>
            <thetext>I&apos;ve confirmed it had fixed, and successfully emerged. Thank you.
metadata/timestamp was &quot;Sun Mar  2 01:08:51 UTC 2008&quot; (Sorry, but I don&apos;t known how to describe the version).

&gt; please do not post patches inline ... &lt;snip&gt;
Thank you for your instructions.</thetext>
          </long_desc>
      
    </bug>

</bugzilla>