* [Buildroot] [PATCH 1/1] Fix config.mak.uname to allow cross-compilation
@ 2016-05-22 20:24 Mauro Condarelli
2016-05-22 20:24 ` Mauro Condarelli
0 siblings, 1 reply; 5+ messages in thread
From: Mauro Condarelli @ 2016-05-22 20:24 UTC (permalink / raw)
To: buildroot
This patch is part of a patchset for BuildRoot (https://buildroot.org/)
needed to correctly cross-compile GIT.
Git compilation relies on "uname" program to determine several system
charcteristics, but that does not work well in a cross-compilation
environment because "uname" will run on host, while we are interested
in information concerning target.
The file "config.mak.uname" unconditionally assigns variables using
":=", this prevents changing their value from the command line.
This minimal patch changes the flavor of the variable and assigns it
only if not already assigned, opening the road to spcify target-consistent
values on the command line (which is done in the other patches for
BuildRoot, but are not relevant here).
We are sending this patch upstream because we feel this might be
useful in other cross-compilation contexts.
Note this patch also changes variable "flavor" thus incurring in a
computational overhead; Makefile perusal doesn't seem to indicate
this as a problem, but it is possible to overcome this problem,
if deemed relevant, by using the construct:
ifeq ($(origin uname_X), undefined)
uname_X := $(shell sh -c 'uname -x 2>/dev/null || echo not')
endif
If required I will submit another patch to this effect.
Regards
Mauro
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Buildroot] [PATCH 1/1] Fix config.mak.uname to allow cross-compilation
2016-05-22 20:24 [Buildroot] [PATCH 1/1] Fix config.mak.uname to allow cross-compilation Mauro Condarelli
@ 2016-05-22 20:24 ` Mauro Condarelli
2016-05-22 20:29 ` Thomas Petazzoni
0 siblings, 1 reply; 5+ messages in thread
From: Mauro Condarelli @ 2016-05-22 20:24 UTC (permalink / raw)
To: buildroot
Current implementation imperatively sets variables from "uname" output.
This breaks cross-compilation because uname is run on host while target
configuration may be different.
Make current behavior a non-imperative default, so it's possible to
force different values setting make variables.
To cross-compile it will be necessary to explicitly set the various
uname_X variables to values compatible with target.
No change is needed with normal host compilation.
Patch is trivial.
Signed-off-by: Mauro Condarelli <mc5686@mclink.it>
---
config.mak.uname | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/config.mak.uname b/config.mak.uname
index 40d6b29..d933b23 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -1,11 +1,11 @@
# Platform specific Makefile tweaks based on uname detection
-uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
-uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
-uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
-uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
-uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
-uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
+uname_S ?= $(shell sh -c 'uname -s 2>/dev/null || echo not')
+uname_M ?= $(shell sh -c 'uname -m 2>/dev/null || echo not')
+uname_O ?= $(shell sh -c 'uname -o 2>/dev/null || echo not')
+uname_R ?= $(shell sh -c 'uname -r 2>/dev/null || echo not')
+uname_P ?= $(shell sh -c 'uname -p 2>/dev/null || echo not')
+uname_V ?= $(shell sh -c 'uname -v 2>/dev/null || echo not')
ifdef MSVC
# avoid the MingW and Cygwin configuration sections
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Buildroot] [PATCH 1/1] Fix config.mak.uname to allow cross-compilation
2016-05-22 20:24 ` Mauro Condarelli
@ 2016-05-22 20:29 ` Thomas Petazzoni
2016-05-22 20:40 ` Mauro Condarelli
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni @ 2016-05-22 20:29 UTC (permalink / raw)
To: buildroot
Hello,
Thanks for your contribution.
On Sun, 22 May 2016 22:24:03 +0200, Mauro Condarelli wrote:
> Current implementation imperatively sets variables from "uname" output.
> This breaks cross-compilation because uname is run on host while target
> configuration may be different.
>
> Make current behavior a non-imperative default, so it's possible to
> force different values setting make variables.
>
> To cross-compile it will be necessary to explicitly set the various
> uname_X variables to values compatible with target.
> No change is needed with normal host compilation.
> Patch is trivial.
>
> Signed-off-by: Mauro Condarelli <mc5686@mclink.it>
> ---
> config.mak.uname | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
This patch cannot be applied, as it is a patch against Git directly,
while you should send patches against Buildroot. I.e, a patch that adds
a patch.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Buildroot] [PATCH 1/1] Fix config.mak.uname to allow cross-compilation
2016-05-22 20:29 ` Thomas Petazzoni
@ 2016-05-22 20:40 ` Mauro Condarelli
2016-05-22 20:45 ` Thomas Petazzoni
0 siblings, 1 reply; 5+ messages in thread
From: Mauro Condarelli @ 2016-05-22 20:40 UTC (permalink / raw)
To: buildroot
Thanks Thomas,
comments below.
Il 22/05/2016 22:29, Thomas Petazzoni ha scritto:
> Hello,
>
> Thanks for your contribution.
>
> On Sun, 22 May 2016 22:24:03 +0200, Mauro Condarelli wrote:
>> Current implementation imperatively sets variables from "uname" output.
>> This breaks cross-compilation because uname is run on host while target
>> configuration may be different.
>>
>> Make current behavior a non-imperative default, so it's possible to
>> force different values setting make variables.
>>
>> To cross-compile it will be necessary to explicitly set the various
>> uname_X variables to values compatible with target.
>> No change is needed with normal host compilation.
>> Patch is trivial.
>>
>> Signed-off-by: Mauro Condarelli <mc5686@mclink.it>
>> ---
>> config.mak.uname | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
> This patch cannot be applied, as it is a patch against Git directly,
> while you should send patches against Buildroot. I.e, a patch that adds
> a patch.
I know.
My patchset for BuildRoot is in "[Buildroot] [PATCH v2] Fix for GIT cross-compilation."
and includes this patch.
I sent this upstream and it's CC: here only FYI.
Sorry if I broke any rules.
Please advise.
>
> Best regards,
>
> Thomas
Regards
Mauro
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Buildroot] [PATCH 1/1] Fix config.mak.uname to allow cross-compilation
2016-05-22 20:40 ` Mauro Condarelli
@ 2016-05-22 20:45 ` Thomas Petazzoni
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Petazzoni @ 2016-05-22 20:45 UTC (permalink / raw)
To: buildroot
Hello,
On Sun, 22 May 2016 22:40:04 +0200, Mauro Condarelli wrote:
> > This patch cannot be applied, as it is a patch against Git directly,
> > while you should send patches against Buildroot. I.e, a patch that adds
> > a patch.
> I know.
> My patchset for BuildRoot is in "[Buildroot] [PATCH v2] Fix for GIT cross-compilation."
> and includes this patch.
> I sent this upstream and it's CC: here only FYI.
Ah, OK, I understand. You didn't break any rule, but I did not realize
this patch was for Git upstream and not for Buildroot :/
Thomsa
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-05-22 20:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-22 20:24 [Buildroot] [PATCH 1/1] Fix config.mak.uname to allow cross-compilation Mauro Condarelli
2016-05-22 20:24 ` Mauro Condarelli
2016-05-22 20:29 ` Thomas Petazzoni
2016-05-22 20:40 ` Mauro Condarelli
2016-05-22 20:45 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox