From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755196AbbDIPKG (ORCPT ); Thu, 9 Apr 2015 11:10:06 -0400 Received: from mail-bn1bon0058.outbound.protection.outlook.com ([157.56.111.58]:51840 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753473AbbDIPKD (ORCPT ); Thu, 9 Apr 2015 11:10:03 -0400 X-Greylist: delayed 2039 seconds by postgrey-1.27 at vger.kernel.org; Thu, 09 Apr 2015 11:10:03 EDT Authentication-Results: spf=fail (sender IP is 137.71.25.55) smtp.mailfrom=crapouillou.net; vger.kernel.org; dkim=none (message not signed) header.d=none; From: Paul Cercueil To: Michal Marek CC: , , "Paul Cercueil" Subject: [PATCH] Makefile: Fix detection of clang when cross-compiling Date: Thu, 9 Apr 2015 16:34:54 +0200 Message-ID: <1428590094-6995-1-git-send-email-paul@crapouillou.net> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-Matching-Connectors: 130730637599783627;(52f37747-95c3-483a-bd05-08d153b03fac);() X-Forefront-Antispam-Report: CIP:137.71.25.55;CTRY:US;IPV:NLI;EFV:NLI;BMV:1;SFV:NSPM;SFS:(10009020)(6009001)(339900001)(189002)(199003)(19580395003)(86362001)(85426001)(47776003)(50466002)(36756003)(48376002)(50226001)(19580405001)(6806004)(46102003)(105606002)(50986999)(87936001)(62966003)(33646002)(92566002)(77096005)(53416004)(110136001)(77156002)(229853001)(106466001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR0301MB1193;H:nwd2mta1.analog.com;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1193; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5002010)(5005006);SRVR:CY1PR0301MB1193;BCL:0;PCL:0;RULEID:(400005)(401004);SRVR:CY1PR0301MB1193; X-Forefront-PRVS: 0541031FF6 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2015 14:35:59.8847 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[137.71.25.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1193 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the host's C compiler is clang, and when attempting to cross-compile Linux e.g. to MIPS with mipsel-linux-gcc, the Makefile would incorrectly detect the use of clang, which resulted in clang-specific flags being passed to mipsel-linux-gcc. This can be verified under Debian by installing the "clang" package, and then using it as the default compiler with: sudo update-alternatives --config cc This patch moves the detection of clang after the $(CC) variable is initialized to the name of the cross-compiler, so that the check applies to the cross-compiler and not the host's C compiler. Signed-off-by: Paul Cercueil --- Makefile | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 54430f9..5fff1b2 100644 --- a/Makefile +++ b/Makefile @@ -335,15 +335,6 @@ endif export KBUILD_MODULES KBUILD_BUILTIN export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD -ifneq ($(CC),) -ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) -COMPILER := clang -else -COMPILER := gcc -endif -export COMPILER -endif - # Look for make include files relative to root of kernel src MAKEFLAGS += --include-dir=$(srctree) @@ -369,6 +360,13 @@ PERL = perl PYTHON = python CHECK = sparse +ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) +COMPILER := clang +else +COMPILER := gcc +endif +export COMPILER + CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ -Wbitwise -Wno-return-void $(CF) CFLAGS_MODULE = -- 2.1.4