Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp617005pxv; Wed, 14 Jul 2021 11:15:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqbU0T/WQAV1rOUltu0AcqkNPWfjjNiljnrDT5tmJtqlhfvHQPlT3WU6xBO8oIEL+NkFYy X-Received: by 2002:a17:907:778a:: with SMTP id ky10mr13554008ejc.32.1626286549178; Wed, 14 Jul 2021 11:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626286549; cv=none; d=google.com; s=arc-20160816; b=ruWzuvoeyJDLTthD7OAVFxh6CB2jrfycBVfY/4vOH2GXna4x42gaI+itvzCcByifx9 1MmrPn8e5ZePQJpyix0jBj7hIXdaDN81ZUQ94ppHPU6Rzm3GK36cpUJ6R8dPPi+PmTsX f4JIwS52xfKJv9v/d+QhP4hiGn2K+wOFJNNGx8zMSk+LJrbyCbwK7VtVOnbBiWhFKi7T 54gwlpNg91fUKqggt0iqQihbPm3TaJKvcepLwHSI+HERAgpy4OqyOVUzI/ztM6RHHopi O1nNcPkFgBlBiLw/cf22bV8+A/ATagO+/PKXpcfh3FqqiLMaaB+kMd1gMYn98axZ8qar hnaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=O8TPU0hqO2c6lrmOpVCEHEZ3QntgeMzfXOeutKZUuGQ=; b=m/JRs6zs16p+xhBSGqp8UOsdFZeHH95QdYXAwpbt85jSJ3TZizkNExX0oURq6Dt+iU GYPWL5swHoL+TfvkPIvZBFPs/C5bZ3MFHQTlvgR0wGxwGx4HIYH5GIVXOrR5m97QhIGt lxs7Z7OxVxjTT99xd1v91nhs+E+WSRlutR70inqjhtqZP0CCoEgV1OrL1/8Dgs1w3kT8 QpTYbERWuwwDFr0ILBB/DDQHC2eHdt+x3y6OYBvpCcQmwpFozJAf9SxBYUbpE3z9dP/H jfARdiBKaYDzK8vmhYrSncM552K2x8zOwKIaarxwub7dQBGI/4rfGu47fsi94bCElBAo DZag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GP0Dd2He; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l21si3869025edw.390.2021.07.14.11.15.24; Wed, 14 Jul 2021 11:15:49 -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=@google.com header.s=20161025 header.b=GP0Dd2He; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239918AbhGNSRD (ORCPT + 99 others); Wed, 14 Jul 2021 14:17:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239974AbhGNSRD (ORCPT ); Wed, 14 Jul 2021 14:17:03 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 174FCC061762 for ; Wed, 14 Jul 2021 11:14:11 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id f30so5184106lfj.1 for ; Wed, 14 Jul 2021 11:14:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=O8TPU0hqO2c6lrmOpVCEHEZ3QntgeMzfXOeutKZUuGQ=; b=GP0Dd2HejNzwHWckSqUuuJQz3ybU1NQTkuAQYQ0Iix+Gqdo0eWbTBj7XnDaLG0wE8k 08OctU1iaTR+/lL1dLgTUKi8wCk+YBwdSpn0GKuvAGGCSDTXUJI/aMos9QYPB3SKgEc/ PAkGIeIRMCIYXU5yjKfC0MyZtFjcbDMD3hIxnGNz6Na67oIJlknmivj1spY/A/5qz5Ba h1I8KLXm+/aU4Kp8zxzQyuqrf52MKJN5gD5k96UWqJwy4ZIdiLeX0P0di+mSs4zycdR4 JYf35fE902Tc/W595ve57Iqs1LGBtYOmeKqw8jUZyPZKYI//Pi0OzfT+ooT83u22YhH/ v85Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=O8TPU0hqO2c6lrmOpVCEHEZ3QntgeMzfXOeutKZUuGQ=; b=dXl0kQ8XGQukvYVkiNdmdLN9lEdaKWRZ5tjLhlU9KrODFwCzbby/rdMqUSThSN5Bax S5VUcphGFSlDGX6XXFsCdvLahxDlcPkoLl76PCvM8A+/Y7gWBHaLvrFwjqzVVnRUPgck vc7AnDQA09blLyY3yeTG2nEnwcixq85s6yZhQGOPLyz4lWP0JyMDfZsUvm4nPRnT88X4 XDxPq72mTdyKlDezBYCigeMxeplSC2uqgyukfbfk3GkyrUDfn/BUShO9xPr8T4E9X9FU mR68v9SGdU9R0bnrVOwFuUxSn4xStYgwwVkFcpa3Kwvim9mMJt/ss04gKhxAc4pMuNuM 2ckQ== X-Gm-Message-State: AOAM530fHssiYBzvKWYSb7Xcn7b6bZi7jHUWZs7UUZkXU/UBq9gGfDTT TyARCvqZz2Trp1Wn7a7C4fhryMYIEpmRVG8C5Xvy5Q== X-Received: by 2002:a05:6512:3e0c:: with SMTP id i12mr8768338lfv.122.1626286449128; Wed, 14 Jul 2021 11:14:09 -0700 (PDT) MIME-Version: 1.0 References: <20210704202756.29107-1-ojeda@kernel.org> <20210704202756.29107-4-ojeda@kernel.org> In-Reply-To: <20210704202756.29107-4-ojeda@kernel.org> From: Nick Desaulniers Date: Wed, 14 Jul 2021 11:13:57 -0700 Message-ID: Subject: Re: [PATCH 03/17] Makefile: generate `CLANG_FLAGS` even in GCC builds To: ojeda@kernel.org Cc: Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Alex Gaynor , Geoffrey Thomas , Finn Behrens , Adam Bratschi-Kaye , Wedson Almeida Filho , clang-built-linux , Nathan Chancellor Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 4, 2021 at 1:28 PM wrote: > > 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 Patch LGTM; please keep an eye on the series: https://lore.kernel.org/lkml/20210707224310.1403944-2-ndesaulniers@google.com/ If that lands in kbuild before this, this patch will need to be rebased to avoid a conflict in linux-next. So (tentatively :-P): Reviewed-by: Nick Desaulniers If the patch needs to be rebased on the series linked above, please drop my reviewed by tag and I will re-review. Perhaps putting me explicitly on Cc: in the commit message will help notify me if there are successive versions? > --- > 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 > -- Thanks, ~Nick Desaulniers