Bug 5624 - When building directfb, BR2_TARGET_LDFLAGS not used by libtool
Summary: When building directfb, BR2_TARGET_LDFLAGS not used by libtool
Status: RESOLVED FIXED
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: 2012.08
Hardware: PC Linux
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-24 10:40 UTC by Duncan
Modified: 2014-02-12 08:52 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Snippet of build output, showing incorrect linker invocation. (3.47 KB, text/x-log)
2012-10-24 10:40 UTC, Duncan
Details
Change as suggested by Arnout. (408 bytes, patch)
2012-10-25 09:09 UTC, Duncan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Duncan 2012-10-24 10:40:46 UTC
Created attachment 4592 [details]
Snippet of build output, showing incorrect linker invocation.

I'm using the CodeSourcery mips-4.4 toolchain, and have a little endian target, so I set BR2_TARGET_LDFLAGS="-EL" in my .config. Works fine for most things, however directfb fails to build; at one stage, it invokes the linker, without the -EL argument, and the link fails because the linker (which defaults to BE) is attempting to link LE object files.

Dodgy workaround is to replace output/host/usr/bin/mips-linux-gnu-ld with a script that contains:

#!/bin/sh
exec /opt/CodeSourcery/mips-4.4//bin/mips-linux-gnu-ld -EL $*


Relevant build output attached. The interesting parts of my .config are:

#
# Toolchain
#
# BR2_TOOLCHAIN_BUILDROOT is not set
BR2_TOOLCHAIN_EXTERNAL=y
# BR2_TOOLCHAIN_CTNG is not set
# BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201109 is not set
# BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201103 is not set
BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS44=y
# BR2_TOOLCHAIN_EXTERNAL_CUSTOM is not set
# BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD is not set
BR2_TOOLCHAIN_EXTERNAL_PREINSTALLED=y
BR2_TOOLCHAIN_EXTERNAL_PATH="/opt/CodeSourcery/mips-4.4/"
BR2_TOOLCHAIN_EXTERNAL_PREFIX="mips-linux-gnu"
BR2_TOOLCHAIN_EXTERNAL_GLIBC=y

BR2_TARGET_OPTIMIZATION="-pipe -EL"
BR2_TARGET_LDFLAGS="-EL"
Comment 1 Thomas Petazzoni 2012-10-24 12:32:25 UTC
The first problem is that DirectFB is stupid in its usage of ld. It should always use gcc, even for pure linking steps, as gcc will pass the appropriate arguments to ld.

The second problem is that we don't generate a toolchain wrapper for ld, so yes the BR2_TARGET_LDFLAGS are not passed.

I am not sure if we should fix DirectFB, or add the toolchain wrapper for ld.
Comment 2 Arnout Vandecappelle 2012-10-24 21:04:41 UTC
Would it help to pass LD="$(TARGET_LD) $(TARGET_LDFLAGS)" to configure?
Comment 3 Thomas Petazzoni 2012-10-24 22:00:00 UTC
You mean globally (in package/Makefile.in) or specifically for this package?
Comment 4 Duncan 2012-10-25 09:09:17 UTC
Created attachment 4598 [details]
Change as suggested by Arnout.
Comment 5 Duncan 2012-10-25 09:09:47 UTC
Arnout, I've made the change you suggested to package/directfb/directfb.mk; now directfb, and all the other packages I have selected, are building for me. Patch against 2012.08 attached.

I'm not sure how many packages have the same problem as directfb; if there are a few, then I'd imagine that a more robust solution may be to create a toolchain wrapper for ld.
Comment 6 Jean-Mickael 2012-10-26 06:56:14 UTC
FYI I got similar issue with my LD not having the correct emulation (mips),
and I opted to add it to LDFLAGS, "-melf64btsmip" for instance.
It fixes packages using LD directly, but a new problem appears: CC cannot recognize such LD specific option syntax, and some packages adds TARGET_LDFLAGS to CC.

So I would first clean-up TARGET_LDFLAGS usage before doing the LD wrapper (which sounds good idea).
Comment 7 Thomas De Schampheleire 2014-02-12 08:52:56 UTC
This problem has been fixed with commit 7e9264956bb5693bc49274ee0b42ffb4c869e23f in buildroot 2013.11.