Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3337552pxp; Tue, 8 Mar 2022 12:11:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeW+mbrg8o1e1h2SS5wQyw4LBjNcUPez7oFQERPfmnaWDl5U6FOb03JSRotPK6iJIj6Ldt X-Received: by 2002:a17:903:2c5:b0:14f:4a29:1f64 with SMTP id s5-20020a17090302c500b0014f4a291f64mr19546696plk.90.1646770301925; Tue, 08 Mar 2022 12:11:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646770301; cv=none; d=google.com; s=arc-20160816; b=hPIe9O5k3YRWrOrcRg5UnHI+lW/HAexWdN6QucukhGlQvrzy0nlUFMrqORjqZwI2UV RxOE6zwVOanCy5QN/G3s8zyEpCxm02AHhTqyLomshAHkBIlSvpKMAMbizu9ekv2dzc3s MUbRn4jFbFGEHK1LWDr5sH8Y1VSzTrMLAKhC2CPYq0KQYUq+lNymULjiMrSYBHTHS3OH jhh2+0DbIOXhv/9fzv7Gzl3LBBGdKCS4p0pR/o7+0V9yZiJO6gxJECdYRwRYBTvewghA Q4ULgHWIOCwBGGcC1+9tHR9mgx5SIZS4/txd6P73Zb5zgom34bZswkvLkd8R73M/LUYB Mb4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=LNqVujHVa7O8s40wwTjHqSBlnuZU+85HEp05z/qwvTA=; b=tUeNbJqBZHRlSYm+Lj0uJgyR6KZ/KG0c5p3XW3h/s7nNo2DLddsQ3MA6II91aouvL1 csBU7djVC+W4z5VzloYkjH3ERcpMIQywZTD7YBkf3jT1BcpCu6dT2rPMxx2UOnxFhf0L 6m1Yi+f3R9Z3yeBrP77xPYbnfIVP9uh47peGdkBkbGuVa7UWc3zrtHhoXvutFeo4iOE0 SU1Y+ZSpUSKADEBht5frTH2LGxq2wOj+sC7lC1mdpY5PprlIr//xOKROGxJO88byaH8N ht6XVt2b5ZXgU3uB6mW3AkSyQyWExXBO8R6LPDGsjJlSIFXCi8K4pBR55o0zAluhukCF 96Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=IuRYrUkU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a056a00218600b004f66e2b12f5si17063566pfi.255.2022.03.08.12.11.22; Tue, 08 Mar 2022 12:11:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=IuRYrUkU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346745AbiCHMPv (ORCPT + 99 others); Tue, 8 Mar 2022 07:15:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346732AbiCHMPu (ORCPT ); Tue, 8 Mar 2022 07:15:50 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A46A43ED1; Tue, 8 Mar 2022 04:14:54 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: aratiu) with ESMTPSA id EC43A1F43C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1646741693; bh=5+4CFM6veuq5rDnjMnbblwZsgeeLINo0x7U43XEkG9c=; h=From:To:Cc:Subject:Date:From; b=IuRYrUkUF0SCi0ER2nCHqEw02YkcL/vPTUhWSs79ZyitkMk0dynGcY39jBfxLIiaZ hmf9tTBEZf1t1e6xosUT5h1Su28aKNtYQeAP2kKvAAfO5dHgAslutstLuwA3QIQNUN zkRYUuUbl4pZTho63yPNAiMvo/5ikHBr/CvcBxefFVs2Jtj14kwJdWJwYO5WJxRZI/ r6eHwi2RPudIMXeXHSAaMlntMUlBToduBaM0nYcDWprzdmx+9zp5m4QFPSnBZTqiyn uQvI+dkLx6F0gD6mHFxqn6mS0ilxypk2AS+BR1mtR2DAR1CtxcG1+bV5y+GHU3ltKx 25knDK62+s5UQ== From: Adrian Ratiu To: netdev@vger.kernel.org Cc: llvm@lists.linux.dev, kernel@collabora.com, linux-kernel@vger.kernel.org, Nick Desaulniers , Manoj Gupta , Nathan Chancellor Subject: [PATCH bpf v2] tools: fix unavoidable GCC call in Clang builds Date: Tue, 8 Mar 2022 14:14:28 +0200 Message-Id: <20220308121428.81735-1-adrian.ratiu@collabora.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In ChromeOS and Gentoo we catch any unwanted mixed Clang/LLVM and GCC/binutils usage via toolchain wrappers which fail builds. This has revealed that GCC is called unconditionally in Clang configured builds to populate GCC_TOOLCHAIN_DIR. Allow the user to override CLANG_CROSS_FLAGS to avoid the GCC call - in our case we set the var directly in the ebuild recipe. In theory Clang could be able to autodetect these settings so this logic could be removed entirely, but in practice as the commit cebdb7374577 ("tools: Help cross-building with clang") mentions, this does not always work, so giving distributions more control to specify their flags & sysroot is beneficial. Suggested-by: Manoj Gupta Suggested-by: Nathan Chancellor Acked-by: Nathan Chancellor Signed-off-by: Adrian Ratiu --- Changes in v2: * Replaced variable override GCC_TOOLCHAIN_DIR -> CLANG_CROSS_FLAGS --- tools/scripts/Makefile.include | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index 79d102304470..b9b1deacc4eb 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -89,6 +89,9 @@ ifeq ($(CC_NO_CLANG), 1) EXTRA_WARNINGS += -Wstrict-aliasing=3 else ifneq ($(CROSS_COMPILE),) +# allow userspace to override CLANG_CROSS_FLAGS to specify their own +# sysroots and flags or to avoid the GCC call in pure Clang builds +ifeq ($(CLANG_CROSS_FLAGS),) CLANG_CROSS_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%)) GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)gcc 2>/dev/null)) ifneq ($(GCC_TOOLCHAIN_DIR),) @@ -96,6 +99,7 @@ CLANG_CROSS_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) CLANG_CROSS_FLAGS += --sysroot=$(shell $(CROSS_COMPILE)gcc -print-sysroot) CLANG_CROSS_FLAGS += --gcc-toolchain=$(realpath $(GCC_TOOLCHAIN_DIR)/..) endif # GCC_TOOLCHAIN_DIR +endif # CLANG_CROSS_FLAGS CFLAGS += $(CLANG_CROSS_FLAGS) AFLAGS += $(CLANG_CROSS_FLAGS) endif # CROSS_COMPILE -- 2.35.1