From: Arnout Vandecappelle <arnout@mind.be>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2 5/7] package: Introduce package-specific BINFMT_FLAT options.
Date: Wed, 10 Apr 2013 12:36:37 +0200 [thread overview]
Message-ID: <516540B5.9070008@mind.be> (raw)
In-Reply-To: <CAJxxZ0NmPmR=OeR3T_n648WR+nNB=+1A=wyBDvR0iqoBtmD-gA@mail.gmail.com>
On 10/04/13 10:10, Sonic Zhang wrote:
> Hi Arnout,
>
> On Wed, Apr 10, 2013 at 1:47 PM, Arnout Vandecappelle <arnout@mind.be> wrote:
[snip]
>> ifeq ($(BR2_BINFMT_FLAT),y)
>> TARGET_LDFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),\
>> -Wl,-elf2flt=-s$($(PKG)_FLAT_STACKSIZE))
>> endif
>>
>
> This doesn't work.
>
> /home/sonic/projects/buildroot/output/host/usr/bin/bfin-uclinux-gcc
> -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
> -pipe -Os -D__NOMMU__ -D__uClinux__ -D_LARGEFILE_SOURCE
> -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wl --static bfin-dma.c
> -o bfin-dma
> cc1: error: unrecognized command line option "-Wl"
> make[1]: *** [bfin-dma] Error 1
Ah yes, of course, the comma. If should be:
ifeq ($(BR2_BINFMT_FLAT),y)
TARGET_LDFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),\
-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE))
endif
> In addition, if 2 generic makefile packages set different flat stack
> sizes, are both of these stack size flags added to the same
> TARGE_LDFLAGS macro with your change?
That is the magic of late binding in make. The value of TARGET_LDFLAGS
is only evaluated at the time when it is used, and it is only at that
time that the $(PKG) is expanded. And if it is used in the body of a
pattern rule, then the expansion only takes place when the rule is
instantiated.
For example, there are two packages, FOO and BAR, that set
FOO_FLAT_STACKSIZE and BAR_FLAT_STACKSIZE. They both use TARGET_LDFLAGS
in their BUILD_CMDS. The BUILD_CMDS are used in the following pattern
rule from pkg-generic.mk:
# Build
$(BUILD_DIR)/%/.stamp_built::
@$(call MESSAGE,"Building")
$($(PKG)_BUILD_CMDS)
$(foreach hook,$($(PKG)_POST_BUILD_HOOKS),$(call $(hook))$(sep))
$(Q)touch $@
When this rule is instantiated for package foo, then the PKG variable
is set to FOO. So $($(PKG)_BUILD_CMDS) expands to $(FOO_BUILD_CMDS),
which expands to something like
$(MAKE) LDFLAGS="$(TARGET_LDFLAGS)"
which expands to
make -j8 LDFLAGS="$(call qstrip,$(BR2_TARGET_LDFLAGS))\
--static\
$(if $($(PKG)_FLAT_STACKSIZE),\
-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE))"
which expands to
make -j8 LDFLAGS="$(call qstrip,"")\
--static\
$(if $(FOO_FLAT_STACKSIZE),\
-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE))"
which expands to
make -j8 LDFLAGS="\
--static\
$(if 2048,\
-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE))"
which expands to
make -j8 LDFLAGS="\
--static\
-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE)"
which expands to
make -j8 LDFLAGS="\
--static\
-W,-elf2flt=-s$(FOO_FLAT_STACKSIZE)"
which expands to
make -j8 LDFLAGS=" --static -W,-elf2flt=-s2048"
Regards,
Arnout
--
Arnout Vandecappelle arnout at mind be
Senior Embedded Software Architect +32-16-286500
Essensium/Mind http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
next prev parent reply other threads:[~2013-04-10 10:36 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-29 9:50 [Buildroot] [PATCH v2 1/7] arch: Add blackfin CPU choice Sonic Zhang
2013-03-29 9:50 ` [Buildroot] [PATCH v2 2/7] arch: toolchain: Introduce target CPU revision Sonic Zhang
2013-04-07 20:42 ` Thomas Petazzoni
2013-04-08 6:30 ` Sonic Zhang
2013-03-29 9:50 ` [Buildroot] [PATCH v2 3/7] arch: toolchain: Introduce binary formats BINFMT_* Sonic Zhang
2013-04-07 20:45 ` Thomas Petazzoni
2013-04-08 6:03 ` Sonic Zhang
2013-04-07 20:47 ` Thomas Petazzoni
2013-04-08 6:04 ` Sonic Zhang
2013-03-29 9:50 ` [Buildroot] [PATCH v2 4/7] arch: toolchain: Introduce binary format FLAT types Sonic Zhang
2013-04-07 20:51 ` Thomas Petazzoni
2013-04-08 6:43 ` Sonic Zhang
2013-04-12 3:39 ` Sonic Zhang
2013-04-13 14:31 ` Thomas Petazzoni
2013-04-16 10:26 ` Sonic Zhang
2013-04-16 10:46 ` Thomas Petazzoni
2013-04-17 9:02 ` Sonic Zhang
2013-04-23 5:57 ` Sonic Zhang
2013-03-29 9:50 ` [Buildroot] [PATCH v2 5/7] package: Introduce package-specific BINFMT_FLAT options Sonic Zhang
2013-04-07 21:27 ` Thomas Petazzoni
2013-04-10 5:47 ` Arnout Vandecappelle
2013-04-10 8:10 ` Sonic Zhang
2013-04-10 10:36 ` Arnout Vandecappelle [this message]
2013-03-29 9:50 ` [Buildroot] [PATCH v2 6/7] arch: Introduce blackfin-specific Makefile Sonic Zhang
2013-04-07 21:41 ` Thomas Petazzoni
2013-04-08 7:19 ` Sonic Zhang
2013-04-08 21:23 ` Thomas Petazzoni
2013-03-29 9:50 ` [Buildroot] [PATCH v2 7/7] package: Introduce NOMMU symbol Sonic Zhang
2013-04-07 20:39 ` [Buildroot] [PATCH v2 1/7] arch: Add blackfin CPU choice Thomas Petazzoni
2013-04-08 3:28 ` Sonic Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=516540B5.9070008@mind.be \
--to=arnout@mind.be \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox