From patchwork Tue Aug 15 02:19:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9900781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C03C66038C for ; Tue, 15 Aug 2017 02:19:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABB04287B8 for ; Tue, 15 Aug 2017 02:19:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F46A287BB; Tue, 15 Aug 2017 02:19:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08413287B8 for ; Tue, 15 Aug 2017 02:19:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753232AbdHOCTO (ORCPT ); Mon, 14 Aug 2017 22:19:14 -0400 Received: from mout.gmx.net ([212.227.17.22]:56822 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753049AbdHOCTN (ORCPT ); Mon, 14 Aug 2017 22:19:13 -0400 Received: from localhost.localdomain ([45.32.39.184]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MfzEP-1dvw3U2eNp-00NPBE; Tue, 15 Aug 2017 04:19:10 +0200 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz, Qu Wenruo Subject: [PATCH] btrfs-progs: Fix cross-compile error for mktables Date: Tue, 15 Aug 2017 11:19:03 +0900 Message-Id: <20170815021903.6923-1-quwenruo.btrfs@gmx.com> X-Mailer: git-send-email 2.13.3 X-Provags-ID: V03:K0:I5pqrlOLdOPOkO/jzPzDxdOP81yzWOtoeW4w2Y7WDSW6V3zPYX/ uCYfZeBcFmOmoX53Tp4PDGH48Jhldw/eV+YCLq18xnKHWk71aySzDI+NZjPy4IP00aXQE/I 2qXWQAz43rE90djP8xbv9TuKC4B3zvHDceKHIrvlcDOk+uC9mRpelItLJdm843ez/NH219u BkHrsSlECoWN/O2cyVKxw== X-UI-Out-Filterresults: notjunk:1; V01:K0:zzJPmRSoUZw=:cTzTAs80Ee1Jc6sq35qxTP t1I+pDDpv5EcybPg/VqnCF8WiFj+po8MSJbv6stYA7PsvAsVflSgMF/x7tWDDulnDwKh21lUd yx/92oPERF3iNsV7fj+UnK+ZlWFiL3UGyfm/LF0/FAS1mZRNT/v0oVgTv759Gxe+lBy6fM9KR fHNNZVvaiNPAkCIIR3w86G1CnAg51XqdxqFrex/R6S/kPWjjcqwBhegzbx+grzeLoFk00GDdK zo8Nd3A1CquBPATu7ogXE9xUnNDVbh3DkRLFTYRiJQYnQEoLRBPAB+SazkrGUCJGbA5HYaZfE 49cqqkkSdb0FnD+Oxrp+mI7gLYxpGA9dvU5XPAhOJJ1xUJ83A/BUL9kAFLiK5G+9dxzd0/OtP AVQNIOXUkKioNMqjRZtFU1jCX7Q07igeKYm/XinjvxCsaGYXdMaDQEyKLkaMTS4jZpfaZKDm1 se07GOKXBRFfcYEndyRs7nHqRRYf5IHLqbRkPMTOKIaEeQIMQc3xS35wxlyklVD9iQ2xvLWbo lL9KpRDGartVymHEazmrvj0Qk5ECOLfO0XMhTkEd9PDNKcKG+9TQ+4uXTkUvmgPmffUVNFYZs lfn2o9Nr2BgEleIosQkj460OeJY40jpgPpI8kCpnXfJ+TZE9zsv6k/pmAShAP1e2EbFEL/6us xbRQcKRgy6fF8QE4z89fv18lpTq8SW83/mLevR19J7Wd6ul8fey70llyZf2DH5bhy53amQ08/ kMIjE+RLT6TsSESadQ44FjMMAhmRERtEe/xm0fP3TOhf7Ca7xySuIqXLNeNGYi8w9qyKEU2jN +CpbWNUbtvHqYq3LX1d1CC197fDHA== Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Suggested-by: David Sterba Signed-off-by: Qu Wenruo --- 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