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 73E3CC11F67 for ; Wed, 14 Jul 2021 18:16:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CD24613B6 for ; Wed, 14 Jul 2021 18:16:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240014AbhGNST2 (ORCPT ); Wed, 14 Jul 2021 14:19:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbhGNST0 (ORCPT ); Wed, 14 Jul 2021 14:19:26 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFD66C061760 for ; Wed, 14 Jul 2021 11:16:33 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 8so5136115lfp.9 for ; Wed, 14 Jul 2021 11:16:33 -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=gdYfStJb5mwOOj1KojUyVafFJ1o2WedkSsc19T3H7UY=; b=NWbdnzBEli+FCtVqOVGaPss2MwLIRyY/wdM4+OblEBSOHLPtHRJx4v4lqeWS87OiJq GrCDPu7eUBhilt/v8alOd8G8WOI58C8iirfAC7Bz5pOBy2GTDt8ZNdlBxGQUO3n4YrBX 0YKG1LOyZQ9udog24gV/2cMfql+Vkwc1NHmxZvx5GcfwE8hcU6pFqbjySrUJjrRw2Wp9 mApyz4NWpEbcuSm3WOHq4Qb6GYGwKDFVRWXkeey6gBTkA2EnAqy9IxDqE3imgbiOZ+V1 pU7DeFfq4lKx0B5Opnxs9bmnjeQZ7/8mdW9zD4wwqb+xlxZyqrUAVcx6lpH5Y8+P6nMC F3WA== 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=gdYfStJb5mwOOj1KojUyVafFJ1o2WedkSsc19T3H7UY=; b=QrIYunNVZdyAy/bC/oTVhThDgAJlOtERK7+iiB3tPitF9jfkqWMSakU1ZqIFwY4zag b2HF0d2RX+1DHYSz0lyKE9THS18dfLWHf7eT4FHExXr1/0gxzdR2qtPJDrkAvXtYmwfX NZbGpLbFIgOn6FruM65rWWZ0E+qo2fWwKmlttpAkGKy8CverJDOTzcgU0GqrS1+U5E0e Qsev1uWGvGmHZnW9vCo33g031sFcUgssc9sH9HWJLdRy2o7REA6uMcw5tcg2ZZLOUHk+ jqItDqT0oaQAYhRof7P/0eMBl3pWmN+nnmtIQXyBqI3a/lVo4tMnbg1ldoKWAxbs/69H 4Uow== X-Gm-Message-State: AOAM531DFCtn6+DlwuBNCxBByQlZu9BRvpcr2LAJ3sd3XQpl937c9sxC 27NzVMN5ft0NyRnarztQFNKDVoz1IbwjmAsusLrH4Q== X-Google-Smtp-Source: ABdhPJzEKs9SRTQ6+N8LhT06hWiRWkYkLtuXtaEpRgI5+ZlKGUTLSDyWY2UH/XyxBPnSN/RKA3eJ4h/aWPEjT0jZRRI= X-Received: by 2002:ac2:59db:: with SMTP id x27mr5574226lfn.547.1626286592091; Wed, 14 Jul 2021 11:16:32 -0700 (PDT) MIME-Version: 1.0 References: <20210704202756.29107-1-ojeda@kernel.org> <20210704202756.29107-4-ojeda@kernel.org> In-Reply-To: From: Nick Desaulniers Date: Wed, 14 Jul 2021 11:16:20 -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 Wed, Jul 14, 2021 at 11:13 AM Nick Desaulniers wrote: > > 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 Also, consider whether `BINDGEN_FLAGS` would be more descriptive (and less verbose) than `TENTATIVE_CLANG_FLAGS`. > > + > > 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 -- Thanks, ~Nick Desaulniers