From patchwork Thu Aug 8 21:06:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Tucker X-Patchwork-Id: 11084747 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BB4D746 for ; Thu, 8 Aug 2019 21:07:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A8C228AC1 for ; Thu, 8 Aug 2019 21:07:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E15228BC6; Thu, 8 Aug 2019 21:07:52 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY 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 05C1928AC1 for ; Thu, 8 Aug 2019 21:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732427AbfHHVHv (ORCPT ); Thu, 8 Aug 2019 17:07:51 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:43512 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730768AbfHHVHv (ORCPT ); Thu, 8 Aug 2019 17:07:51 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: gtucker) with ESMTPSA id 5EF0328CB48 From: Guillaume Tucker To: Masahiro Yamada , Michal Marek Cc: Mark Brown , Guenter Roeck , Nick Desaulniers , clang-built-linux@googlegroups.com, linux-kbuild@vger.kernel.org, kernel@collabora.com, Guillaume Tucker Subject: [PATCH RFC 1/1] kbuild: enable overriding the compiler using the environment Date: Thu, 8 Aug 2019 23:06:52 +0200 Message-Id: <3885ccdcbdbe83eb367e8344584df944adc76e34.1565297255.git.guillaume.tucker@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Only use gcc/g++ for HOSTCC, HOSTCXX and CC by default if they are not already defined in the environment. This fixes cases such as building host tools with clang without having gcc installed. The issue was initially hit when running merge_config.sh with clang only as it failed to build "HOSTCC scripts/basic/fixdep". Signed-off-by: Guillaume Tucker Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 23cdf1f41364..c8608126750d 100644 --- a/Makefile +++ b/Makefile @@ -400,8 +400,8 @@ HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null) HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null) HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null) -HOSTCC = gcc -HOSTCXX = g++ +HOSTCC ?= gcc +HOSTCXX ?= g++ KBUILD_HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \ -fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \ $(HOSTCFLAGS) @@ -412,7 +412,7 @@ KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) # Make variables (CC, etc...) AS = $(CROSS_COMPILE)as LD = $(CROSS_COMPILE)ld -CC = $(CROSS_COMPILE)gcc +CC ?= $(CROSS_COMPILE)gcc CPP = $(CC) -E AR = $(CROSS_COMPILE)ar NM = $(CROSS_COMPILE)nm