Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3277967pxv; Sun, 4 Jul 2021 13:29:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHJUJ+4DCC933Y2VCZVl0dha0qfb5cV3WHIHjKXD4q2PEbRPTdFQ5874v0PLPQedvHgl2I X-Received: by 2002:a05:6602:58e:: with SMTP id v14mr8863557iox.181.1625430572330; Sun, 04 Jul 2021 13:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625430572; cv=none; d=google.com; s=arc-20160816; b=Wr/ElwYdks54Yyo2HORUqozLezHrKxEPSfLKVfzw55CGE2WfMw9STcOPwdOdPQnftm FrLEJFBazC06ypjB/gnJwXgyf0LNCtwTrFHR8oBCPOPebfHLykZBLMPqveffnMcf/ZqX kKj1ES3DIsV/TL9SvEBw7vCuPwvQrpJRdUmyC9VcUcGy8YZ6d5BfatcbkBPmUai/EAUu Eyj3aPopLGzEWeHtoCjYbAmpCp9Ox9uWfMrKglz1jEUB5ef+HdOBTERWaftKzVcPzzBK vLyJPQ29J640gAwPsXD463OMtZ4M9EJ3Ggau/cr2HnfFD7NmgNzgYfH+P1l38diANd2N S8FA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BIshOP1K4HEKhxVB49heXkVuoXSlYFub9Otx20mRt1M=; b=jqiOVdWw3j7WWONzBv9UVK0QF9RYRXJJR7oFV+LbIMEJxyPfDJDxi6nJODbzv06cFR oVgLrgjkBP5CGMZbC9VkQbICdIe/Dbrdc9Dv3vHfxbK+OZWjx+znncr+TbqPfR2VTAm0 ZnfMa7YmcHGHibQiIPLILMx3EPi1JDMNkg5cmYBsniktpTQ5okjLlBOnz41W0HA0cgf1 qS15D/5Lu5OzLfudU4D7EjzfdLBQVtE6YhAhNcLI0zy2MiW49EMrKwe5XP9EsznvafDk 7IU4oTKCUiuWPf+9Nu4eHhxPuJVE82eFBJjwmOdCRZgI3Ef6Su02Bqo0fePDKGFcmLeM 14Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Usx3Cccb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x13si11090514jas.89.2021.07.04.13.29.21; Sun, 04 Jul 2021 13:29:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Usx3Cccb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229981AbhGDUbV (ORCPT + 99 others); Sun, 4 Jul 2021 16:31:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:36720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229963AbhGDUbU (ORCPT ); Sun, 4 Jul 2021 16:31:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EE5466115C; Sun, 4 Jul 2021 20:28:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625430524; bh=9sHxSofkyts3lBEKvreHLTsKUIXAeirgJMCP+4zsqes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Usx3CccbvuHYIGN72WFhDCC3dDydQtYIvfsi4NoBzNKDCPS8QRtRkBk4Cyk50Inln QQLbsMfRT86Pa10e/mL8atPMTDvFem1bRLMLvmL8wJC4i0rd1ctYFjJMK45EBtTsjG ySSbciM5yk5HqipOXlDNdMaeZkpgtOhxtug4f+CeCQQZ3tTB087ZfKEh6Rqf1U0OHH 1xQWhY7Iek+h8W2w2Zi0TrI2Cz/+R0U1n9zX9WinMFdVyUE6pYBD5E84LCmU/En6nf prb5rgfEco3P/JDEpVWcNum6P01OPmtXdaksCchpUn8qjeFOufE6uIQ6DeBfhHQjsk Kzbc5Gn9BNQWw== From: ojeda@kernel.org To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Geoffrey Thomas , Finn Behrens , Adam Bratschi-Kaye , Wedson Almeida Filho Subject: [PATCH 03/17] Makefile: generate `CLANG_FLAGS` even in GCC builds Date: Sun, 4 Jul 2021 22:27:42 +0200 Message-Id: <20210704202756.29107-4-ojeda@kernel.org> In-Reply-To: <20210704202756.29107-1-ojeda@kernel.org> References: <20210704202756.29107-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miguel Ojeda To support Rust under GCC-built kernels, we need to save the flags that would have been passed if the kernel was being compiled with Clang. The reason is that `bindgen` -- the tool we use to generate Rust bindings to the C side of the kernel -- relies on `libclang` to parse C. Ideally: - `bindgen` would support a GCC backend (requested at [1]), - or the Clang driver would be perfectly compatible with GCC, including plugins. Unlikely, of course, but perhaps a big subset of configs may be possible to guarantee to be kept compatible nevertheless. This is also the reason why GCC builds are very experimental and some configurations may not work (e.g. `GCC_PLUGIN_RANDSTRUCT`). However, we keep GCC builds working (for some example configs) in the CI to avoid diverging/regressing further, so that we are better prepared for the future when a solution might become available. [1] https://github.com/rust-lang/rust-bindgen/issues/1949 Link: https://github.com/Rust-for-Linux/linux/issues/167 Co-developed-by: Alex Gaynor Signed-off-by: Alex Gaynor Co-developed-by: Geoffrey Thomas Signed-off-by: Geoffrey Thomas Co-developed-by: Finn Behrens Signed-off-by: Finn Behrens Co-developed-by: Adam Bratschi-Kaye Signed-off-by: Adam Bratschi-Kaye Co-developed-by: Wedson Almeida Filho Signed-off-by: Wedson Almeida Filho Signed-off-by: Miguel Ojeda --- Makefile | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 0565caea036..6e823d8bd64 100644 --- a/Makefile +++ b/Makefile @@ -573,18 +573,23 @@ endif # and from include/config/auto.conf.cmd to detect the compiler upgrade. CC_VERSION_TEXT = $(subst $(pound),,$(shell $(CC) --version 2>/dev/null | head -n 1)) -ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) +TENTATIVE_CLANG_FLAGS := -Werror=unknown-warning-option + ifneq ($(CROSS_COMPILE),) -CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) +TENTATIVE_CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) endif ifeq ($(LLVM_IAS),1) -CLANG_FLAGS += -integrated-as +TENTATIVE_CLANG_FLAGS += -integrated-as else -CLANG_FLAGS += -no-integrated-as +TENTATIVE_CLANG_FLAGS += -no-integrated-as GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) -CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) +TENTATIVE_CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) endif -CLANG_FLAGS += -Werror=unknown-warning-option + +export TENTATIVE_CLANG_FLAGS + +ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) +CLANG_FLAGS += $(TENTATIVE_CLANG_FLAGS) KBUILD_CFLAGS += $(CLANG_FLAGS) KBUILD_AFLAGS += $(CLANG_FLAGS) export CLANG_FLAGS -- 2.32.0