* [PATCH] kbuild: Allow scripts/* to be cross compiled
@ 2013-08-09 11:07 Mark Brown
2013-08-09 12:32 ` Sam Ravnborg
2013-08-09 12:36 ` Michal Marek
0 siblings, 2 replies; 8+ messages in thread
From: Mark Brown @ 2013-08-09 11:07 UTC (permalink / raw)
To: Michal Marek; +Cc: linaro-kernel, linux-kbuild, John Rigby, Mark Brown
From: John Rigby <john.rigby@linaro.org>
Cross compiling the binaries in scripts/* is not possible
because various makefiles assume that $(obj)/whatever is
executable on the build host.
This patch introduces a new variable called KBUILD_SCRIPTROOT
that points to script/binaries to use while cross compiling.
Usage:
Build scripts for the build host:
make O=path/to/buildhost/buildscripts \
silentoldconfig prepare scripts
Then cross build script for target:
make O=path/to/target/buildscripts \
HOSTCC=$CROSS_COMPILE \
KBUILD_SCRIPTROOT=path/to/buildhost/buildscripts
silentoldconfig prepare scripts
This patch does not use KBUILD_SCRIPTROOT for all script invocations
it only redefines the following if KBUILD_SCRIPTROOT is defined.
scripts/Makefile.build
scripts/basic/fixdep --> $(KBUILD_SCRIPTROOT)/scripts/basic/fixdep
scripts/kconfig/Makefile
$(obj)/conf --> $(KBUILD_SCRIPTROOT)/scripts/kconfig/conf
scripts/mod/Makefile
$(obj)mk_elfconfig --> $(KBUILD_SCRIPTROOT)/scripts/mod/mk_elfconfig
Signed-off-by: John Rigby <john.rigby@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
---
scripts/Kbuild.include | 6 +++++-
scripts/Makefile.build | 6 +++++-
scripts/kconfig/Makefile | 30 ++++++++++++++++++------------
scripts/mod/Makefile | 10 ++++++++--
4 files changed, 36 insertions(+), 16 deletions(-)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 547e15d..09aa90c 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -222,11 +222,15 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
$(echo-cmd) $(cmd_$(1)); \
echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
+ifeq ($(KBUILD_SCRIPTROOT),)
+KBUILD_SCRIPTROOT=.
+endif
+
# Execute the command and also postprocess generated .d dependencies file.
if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \
@set -e; \
$(echo-cmd) $(cmd_$(1)); \
- scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
+ $(KBUILD_SCRIPTROOT)/scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
rm -f $(depfile); \
mv -f $(dot-target).tmp $(dot-target).cmd)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index d5d859c..de35192 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -291,13 +291,17 @@ cmd_record_mcount = \
fi;
endif
+ifeq ($(KBUILD_SCRIPTROOT),)
+KBUILD_SCRIPTROOT=.
+endif
+
define rule_cc_o_c
$(call echo-cmd,checksrc) $(cmd_checksrc) \
$(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \
$(cmd_modversions) \
$(call echo-cmd,record_mcount) \
$(cmd_record_mcount) \
- scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
+ $(KBUILD_SCRIPTROOT)/scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
$(dot-target).tmp; \
rm -f $(depfile); \
mv -f $(dot-target).tmp $(dot-target).cmd
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 844bc9d..c58f912 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -14,6 +14,12 @@ endif
# We need this, in case the user has it in its environment
unexport CONFIG_
+ifdef KBUILD_SCRIPTROOT
+CONF = $(KBUILD_SCRIPTROOT)/scripts/kconfig/conf
+else
+CONF = $(obj)/conf
+endif
+
xconfig: $(obj)/qconf
$< $(Kconfig)
@@ -23,31 +29,31 @@ gconfig: $(obj)/gconf
menuconfig: $(obj)/mconf
$< $(Kconfig)
-config: $(obj)/conf
+config: $(CONF)
$< --oldaskconfig $(Kconfig)
nconfig: $(obj)/nconf
$< $(Kconfig)
-oldconfig: $(obj)/conf
+oldconfig: $(CONF)
$< --$@ $(Kconfig)
-silentoldconfig: $(obj)/conf
+silentoldconfig: $(CONF)
$(Q)mkdir -p include/generated
$< --$@ $(Kconfig)
-localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
+localyesconfig localmodconfig: $(obj)/streamline_config.pl $(CONF)
$(Q)mkdir -p include/generated
$(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config
$(Q)if [ -f .config ]; then \
cmp -s .tmp.config .config || \
(mv -f .config .config.old.1; \
mv -f .tmp.config .config; \
- $(obj)/conf --silentoldconfig $(Kconfig); \
+ $(CONF) --silentoldconfig $(Kconfig); \
mv -f .config.old.1 .config.old) \
else \
mv -f .tmp.config .config; \
- $(obj)/conf --silentoldconfig $(Kconfig); \
+ $(CONF) --silentoldconfig $(Kconfig); \
fi
$(Q)rm -f .tmp.config
@@ -76,24 +82,24 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig
-allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf
+allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(CONF)
$< --$@ $(Kconfig)
PHONY += listnewconfig olddefconfig oldnoconfig savedefconfig defconfig
-listnewconfig olddefconfig: $(obj)/conf
+listnewconfig olddefconfig: $(CONF)
$< --$@ $(Kconfig)
# oldnoconfig is an alias of olddefconfig, because people already are dependent
# on its behavior(sets new symbols to their default value but not 'n') with the
# counter-intuitive name.
-oldnoconfig: $(obj)/conf
+oldnoconfig: $(CONF)
$< --olddefconfig $(Kconfig)
-savedefconfig: $(obj)/conf
+savedefconfig: $(CONF)
$< --$@=defconfig $(Kconfig)
-defconfig: $(obj)/conf
+defconfig: $(CONF)
ifeq ($(KBUILD_DEFCONFIG),)
$< --defconfig $(Kconfig)
else
@@ -101,7 +107,7 @@ else
$(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
endif
-%_defconfig: $(obj)/conf
+%_defconfig: $(CONF)
$(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
# Help text used by make help
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile
index c11212f..8967d55 100644
--- a/scripts/mod/Makefile
+++ b/scripts/mod/Makefile
@@ -1,6 +1,12 @@
hostprogs-y := modpost mk_elfconfig
always := $(hostprogs-y) empty.o
+ifdef KBUILD_SCRIPTROOT
+MKELFCONFIG = $(KBUILD_SCRIPTROOT)/scripts/mod/mk_elfconfig
+else
+MKELFCONFIG = $(obj)/mk_elfconfig
+endif
+
modpost-objs := modpost.o file2alias.o sumversion.o
devicetable-offsets-file := devicetable-offsets.h
@@ -40,9 +46,9 @@ $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h
$(obj)/file2alias.o: $(obj)/$(devicetable-offsets-file)
quiet_cmd_elfconfig = MKELF $@
- cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@
+ cmd_elfconfig = $(MKELFCONFIG) < $< > $@
-$(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE
+$(obj)/elfconfig.h: $(obj)/empty.o $(MKELFCONFIG) FORCE
$(call if_changed,elfconfig)
targets += elfconfig.h
--
1.8.4.rc1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] kbuild: Allow scripts/* to be cross compiled
2013-08-09 11:07 [PATCH] kbuild: Allow scripts/* to be cross compiled Mark Brown
@ 2013-08-09 12:32 ` Sam Ravnborg
2013-08-09 15:00 ` Mark Brown
2013-08-09 12:36 ` Michal Marek
1 sibling, 1 reply; 8+ messages in thread
From: Sam Ravnborg @ 2013-08-09 12:32 UTC (permalink / raw)
To: Mark Brown
Cc: Michal Marek, linaro-kernel, linux-kbuild, John Rigby, Mark Brown
On Fri, Aug 09, 2013 at 12:07:12PM +0100, Mark Brown wrote:
> From: John Rigby <john.rigby@linaro.org>
>
> Cross compiling the binaries in scripts/* is not possible
> because various makefiles assume that $(obj)/whatever is
> executable on the build host.
Please explain what problem you are trying to solve with this.
I do not understand the rationale behind this patch from the above.
Sam
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kbuild: Allow scripts/* to be cross compiled
2013-08-09 11:07 [PATCH] kbuild: Allow scripts/* to be cross compiled Mark Brown
2013-08-09 12:32 ` Sam Ravnborg
@ 2013-08-09 12:36 ` Michal Marek
1 sibling, 0 replies; 8+ messages in thread
From: Michal Marek @ 2013-08-09 12:36 UTC (permalink / raw)
To: Mark Brown; +Cc: linaro-kernel, linux-kbuild, John Rigby, Mark Brown
On 9.8.2013 13:07, Mark Brown wrote:
> From: John Rigby <john.rigby@linaro.org>
>
> Cross compiling the binaries in scripts/* is not possible
> because various makefiles assume that $(obj)/whatever is
> executable on the build host.
What is the use case for cross-compiling them? If you have a powerful
enough target machine to build the kernel on it, you can as well compile
the host scripts natively, can't you? But maybe I'm missing something, I
do not cross-compile the kernel on a daily basis. Are there other
projects that have such feature in their build system?
> This patch introduces a new variable called KBUILD_SCRIPTROOT
> that points to script/binaries to use while cross compiling.
>
> Usage:
>
> Build scripts for the build host:
> make O=path/to/buildhost/buildscripts \
> silentoldconfig prepare scripts
> Then cross build script for target:
> make O=path/to/target/buildscripts \
> HOSTCC=$CROSS_COMPILE \
> KBUILD_SCRIPTROOT=path/to/buildhost/buildscripts
> silentoldconfig prepare scripts
Note that a build that uses KBUILD_SCRIPTROOT cannot detect if the
scripts are up to date and cannot rebuild them. This must be documented.
> This patch does not use KBUILD_SCRIPTROOT for all script invocations
> it only redefines the following if KBUILD_SCRIPTROOT is defined.
>
> scripts/Makefile.build
> scripts/basic/fixdep --> $(KBUILD_SCRIPTROOT)/scripts/basic/fixdep
>
> scripts/kconfig/Makefile
> $(obj)/conf --> $(KBUILD_SCRIPTROOT)/scripts/kconfig/conf
>
> scripts/mod/Makefile
> $(obj)mk_elfconfig --> $(KBUILD_SCRIPTROOT)/scripts/mod/mk_elfconfig
OK, but you might need to add a couple of more of them, like
lib/gen_crc32table.
> diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
> index 547e15d..09aa90c 100644
> --- a/scripts/Kbuild.include
> +++ b/scripts/Kbuild.include
> @@ -222,11 +222,15 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
> $(echo-cmd) $(cmd_$(1)); \
> echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
>
> +ifeq ($(KBUILD_SCRIPTROOT),)
> +KBUILD_SCRIPTROOT=.
> +endif
> +
This should be set in the top level Makefile once.
Thanks,
Michal
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kbuild: Allow scripts/* to be cross compiled
2013-08-09 12:32 ` Sam Ravnborg
@ 2013-08-09 15:00 ` Mark Brown
2013-08-09 15:13 ` Sam Ravnborg
0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2013-08-09 15:00 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: Michal Marek, linaro-kernel, linux-kbuild, John Rigby
[-- Attachment #1: Type: text/plain, Size: 551 bytes --]
On Fri, Aug 09, 2013 at 02:32:51PM +0200, Sam Ravnborg wrote:
> On Fri, Aug 09, 2013 at 12:07:12PM +0100, Mark Brown wrote:
> > From: John Rigby <john.rigby@linaro.org>
> > Cross compiling the binaries in scripts/* is not possible
> > because various makefiles assume that $(obj)/whatever is
> > executable on the build host.
> Please explain what problem you are trying to solve with this.
> I do not understand the rationale behind this patch from the above.
OK... I'd have thought that cross compliation was enough of a rationale
to be honest.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kbuild: Allow scripts/* to be cross compiled
2013-08-09 15:00 ` Mark Brown
@ 2013-08-09 15:13 ` Sam Ravnborg
2013-08-09 15:27 ` Mark Brown
0 siblings, 1 reply; 8+ messages in thread
From: Sam Ravnborg @ 2013-08-09 15:13 UTC (permalink / raw)
To: Mark Brown; +Cc: Michal Marek, linaro-kernel, linux-kbuild, John Rigby
On Fri, Aug 09, 2013 at 04:00:31PM +0100, Mark Brown wrote:
> On Fri, Aug 09, 2013 at 02:32:51PM +0200, Sam Ravnborg wrote:
> > On Fri, Aug 09, 2013 at 12:07:12PM +0100, Mark Brown wrote:
> > > From: John Rigby <john.rigby@linaro.org>
>
> > > Cross compiling the binaries in scripts/* is not possible
> > > because various makefiles assume that $(obj)/whatever is
> > > executable on the build host.
>
> > Please explain what problem you are trying to solve with this.
> > I do not understand the rationale behind this patch from the above.
>
> OK... I'd have thought that cross compliation was enough of a rationale
> to be honest.
The way I understand cross compilation is that for example you
build for arm - on your x86 box.
This is supported today.
So you need to explain your interpretation of cross compilation
and why this patch is needed.
Because I do not get it.
Sam
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kbuild: Allow scripts/* to be cross compiled
2013-08-09 15:13 ` Sam Ravnborg
@ 2013-08-09 15:27 ` Mark Brown
2013-08-09 15:35 ` Michal Marek
0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2013-08-09 15:27 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: Michal Marek, linaro-kernel, linux-kbuild, John Rigby
[-- Attachment #1: Type: text/plain, Size: 871 bytes --]
On Fri, Aug 09, 2013 at 05:13:46PM +0200, Sam Ravnborg wrote:
> On Fri, Aug 09, 2013 at 04:00:31PM +0100, Mark Brown wrote:
> > OK... I'd have thought that cross compliation was enough of a rationale
> > to be honest.
> The way I understand cross compilation is that for example you
> build for arm - on your x86 box.
> This is supported today.
> So you need to explain your interpretation of cross compilation
> and why this patch is needed.
> Because I do not get it.
I thought that was covered by:
Cross compiling the binaries in scripts/* is not possible
because various makefiles assume that $(obj)/whatever is
executable on the build host.
ie, we can cross build the kernel but not fixdep, conf or mk_elfconfig
since those are assumed to be runnable for the kernel build, meaning
they can't be deployed onto a target system without hoop jumping.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kbuild: Allow scripts/* to be cross compiled
2013-08-09 15:27 ` Mark Brown
@ 2013-08-09 15:35 ` Michal Marek
2013-08-09 16:08 ` Mark Brown
0 siblings, 1 reply; 8+ messages in thread
From: Michal Marek @ 2013-08-09 15:35 UTC (permalink / raw)
To: Mark Brown; +Cc: Sam Ravnborg, linaro-kernel, linux-kbuild, John Rigby
On 9.8.2013 17:27, Mark Brown wrote:
> On Fri, Aug 09, 2013 at 05:13:46PM +0200, Sam Ravnborg wrote:
>> On Fri, Aug 09, 2013 at 04:00:31PM +0100, Mark Brown wrote:
>
>>> OK... I'd have thought that cross compliation was enough of a rationale
>>> to be honest.
>
>> The way I understand cross compilation is that for example you
>> build for arm - on your x86 box.
>> This is supported today.
>
>> So you need to explain your interpretation of cross compilation
>> and why this patch is needed.
>> Because I do not get it.
>
> I thought that was covered by:
>
> Cross compiling the binaries in scripts/* is not possible
> because various makefiles assume that $(obj)/whatever is
> executable on the build host.
>
> ie, we can cross build the kernel but not fixdep, conf or mk_elfconfig
> since those are assumed to be runnable for the kernel build, meaning
> they can't be deployed onto a target system without hoop jumping.
OK, but what what do you need cross compile them and deploy on the
target? Their job is to build the kernel. So if you are going to build
the kernel on the target, you can also build the tools there, can't you?
Or are you using the tools from something else than building the kernel?
I think that we are missing some detail of your use case and it does not
make sense without that detail.
Michal
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kbuild: Allow scripts/* to be cross compiled
2013-08-09 15:35 ` Michal Marek
@ 2013-08-09 16:08 ` Mark Brown
0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2013-08-09 16:08 UTC (permalink / raw)
To: Michal Marek
Cc: Sam Ravnborg, linaro-kernel, linux-kbuild, John Rigby,
Andrey Konovalov
[-- Attachment #1: Type: text/plain, Size: 884 bytes --]
On Fri, Aug 09, 2013 at 05:35:39PM +0200, Michal Marek wrote:
> On 9.8.2013 17:27, Mark Brown wrote:
> > ie, we can cross build the kernel but not fixdep, conf or mk_elfconfig
> > since those are assumed to be runnable for the kernel build, meaning
> > they can't be deployed onto a target system without hoop jumping.
> OK, but what what do you need cross compile them and deploy on the
> target? Their job is to build the kernel. So if you are going to build
> the kernel on the target, you can also build the tools there, can't you?
> Or are you using the tools from something else than building the kernel?
> I think that we are missing some detail of your use case and it does not
> make sense without that detail.
Well, fixdep in particular seems like a generically useful thing that
you might want installed but in general I agree - Andrey, why are we
carrying this patch?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-08-09 16:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-09 11:07 [PATCH] kbuild: Allow scripts/* to be cross compiled Mark Brown
2013-08-09 12:32 ` Sam Ravnborg
2013-08-09 15:00 ` Mark Brown
2013-08-09 15:13 ` Sam Ravnborg
2013-08-09 15:27 ` Mark Brown
2013-08-09 15:35 ` Michal Marek
2013-08-09 16:08 ` Mark Brown
2013-08-09 12:36 ` Michal Marek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox