From: Nathan Chancellor <nathan@kernel.org>
To: ojeda@kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Alex Gaynor <alex.gaynor@gmail.com>,
Geoffrey Thomas <geofft@ldpreload.com>,
Finn Behrens <me@kloenk.de>,
Adam Bratschi-Kaye <ark.email@gmail.com>,
Wedson Almeida Filho <wedsonaf@google.com>,
Michal Suchanek <msuchanek@suse.de>,
Masahiro Yamada <masahiroy@kernel.org>
Subject: Re: [PATCH 03/13] Makefile: Generate CLANG_FLAGS even in GCC builds
Date: Wed, 14 Apr 2021 11:59:48 -0700 [thread overview]
Message-ID: <YHc7pHjwmDJrkXqZ@archlinux-ax161> (raw)
In-Reply-To: <20210414184604.23473-4-ojeda@kernel.org>
Hi Miguel,
On Wed, Apr 14, 2021 at 08:45:54PM +0200, ojeda@kernel.org wrote:
> From: Miguel Ojeda <ojeda@kernel.org>
>
> 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 <alex.gaynor@gmail.com>
> Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
> Co-developed-by: Geoffrey Thomas <geofft@ldpreload.com>
> Signed-off-by: Geoffrey Thomas <geofft@ldpreload.com>
> Co-developed-by: Finn Behrens <me@kloenk.de>
> Signed-off-by: Finn Behrens <me@kloenk.de>
> Co-developed-by: Adam Bratschi-Kaye <ark.email@gmail.com>
> Signed-off-by: Adam Bratschi-Kaye <ark.email@gmail.com>
> Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com>
> Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> Makefile | 27 ++++++++++++++++-----------
> 1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index d4784d181123..9c75354324ed 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -559,26 +559,31 @@ ifdef building_out_of_srctree
> { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
> endif
>
> -# The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
> -# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
> -# CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
> -# and from include/config/auto.conf.cmd to detect the compiler upgrade.
> -CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1 | sed 's/\#//g')
> +TENTATIVE_CLANG_FLAGS := -Werror=unknown-warning-option
>
> -ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
> ifneq ($(CROSS_COMPILE),)
> -CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
> +TENTATIVE_CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
> GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
Shuffling this around will cause this issue (I never saw you CC'd on the
thread).
https://lore.kernel.org/r/f6218ac526a04fa4d4406f935bcc4eb4a7df65c4.1617917438.git.msuchanek@suse.de/
Perhaps that patch should be added to this series?
> -CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
> +TENTATIVE_CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
> GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
> endif
> ifneq ($(GCC_TOOLCHAIN),)
> -CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
> +TENTATIVE_CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
> endif
> ifneq ($(LLVM_IAS),1)
> -CLANG_FLAGS += -no-integrated-as
> +TENTATIVE_CLANG_FLAGS += -no-integrated-as
> endif
> -CLANG_FLAGS += -Werror=unknown-warning-option
> +
> +export TENTATIVE_CLANG_FLAGS
> +
> +# The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
> +# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
> +# CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
> +# and from include/config/auto.conf.cmd to detect the compiler upgrade.
> +CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1 | sed 's/\#//g')
> +
> +ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
> +CLANG_FLAGS += $(TENTATIVE_CLANG_FLAGS)
> KBUILD_CFLAGS += $(CLANG_FLAGS)
> KBUILD_AFLAGS += $(CLANG_FLAGS)
> export CLANG_FLAGS
> --
> 2.17.1
>
next prev parent reply other threads:[~2021-04-14 18:59 UTC|newest]
Thread overview: 199+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 18:45 [PATCH 00/13] [RFC] Rust support ojeda
2021-04-14 18:45 ` [PATCH 01/13] kallsyms: Support "big" kernel symbols (2-byte lengths) ojeda
2021-04-14 19:44 ` Matthew Wilcox
2021-04-14 19:59 ` Miguel Ojeda
2021-04-14 18:45 ` [PATCH 02/13] kallsyms: Increase maximum kernel symbol length to 512 ojeda
2021-04-14 23:48 ` Nick Desaulniers
2021-04-14 18:45 ` [PATCH 03/13] Makefile: Generate CLANG_FLAGS even in GCC builds ojeda
2021-04-14 18:59 ` Nathan Chancellor [this message]
2021-04-15 10:18 ` Miguel Ojeda
2021-04-14 23:46 ` Nick Desaulniers
2021-04-15 0:47 ` Miguel Ojeda
2021-04-14 18:45 ` [PATCH 04/13] Kbuild: Rust support ojeda
2021-04-14 23:19 ` Nick Desaulniers
2021-04-15 0:43 ` Miguel Ojeda
2021-04-15 18:03 ` Nick Desaulniers
2021-04-16 12:23 ` Miguel Ojeda
2021-04-17 19:35 ` Masahiro Yamada
2021-04-16 13:38 ` Peter Zijlstra
2021-04-16 17:05 ` Linus Torvalds
2021-04-16 17:47 ` Miguel Ojeda
2021-04-16 18:09 ` Al Viro
2021-04-16 18:57 ` Miguel Ojeda
2021-04-16 20:22 ` Willy Tarreau
2021-04-16 20:34 ` Connor Kuehl
2021-04-16 20:58 ` Willy Tarreau
2021-04-16 21:39 ` Miguel Ojeda
2021-04-16 22:04 ` Willy Tarreau
2021-04-16 22:45 ` Al Viro
2021-04-16 23:46 ` Miguel Ojeda
2021-04-17 4:24 ` Willy Tarreau
2021-04-17 15:38 ` Miguel Ojeda
2021-04-16 21:19 ` Miguel Ojeda
2021-04-16 17:34 ` Miguel Ojeda
2021-04-19 19:58 ` David Sterba
2021-04-19 20:17 ` Matthew Wilcox
2021-04-19 21:03 ` Miguel Ojeda
2021-04-19 20:54 ` Miguel Ojeda
2021-04-14 18:45 ` [PATCH 05/13] Rust: Compiler builtins crate ojeda
2021-04-14 19:19 ` Linus Torvalds
2021-04-14 19:34 ` Miguel Ojeda
2021-04-14 18:45 ` [PATCH 06/13] Rust: Module crate ojeda
2021-04-14 18:45 ` [PATCH 08/13] Rust: Export generated symbols ojeda
2021-04-14 18:46 ` [PATCH 09/13] Samples: Rust examples ojeda
2021-04-14 19:34 ` Linus Torvalds
2021-04-14 19:42 ` Miguel Ojeda
2021-04-14 19:49 ` Matthew Wilcox
2021-04-16 11:46 ` Andrej Shadura
2021-04-14 23:24 ` Nick Desaulniers
2021-04-15 7:10 ` Greg Kroah-Hartman
2021-04-15 7:39 ` Nick Desaulniers
2021-04-15 12:42 ` Miguel Ojeda
2021-04-16 13:07 ` Sven Van Asbroeck
2021-04-16 13:20 ` Greg Kroah-Hartman
2021-04-14 18:46 ` [PATCH 10/13] Documentation: Rust general information ojeda
2021-04-14 22:17 ` Nick Desaulniers
2021-04-14 23:34 ` Miguel Ojeda
2021-04-14 18:46 ` [PATCH 11/13] MAINTAINERS: Rust ojeda
2021-04-14 21:55 ` Nick Desaulniers
2021-04-14 22:02 ` Miguel Ojeda
2021-04-14 22:36 ` Nick Desaulniers
2021-04-14 18:46 ` [PATCH 12/13] Rust: add abstractions for Binder (WIP) ojeda
[not found] ` <20210414184604.23473-8-ojeda@kernel.org>
2021-04-14 19:31 ` [PATCH 07/13] Rust: Kernel crate Linus Torvalds
2021-04-14 19:50 ` Miguel Ojeda
2021-04-14 19:44 ` [PATCH 00/13] [RFC] Rust support Linus Torvalds
2021-04-14 20:20 ` Miguel Ojeda
2021-04-15 1:38 ` Kees Cook
2021-04-15 8:26 ` David Laight
2021-04-15 18:08 ` Kees Cook
2021-04-15 12:39 ` Miguel Ojeda
2021-04-14 20:09 ` Matthew Wilcox
2021-04-14 20:21 ` Linus Torvalds
2021-04-14 20:35 ` Josh Triplett
2021-04-14 22:08 ` David Laight
2021-04-14 20:29 ` Miguel Ojeda
2021-04-18 15:31 ` Wedson Almeida Filho
2021-04-15 0:22 ` Nick Desaulniers
2021-04-15 10:05 ` Miguel Ojeda
2021-04-15 18:58 ` Peter Zijlstra
2021-04-16 2:22 ` Wedson Almeida Filho
2021-04-16 4:25 ` Al Viro
2021-04-16 5:02 ` Wedson Almeida Filho
2021-04-16 5:39 ` Paul Zimmerman
2021-04-16 7:46 ` Peter Zijlstra
2021-04-16 7:09 ` Peter Zijlstra
2021-04-17 5:23 ` comex
2021-04-17 12:46 ` David Laight
2021-04-17 14:51 ` Paolo Bonzini
2021-04-19 7:32 ` Peter Zijlstra
2021-04-19 7:53 ` Paolo Bonzini
2021-04-19 8:26 ` Peter Zijlstra
2021-04-19 8:35 ` Peter Zijlstra
2021-04-19 9:02 ` Paolo Bonzini
2021-04-19 9:36 ` Peter Zijlstra
2021-04-19 9:40 ` Paolo Bonzini
2021-04-19 11:01 ` Will Deacon
2021-04-19 17:14 ` Linus Torvalds
2021-04-19 18:38 ` Paolo Bonzini
2021-04-19 18:50 ` Linus Torvalds
2021-04-22 10:03 ` Linus Walleij
2021-04-22 14:09 ` David Laight
2021-04-22 15:24 ` Wedson Almeida Filho
2021-04-26 0:18 ` Linus Walleij
2021-04-26 14:26 ` Miguel Ojeda
2021-04-26 14:40 ` Wedson Almeida Filho
2021-04-26 16:03 ` Miguel Ojeda
2021-04-27 10:54 ` Linus Walleij
2021-04-27 11:13 ` Robin Randhawa
2021-04-29 1:52 ` Wedson Almeida Filho
2021-04-26 18:01 ` Miguel Ojeda
2021-04-22 21:28 ` Miguel Ojeda
2021-04-26 0:31 ` Linus Walleij
2021-04-26 18:18 ` Miguel Ojeda
2021-04-27 11:13 ` Linus Walleij
2021-04-28 2:51 ` Kyle Strand
2021-04-28 3:10 ` Miguel Ojeda
2021-05-04 21:21 ` Linus Walleij
2021-05-04 23:30 ` Miguel Ojeda
2021-05-05 11:34 ` Linus Walleij
2021-05-05 14:17 ` Miguel Ojeda
2021-05-05 15:13 ` Enrico Weigelt, metux IT consult
2021-05-06 12:47 ` Linus Walleij
2021-05-07 18:23 ` Miguel Ojeda
2021-04-16 4:27 ` Boqun Feng
2021-04-16 6:04 ` Nick Desaulniers
2021-04-16 18:47 ` Paul E. McKenney
2021-04-19 20:35 ` Nick Desaulniers
2021-04-19 21:37 ` Paul E. McKenney
2021-04-19 22:03 ` Miguel Ojeda
2021-04-16 20:48 ` Josh Triplett
2021-04-16 8:16 ` Michal Kubecek
2021-04-16 9:29 ` Willy Tarreau
2021-04-16 11:24 ` Peter Zijlstra
2021-04-16 13:07 ` Wedson Almeida Filho
2021-04-16 14:19 ` Peter Zijlstra
2021-04-16 15:04 ` Miguel Ojeda
2021-04-16 15:43 ` Peter Zijlstra
2021-04-16 16:21 ` Miguel Ojeda
2021-04-16 15:33 ` Wedson Almeida Filho
2021-04-16 16:14 ` Willy Tarreau
2021-04-16 17:10 ` Miguel Ojeda
2021-04-16 17:18 ` Peter Zijlstra
2021-04-16 18:08 ` Matthew Wilcox
2021-04-17 11:17 ` Peter Zijlstra
2021-04-17 11:46 ` Willy Tarreau
2021-04-17 14:24 ` Peter Zijlstra
2021-04-17 14:36 ` Willy Tarreau
2021-04-17 13:46 ` David Laight
2021-04-16 17:37 ` Willy Tarreau
2021-04-16 17:46 ` Connor Kuehl
2021-04-20 0:24 ` Nick Desaulniers
2021-04-20 3:47 ` Willy Tarreau
2021-04-20 5:56 ` Greg Kroah-Hartman
2021-04-20 6:16 ` Willy Tarreau
2021-04-29 15:38 ` peter enderborg
2021-04-17 13:53 ` Wedson Almeida Filho
2021-04-17 14:21 ` Willy Tarreau
2021-04-17 15:23 ` Miguel Ojeda
2021-04-18 15:51 ` Wedson Almeida Filho
2021-04-17 12:41 ` David Laight
2021-04-17 13:01 ` Wedson Almeida Filho
2021-04-16 15:03 ` Matthew Wilcox
2021-04-17 13:29 ` Wedson Almeida Filho
2021-04-16 15:58 ` Theodore Ts'o
2021-04-16 16:21 ` Wedson Almeida Filho
2021-04-17 15:11 ` Paolo Bonzini
2021-04-16 14:21 ` Miguel Ojeda
2021-04-17 20:42 ` Richard Weinberger
2021-04-28 18:34 ` Mariusz Ceier
2021-04-28 20:25 ` Nick Desaulniers
2021-04-28 21:21 ` David Laight
2021-04-29 11:14 ` Kajetan Puchalski
2021-04-29 11:25 ` Kajetan Puchalski
2021-04-29 14:06 ` Mariusz Ceier
2021-04-29 14:13 ` Sven Van Asbroeck
2021-04-29 14:26 ` Willy Tarreau
2021-04-29 15:06 ` Al Viro
2021-04-29 16:09 ` Mariusz Ceier
2021-04-30 6:39 ` Thomas Schoebel-Theuer
2021-04-30 8:30 ` David Laight
2021-05-05 13:58 ` Enrico Weigelt, metux IT consult
2021-05-05 14:41 ` Miguel Ojeda
2022-06-20 15:11 ` Olliver Schinagl
2022-06-27 17:44 ` Miguel Ojeda
2022-07-18 6:56 ` Olliver Schinagl
2022-07-20 19:23 ` Miguel Ojeda
2022-07-20 20:21 ` Nicolas Pitre
2022-07-27 7:47 ` Olliver Schinagl
2022-07-27 13:32 ` Nicolas Pitre
2022-07-27 8:05 ` Olliver Schinagl
2022-07-28 10:21 ` Gary Guo
2022-07-28 12:09 ` Greg Kroah-Hartman
2022-07-28 12:28 ` Gary Guo
2022-07-28 20:45 ` Olliver Schinagl
2022-07-29 8:04 ` Greg Kroah-Hartman
2022-07-28 20:43 ` Olliver Schinagl
2022-10-15 14:16 ` Olliver Schinagl
2022-10-16 1:44 ` Bagas Sanjaya
2022-10-16 1:50 ` Bagas Sanjaya
2022-10-16 13:23 ` Josh Triplett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YHc7pHjwmDJrkXqZ@archlinux-ax161 \
--to=nathan@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=ark.email@gmail.com \
--cc=geofft@ldpreload.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=me@kloenk.de \
--cc=msuchanek@suse.de \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=wedsonaf@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).