[PATCH] Use $(CC) when linking instead of $(LD) and use $(CFLAGS) when linking.

Mike Frysinger vapier at gentoo.org
Mon Mar 7 02:28:49 UTC 2011


On Sun, Mar 6, 2011 at 8:37 PM, Denys Vlasenko wrote:
> On Monday 07 March 2011 01:59, Nathan Phillip Brink wrote:
>> This fixes the issue where LDFLAGS escaped with -Wl are ignored during
>> compilation. It also simplifies using CFLAGS (such as -m32 on x86_64)
>> which apply to both compilation and linking situations.
>
> "make CFLAGS=-m32" disables ALL optimizations.
> You need to use EXTRA_CFLAGS (and EXTRA_LDFLAGS):
>
>   text    data     bss     dec     hex filename
> 1134371    2125    9156 1145652  117b34 busybox_CFLAGSm32
>  769631    2067    9084  780782   be9ee busybox_EXTRA_CFLAGSm32
>
> make EXTRA_CFLAGS=-m32 EXTRA_LDFLAGS=-m32 works without your patch.
> Do you see other reasons to apply it?

the driving point is to not invoke the linker directly, but go through
the compiler driver.  i.e. `gcc` and not `ld`.

this allows CFLAGS to be passed to the linker step, as well as using
the -Wl form of LDFLAGS rather than raw linker flags.
-mike


More information about the busybox mailing list