From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-28.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 881CCC11F67 for ; Wed, 14 Jul 2021 18:14:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72952613C8 for ; Wed, 14 Jul 2021 18:14:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240002AbhGNSRE (ORCPT ); Wed, 14 Jul 2021 14:17:04 -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-Google-Smtp-Source: ABdhPJzGQBRL19G8n4JdfX5XiIs4hch17ulA/Fmu33Rkcgp58p/SczPkAD+RTaPFPpf30NDPB1c736FtkruzNIUr9lM= 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