Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5645745imu; Mon, 26 Nov 2018 03:28:21 -0800 (PST) X-Google-Smtp-Source: AJdET5eNJv7CYKKMUoOZlJE9v/dLcuAxzoVE9LCnGBqCVHXM0Y88Q5rwQELHSSfwivGtj/3LOA5T X-Received: by 2002:a62:399b:: with SMTP id u27mr28396134pfj.181.1543231701553; Mon, 26 Nov 2018 03:28:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543231701; cv=none; d=google.com; s=arc-20160816; b=BQvAM6Kpx2hQdokirriWrRii9AmdxQ+NxNxiABqetNbX51zCazZqbHpFDvU7gdxsP/ Gm3awfgNSdwGme4DkxTouOXhocTa2gsRqaRNyoQAYH7J6L4iDOCSTutbxprAH5bJmK0O n9Apgz/h0rwUgjUZcEfZ2l/6Yrdn0T1O7DkondsNyJKpFodcrKe85YrZAolvEPOpfydz cdCsHKNiNxz8ijZYVFIctGfQBwbSSuqhi4bVNle0GmEAvUMTIqDvCrhxWc3jLXO1hJbJ XwW2HCfr2EQECdRqikxK31Hpn8Tfkj3I/d7BOKJNvYav7/SgQgMnIq45fUdUzjymfG0n RTVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2WyA0709Fo1BS1MKXXTdxrhwngSbWjjOJ0keSyyHPjg=; b=lLJaUZb6QpS+g6EPdttUyszULRI0RdeSS6x6MzlceqkhBB/C5lpnem9NIBh9TqWhXN UyHBc4nV7PWxSZ8ZNFTzx1hPWW2gANW/gUwymNtlAdQr1QFpxL0OZ1UFgAT142BWIArn Krpo/muyqzhgAv6D02Tu58v7TeF5SY3OVIjk4bC7xLnb/M+UPxFygknGnB4whptiBjfa 8/FYbrGFxZx2mpo30SdWwTu13P+r/GJgyO5Kucsh1Ch7ntnQJR1QOWvvyc4SbWqdPzFC OdVPCNodk1u3OdGhNCRejZvlGHh4ydZB0HKV9C8g35Oqa35xMITxp+I0Ur9h2tFe97C9 ZtdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lLEUtStF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y123si26552pfy.18.2018.11.26.03.27.55; Mon, 26 Nov 2018 03:28:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lLEUtStF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727150AbeKZVrk (ORCPT + 99 others); Mon, 26 Nov 2018 16:47:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:55866 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727045AbeKZVri (ORCPT ); Mon, 26 Nov 2018 16:47:38 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8F22220817; Mon, 26 Nov 2018 10:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543229635; bh=9nmPxmXw6IMqVd2l40wXTfvK6chJXeDJshg+yFuDruE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lLEUtStFITHcYpv595RDE0LQToS46V7nQ+/q+sCgOCruFTfdR7DM3RK1D2rS8A5hX 7ygSRxA07Du3dcNpYu8r+Et6VGjgSFwYP0X0XbuCDTegDsl2+h0AymljeY6IzvNOzI tOxs6+yzoksqWgp4AJJCt7ibfngKv4bG3RgaEsSU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Behan Webster , =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= , Mark Charlebois , Greg Hackmann , Matthias Kaehlcke , Masahiro Yamada , Nathan Chancellor Subject: [PATCH 4.4 06/70] kbuild: Add better clang cross build support Date: Mon, 26 Nov 2018 11:50:21 +0100 Message-Id: <20181126105047.521454664@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105046.722096341@linuxfoundation.org> References: <20181126105046.722096341@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Behan Webster commit 785f11aa595bc3d4e74096cbd598ada54ecc0d81 upstream. Add cross target to CC if using clang. Also add custom gcc toolchain path for fallback gcc tools. Clang will fallback to using things like ld, as, and libgcc if (respectively) one of the llvm linkers isn't available, the integrated assembler is turned off, or an appropriately cross-compiled version of compiler-rt isn't available. To this end, you can specify the path to this fallback gcc toolchain with GCC_TOOLCHAIN. Signed-off-by: Behan Webster Reviewed-by: Jan-Simon Möller Reviewed-by: Mark Charlebois Signed-off-by: Greg Hackmann Signed-off-by: Matthias Kaehlcke Signed-off-by: Masahiro Yamada Signed-off-by: Nathan Chancellor Signed-off-by: Greg Kroah-Hartman --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/Makefile +++ b/Makefile @@ -698,6 +698,15 @@ endif KBUILD_CFLAGS += $(stackp-flag) ifeq ($(cc-name),clang) +ifneq ($(CROSS_COMPILE),) +CLANG_TARGET := -target $(notdir $(CROSS_COMPILE:%-=%)) +GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..) +endif +ifneq ($(GCC_TOOLCHAIN),) +CLANG_GCC_TC := -gcc-toolchain $(GCC_TOOLCHAIN) +endif +KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) +KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,) KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)