* [PATCH] btrfs-progs: Fix cross-compile error for mktables
@ 2017-08-15 2:19 Qu Wenruo
[not found] ` <9d6cf409-e6f4-a960-a509-cac9880238d2@libero.it>
0 siblings, 1 reply; 2+ messages in thread
From: Qu Wenruo @ 2017-08-15 2:19 UTC (permalink / raw)
To: linux-btrfs; +Cc: dsterba, Qu Wenruo
When cross compiling btrfs-progs, following error will prevent
btrfs-progs to be compiled:
[CC] mktables
[TABLE] kernel-lib/tables.c
/bin/sh: ./mktables: cannot execute binary file: Exec format error
make: *** No rule to make target 'kernel-lib/tables.c', needed by 'kernel-lib/tables.o'. Stop.
"mktables" should only be executed in host environment, while @CC
set by autoconf will follow host/build/target setting, causing mktables
to be cross-compiled.
The fix is to introduce a new @HOSTCC for mktables, which will not be
affected by host/build/target settings.
Reported-by: Hallo32 <Hallo32@gmx.net>
Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
---
Tested with AArch64 cross-toolchain created by buildroot.
---
Makefile | 2 +-
Makefile.inc.in | 1 +
configure.ac | 1 +
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index b3e2b636..0395e37f 100644
--- a/Makefile
+++ b/Makefile
@@ -323,7 +323,7 @@ version.h: version.sh version.h.in configure.ac
mktables: kernel-lib/mktables.c
@echo " [CC] $@"
- $(Q)$(CC) $(CFLAGS) $< -o $@
+ $(Q)$(HOSTCC) $(CFLAGS) $< -o $@
kernel-lib/tables.c: mktables
@echo " [TABLE] $@"
diff --git a/Makefile.inc.in b/Makefile.inc.in
index 4e1b68cb..308acca3 100644
--- a/Makefile.inc.in
+++ b/Makefile.inc.in
@@ -4,6 +4,7 @@
export
CC = @CC@
+HOSTCC = @HOSTCC@
LN_S = @LN_S@
AR = @AR@
RM = @RM@
diff --git a/configure.ac b/configure.ac
index 30055f85..f6051ebd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,6 +26,7 @@ AC_CONFIG_SRCDIR([btrfs.c])
AC_PREFIX_DEFAULT([/usr/local])
AC_PROG_CC
+AC_PATH_PROGS([HOSTCC], [gcc clang])
AC_CANONICAL_HOST
AC_C_CONST
AC_C_VOLATILE
--
2.14.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs-progs: Fix cross-compile error for mktables
[not found] ` <9d6cf409-e6f4-a960-a509-cac9880238d2@libero.it>
@ 2017-08-15 8:07 ` Qu Wenruo
0 siblings, 0 replies; 2+ messages in thread
From: Qu Wenruo @ 2017-08-15 8:07 UTC (permalink / raw)
To: kreijack, linux-btrfs@vger.kernel.org
On 2017年08月15日 15:14, Goffredo Baroncelli wrote:
> Hi Qu,
>
> On 08/15/2017 04:19 AM, Qu Wenruo wrote:
>> When cross compiling btrfs-progs, following error will prevent
>> btrfs-progs to be compiled:
>>
>> [CC] mktables
>> [TABLE] kernel-lib/tables.c
>> /bin/sh: ./mktables: cannot execute binary file: Exec format error
>> make: *** No rule to make target 'kernel-lib/tables.c', needed by 'kernel-lib/tables.o'. Stop.
>>
>> "mktables" should only be executed in host environment, while @CC
>> set by autoconf will follow host/build/target setting, causing mktables
>> to be cross-compiled.
>>
>> The fix is to introduce a new @HOSTCC for mktables, which will not be
>> affected by host/build/target settings.
>>
>> Reported-by: Hallo32 <Hallo32@gmx.net>
>> Suggested-by: David Sterba <dsterba@suse.cz>
>
> this idea was a my suggestion.... :(
Sorry, I though all that 2 mails are from David.
And David still likes the idea to let git manage that file...
So correct tag should be:
Suggested-by: Goffredo Baroncelli <kreijack@libero.it>
Thanks for pointing this out.
Qu
>
>> Signed-off-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
>> ---
>> Tested with AArch64 cross-toolchain created by buildroot.
>> ---
>> Makefile | 2 +-
>> Makefile.inc.in | 1 +
>> configure.ac | 1 +
>> 3 files changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/Makefile b/Makefile
>> index b3e2b636..0395e37f 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -323,7 +323,7 @@ version.h: version.sh version.h.in configure.ac
>>
>> mktables: kernel-lib/mktables.c
>> @echo " [CC] $@"
>> - $(Q)$(CC) $(CFLAGS) $< -o $@
>> + $(Q)$(HOSTCC) $(CFLAGS) $< -o $@
>>
>> kernel-lib/tables.c: mktables
>> @echo " [TABLE] $@"
>> diff --git a/Makefile.inc.in b/Makefile.inc.in
>> index 4e1b68cb..308acca3 100644
>> --- a/Makefile.inc.in
>> +++ b/Makefile.inc.in
>> @@ -4,6 +4,7 @@
>> export
>>
>> CC = @CC@
>> +HOSTCC = @HOSTCC@
>> LN_S = @LN_S@
>> AR = @AR@
>> RM = @RM@
>> diff --git a/configure.ac b/configure.ac
>> index 30055f85..f6051ebd 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -26,6 +26,7 @@ AC_CONFIG_SRCDIR([btrfs.c])
>> AC_PREFIX_DEFAULT([/usr/local])
>>
>> AC_PROG_CC
>> +AC_PATH_PROGS([HOSTCC], [gcc clang])
>> AC_CANONICAL_HOST
>> AC_C_CONST
>> AC_C_VOLATILE
>>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-15 8:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-15 2:19 [PATCH] btrfs-progs: Fix cross-compile error for mktables Qu Wenruo
[not found] ` <9d6cf409-e6f4-a960-a509-cac9880238d2@libero.it>
2017-08-15 8:07 ` Qu Wenruo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).