Message ID | 20231020155056.3495121-2-Jamie.Cunliffe@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Rust enablement for AArch64 | expand |
On Fri, Oct 20, 2023 at 04:50:55PM +0100, Jamie Cunliffe wrote: > Eventually we want all architectures to be using the target as defined > by rustc. However currently some architectures can't do that and are > using the target.json specification. This puts in place the foundation > to allow the use of the builtin target definition or a target.json > specification. > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > --- > Makefile | 1 - > arch/x86/Makefile | 1 + > rust/Makefile | 5 ++++- > scripts/Makefile | 4 +++- > 4 files changed, 8 insertions(+), 3 deletions(-) Adding the x86 maintainers - no functional change for x86, any objection to this patch going in via the arm64 tree (part of the two-patch series enabling Rust for arm64)? Thanks. (keeping the rest of the patch below for your reference) > diff --git a/Makefile b/Makefile > index 88ebf6547964..23100f193da3 100644 > --- a/Makefile > +++ b/Makefile > @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing > > KBUILD_CPPFLAGS := -D__KERNEL__ > KBUILD_RUSTFLAGS := $(rust_common_flags) \ > - --target=$(objtree)/scripts/target.json \ > -Cpanic=abort -Cembed-bitcode=n -Clto=n \ > -Cforce-unwind-tables=n -Ccodegen-units=1 \ > -Csymbol-mangling-version=v0 \ > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > index 5bfe5caaa444..0f339d4abd40 100644 > --- a/arch/x86/Makefile > +++ b/arch/x86/Makefile > @@ -68,6 +68,7 @@ export BITS > # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 > # > KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx > +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json > KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 > > ifeq ($(CONFIG_X86_KERNEL_IBT),y) > diff --git a/rust/Makefile b/rust/Makefile > index 87958e864be0..8d75a6ffe951 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 > $(obj)/core.o: private skip_flags = -Dunreachable_pub > $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) > $(obj)/core.o: private rustc_target_flags = $(core-cfgs) > -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE > +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE > $(call if_changed_dep,rustc_library) > +ifdef CONFIG_X86_64 > +$(obj)/core.o: scripts/target.json > +endif > > $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' > $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE > diff --git a/scripts/Makefile b/scripts/Makefile > index 576cf64be667..c85d130a4125 100644 > --- a/scripts/Makefile > +++ b/scripts/Makefile > @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file > hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen > -always-$(CONFIG_RUST) += target.json > > +ifdef CONFIG_X86_64 > +always-$(CONFIG_RUST) += target.json > filechk_rust_target = $< < include/config/auto.conf > > $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE > $(call filechk,rust_target) > +endif > > hostprogs += generate_rust_target > generate_rust_target-rust := y > -- > 2.30.2
* Catalin Marinas <catalin.marinas@arm.com> wrote: > On Fri, Oct 20, 2023 at 04:50:55PM +0100, Jamie Cunliffe wrote: > > Eventually we want all architectures to be using the target as defined > > by rustc. However currently some architectures can't do that and are > > using the target.json specification. This puts in place the foundation > > to allow the use of the builtin target definition or a target.json > > specification. > > > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > > --- > > Makefile | 1 - > > arch/x86/Makefile | 1 + > > rust/Makefile | 5 ++++- > > scripts/Makefile | 4 +++- > > 4 files changed, 8 insertions(+), 3 deletions(-) > > Adding the x86 maintainers - no functional change for x86, any objection > to this patch going in via the arm64 tree (part of the two-patch series > enabling Rust for arm64)? > > Thanks. > > (keeping the rest of the patch below for your reference) If Masahiro Yamada (kbuild maintainer, Cc:-ed) is fine with it, then it will be OK to me too. Thanks, Ingo
On Sun, Oct 22, 2023 at 7:14 AM Ingo Molnar <mingo@kernel.org> wrote: > > > * Catalin Marinas <catalin.marinas@arm.com> wrote: > > > > Adding the x86 maintainers - no functional change for x86, any objection > > to this patch going in via the arm64 tree (part of the two-patch series > > enabling Rust for arm64)? > > > > Thanks. > > > > (keeping the rest of the patch below for your reference) > > If Masahiro Yamada (kbuild maintainer, Cc:-ed) is fine with it, > then it will be OK to me too. > > Thanks, > > Ingo > I don't think this has been picked up yet. Is it only waiting on Masahiro 's ack or is a new version expected? - Trevor
On Mon, Oct 30, 2023 at 08:24:39PM -0400, Trevor Gross wrote: > On Sun, Oct 22, 2023 at 7:14 AM Ingo Molnar <mingo@kernel.org> wrote: > > * Catalin Marinas <catalin.marinas@arm.com> wrote: > > > Adding the x86 maintainers - no functional change for x86, any objection > > > to this patch going in via the arm64 tree (part of the two-patch series > > > enabling Rust for arm64)? > > > > > > Thanks. > > > > > > (keeping the rest of the patch below for your reference) > > > > If Masahiro Yamada (kbuild maintainer, Cc:-ed) is fine with it, > > then it will be OK to me too. [...] > I don't think this has been picked up yet. Is it only waiting on > Masahiro 's ack or is a new version expected? I'd say Masahiro's ack only. However, it's probably too late for 6.7 now, the merging window is already open and maintainers tend to pick stuff up in the weeks before.
On Tue, Oct 31, 2023 at 7:58 AM Catalin Marinas <catalin.marinas@arm.com> wrote: > I'd say Masahiro's ack only. However, it's probably too late for 6.7 > now, the merging window is already open and maintainers tend to pick > stuff up in the weeks before. Right, thanks for confirming. I was unsure whether the BE discussion changed anything, but that could likely come separately. - Trevor
On Tue, Oct 31, 2023 at 11:58:03AM +0000, Catalin Marinas wrote: > On Mon, Oct 30, 2023 at 08:24:39PM -0400, Trevor Gross wrote: > > On Sun, Oct 22, 2023 at 7:14 AM Ingo Molnar <mingo@kernel.org> wrote: > > > * Catalin Marinas <catalin.marinas@arm.com> wrote: > > > > Adding the x86 maintainers - no functional change for x86, any objection > > > > to this patch going in via the arm64 tree (part of the two-patch series > > > > enabling Rust for arm64)? > > > > > > > > Thanks. > > > > > > > > (keeping the rest of the patch below for your reference) > > > > > > If Masahiro Yamada (kbuild maintainer, Cc:-ed) is fine with it, > > > then it will be OK to me too. > [...] > > I don't think this has been picked up yet. Is it only waiting on > > Masahiro 's ack or is a new version expected? > > I'd say Masahiro's ack only. However, it's probably too late for 6.7 > now, the merging window is already open and maintainers tend to pick > stuff up in the weeks before. Masahiro -- please can we have your Ack on this so that we can take it via the arm64 tree? Thanks, Will
On Fri, Oct 20, 2023 at 10:59 AM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote: > > Eventually we want all architectures to be using the target as defined > by rustc. However currently some architectures can't do that and are > using the target.json specification. This puts in place the foundation > to allow the use of the builtin target definition or a target.json > specification. > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > --- > Makefile | 1 - > arch/x86/Makefile | 1 + > rust/Makefile | 5 ++++- > scripts/Makefile | 4 +++- > 4 files changed, 8 insertions(+), 3 deletions(-) Adding LoongArch maintainers - this patch will need a small update to arch/loongarch/Makefile similar to the change in arch/x86/Makefile (included below), since that support is now in-tree and uses generate_rust_target [1]. Also a very minor conflict in docs at patch 2/2. I believe this patchset is still waiting on an ack from the kbuild team. Series at [2] for reference. Thanks, Trevor [1]: https://lore.kernel.org/rust-for-linux/20240108032117.215171-1-wangrui@loongson.cn/ [2]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ > diff --git a/Makefile b/Makefile > index 88ebf6547964..23100f193da3 100644 > --- a/Makefile > +++ b/Makefile > @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing > > KBUILD_CPPFLAGS := -D__KERNEL__ > KBUILD_RUSTFLAGS := $(rust_common_flags) \ > - --target=$(objtree)/scripts/target.json \ > -Cpanic=abort -Cembed-bitcode=n -Clto=n \ > -Cforce-unwind-tables=n -Ccodegen-units=1 \ > -Csymbol-mangling-version=v0 \ > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > index 5bfe5caaa444..0f339d4abd40 100644 > --- a/arch/x86/Makefile > +++ b/arch/x86/Makefile > @@ -68,6 +68,7 @@ export BITS > # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 > # > KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx > +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json > KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 > > ifeq ($(CONFIG_X86_KERNEL_IBT),y) > diff --git a/rust/Makefile b/rust/Makefile > index 87958e864be0..8d75a6ffe951 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 > $(obj)/core.o: private skip_flags = -Dunreachable_pub > $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) > $(obj)/core.o: private rustc_target_flags = $(core-cfgs) > -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE > +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE > $(call if_changed_dep,rustc_library) > +ifdef CONFIG_X86_64 > +$(obj)/core.o: scripts/target.json > +endif > > $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' > $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE > diff --git a/scripts/Makefile b/scripts/Makefile > index 576cf64be667..c85d130a4125 100644 > --- a/scripts/Makefile > +++ b/scripts/Makefile > @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file > hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen > -always-$(CONFIG_RUST) += target.json > > +ifdef CONFIG_X86_64 > +always-$(CONFIG_RUST) += target.json > filechk_rust_target = $< < include/config/auto.conf > > $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE > $(call filechk,rust_target) > +endif > > hostprogs += generate_rust_target > generate_rust_target-rust := y > -- > 2.30.2 > >
Jamie Cunliffe <Jamie.Cunliffe@arm.com> writes: > Eventually we want all architectures to be using the target as defined > by rustc. However currently some architectures can't do that and are > using the target.json specification. This puts in place the foundation > to allow the use of the builtin target definition or a target.json > specification. > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> Tested with Rust Binder. Tested-by: Alice Ryhl <aliceryhl@google.com>
On Sat, Oct 21, 2023 at 12:53 AM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote: > > Eventually we want all architectures to be using the target as defined > by rustc. However currently some architectures can't do that and are > using the target.json specification. This puts in place the foundation > to allow the use of the builtin target definition or a target.json > specification. > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > --- > Makefile | 1 - > arch/x86/Makefile | 1 + > rust/Makefile | 5 ++++- > scripts/Makefile | 4 +++- > 4 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/Makefile b/Makefile > index 88ebf6547964..23100f193da3 100644 > --- a/Makefile > +++ b/Makefile > @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing > > KBUILD_CPPFLAGS := -D__KERNEL__ > KBUILD_RUSTFLAGS := $(rust_common_flags) \ > - --target=$(objtree)/scripts/target.json \ > -Cpanic=abort -Cembed-bitcode=n -Clto=n \ > -Cforce-unwind-tables=n -Ccodegen-units=1 \ > -Csymbol-mangling-version=v0 \ > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > index 5bfe5caaa444..0f339d4abd40 100644 > --- a/arch/x86/Makefile > +++ b/arch/x86/Makefile > @@ -68,6 +68,7 @@ export BITS > # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 > # > KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx > +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json > KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 > > ifeq ($(CONFIG_X86_KERNEL_IBT),y) > diff --git a/rust/Makefile b/rust/Makefile > index 87958e864be0..8d75a6ffe951 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 > $(obj)/core.o: private skip_flags = -Dunreachable_pub > $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) > $(obj)/core.o: private rustc_target_flags = $(core-cfgs) > -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE > +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE > $(call if_changed_dep,rustc_library) > +ifdef CONFIG_X86_64 > +$(obj)/core.o: scripts/target.json > +endif > > $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' > $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE > diff --git a/scripts/Makefile b/scripts/Makefile > index 576cf64be667..c85d130a4125 100644 > --- a/scripts/Makefile > +++ b/scripts/Makefile > @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file > hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen > -always-$(CONFIG_RUST) += target.json > > +ifdef CONFIG_X86_64 Sorry for the delay. I did not notice that this was waiting for my Ack. Now, Rust for loongarch is upstreamed, and it also uses the custom target. This block should be changed to: ifneq ($(CONFIG_X86_64)$(CONFIG_LOONGARCH),) ... endif With that changed, Acked-by: Masahiro Yamada <masahiroy@kernel.org> Or, if you want to make it a little bit cleaner, perhaps you can introduce a new CONFIG option. Let's say CONFIG_RUST_USE_CUSTOM_TARGET (please pick up any option name you like). In scripts/Makefile, -always-$(CONFIG_RUST) += target.json +always-$(CONFIG_RUST_USE_CUSTOM_TARGET) += target.json In the top Makefile, ifdef CONFIG_RUST_USE_CUSTOM_TARGET KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json endif > +always-$(CONFIG_RUST) += target.json > filechk_rust_target = $< < include/config/auto.conf > > $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE > $(call filechk,rust_target) > +endif > > hostprogs += generate_rust_target > generate_rust_target-rust := y > -- > 2.30.2 > >
Hello, On Mon, Jan 22, 2024 at 5:17 PM Trevor Gross <tmgross@umich.edu> wrote: > > On Fri, Oct 20, 2023 at 10:59 AM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote: > > > > Eventually we want all architectures to be using the target as defined > > by rustc. However currently some architectures can't do that and are > > using the target.json specification. This puts in place the foundation > > to allow the use of the builtin target definition or a target.json > > specification. > > > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > > --- > > Makefile | 1 - > > arch/x86/Makefile | 1 + > > rust/Makefile | 5 ++++- > > scripts/Makefile | 4 +++- > > 4 files changed, 8 insertions(+), 3 deletions(-) > > Adding LoongArch maintainers - this patch will need a small update to > arch/loongarch/Makefile similar to the change in arch/x86/Makefile > (included below), since that support is now in-tree and uses > generate_rust_target [1]. Also a very minor conflict in docs at patch > 2/2. > > I believe this patchset is still waiting on an ack from the kbuild > team. Series at [2] for reference. > > Thanks, > Trevor > > [1]: https://lore.kernel.org/rust-for-linux/20240108032117.215171-1-wangrui@loongson.cn/ > [2]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ I can confirm that the fix patch [2], based on patch [1], is suitable for LoongArch. LoongArch encounters no issues when using the built-in `loongarch64-unknown-none-softfloat` target. Once patch [1] is merged into the mainline, I'll send a patch to switch to using the built-in target. Thanks, Rui [1]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ [2]: https://github.com/heiher/linux/commit/c504d83a6edd963e2ba58ec538e3f06da78b187e.patch > > > diff --git a/Makefile b/Makefile > > index 88ebf6547964..23100f193da3 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing > > > > KBUILD_CPPFLAGS := -D__KERNEL__ > > KBUILD_RUSTFLAGS := $(rust_common_flags) \ > > - --target=$(objtree)/scripts/target.json \ > > -Cpanic=abort -Cembed-bitcode=n -Clto=n \ > > -Cforce-unwind-tables=n -Ccodegen-units=1 \ > > -Csymbol-mangling-version=v0 \ > > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > > index 5bfe5caaa444..0f339d4abd40 100644 > > --- a/arch/x86/Makefile > > +++ b/arch/x86/Makefile > > @@ -68,6 +68,7 @@ export BITS > > # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 > > # > > KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx > > +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json > > KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 > > > > ifeq ($(CONFIG_X86_KERNEL_IBT),y) > > diff --git a/rust/Makefile b/rust/Makefile > > index 87958e864be0..8d75a6ffe951 100644 > > --- a/rust/Makefile > > +++ b/rust/Makefile > > @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 > > $(obj)/core.o: private skip_flags = -Dunreachable_pub > > $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) > > $(obj)/core.o: private rustc_target_flags = $(core-cfgs) > > -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE > > +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE > > $(call if_changed_dep,rustc_library) > > +ifdef CONFIG_X86_64 > > +$(obj)/core.o: scripts/target.json > > +endif > > > > $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' > > $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE > > diff --git a/scripts/Makefile b/scripts/Makefile > > index 576cf64be667..c85d130a4125 100644 > > --- a/scripts/Makefile > > +++ b/scripts/Makefile > > @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file > > hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert > > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder > > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen > > -always-$(CONFIG_RUST) += target.json > > > > +ifdef CONFIG_X86_64 > > +always-$(CONFIG_RUST) += target.json > > filechk_rust_target = $< < include/config/auto.conf > > > > $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE > > $(call filechk,rust_target) > > +endif > > > > hostprogs += generate_rust_target > > generate_rust_target-rust := y > > -- > > 2.30.2 > > > > >
On Thu, Jan 25, 2024 at 12:20 PM WANG Rui <wangrui@loongson.cn> wrote: > > Hello, > > On Mon, Jan 22, 2024 at 5:17 PM Trevor Gross <tmgross@umich.edu> wrote: > > > > On Fri, Oct 20, 2023 at 10:59 AM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote: > > > > > > Eventually we want all architectures to be using the target as defined > > > by rustc. However currently some architectures can't do that and are > > > using the target.json specification. This puts in place the foundation > > > to allow the use of the builtin target definition or a target.json > > > specification. > > > > > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > > > --- > > > Makefile | 1 - > > > arch/x86/Makefile | 1 + > > > rust/Makefile | 5 ++++- > > > scripts/Makefile | 4 +++- > > > 4 files changed, 8 insertions(+), 3 deletions(-) > > > > Adding LoongArch maintainers - this patch will need a small update to > > arch/loongarch/Makefile similar to the change in arch/x86/Makefile > > (included below), since that support is now in-tree and uses > > generate_rust_target [1]. Also a very minor conflict in docs at patch > > 2/2. > > > > I believe this patchset is still waiting on an ack from the kbuild > > team. Series at [2] for reference. > > > > Thanks, > > Trevor > > > > [1]: https://lore.kernel.org/rust-for-linux/20240108032117.215171-1-wangrui@loongson.cn/ > > [2]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ > > I can confirm that the fix patch [2], based on patch [1], is suitable > for LoongArch. LoongArch encounters no issues when using the built-in > `loongarch64-unknown-none-softfloat` target. Once patch [1] is merged > into the mainline, I'll send a patch to switch to using the built-in > target. But, [1] and [2] must be squashed together. Otherwise, [1] is changing the behavior of loongach, while the commit description does not mention it. > Thanks, > Rui > > [1]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ > [2]: https://github.com/heiher/linux/commit/c504d83a6edd963e2ba58ec538e3f06da78b187e.patch > > > > > > diff --git a/Makefile b/Makefile > > > index 88ebf6547964..23100f193da3 100644 > > > --- a/Makefile > > > +++ b/Makefile > > > @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing > > > > > > KBUILD_CPPFLAGS := -D__KERNEL__ > > > KBUILD_RUSTFLAGS := $(rust_common_flags) \ > > > - --target=$(objtree)/scripts/target.json \ > > > -Cpanic=abort -Cembed-bitcode=n -Clto=n \ > > > -Cforce-unwind-tables=n -Ccodegen-units=1 \ > > > -Csymbol-mangling-version=v0 \ > > > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > > > index 5bfe5caaa444..0f339d4abd40 100644 > > > --- a/arch/x86/Makefile > > > +++ b/arch/x86/Makefile > > > @@ -68,6 +68,7 @@ export BITS > > > # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 > > > # > > > KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx > > > +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json > > > KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 > > > > > > ifeq ($(CONFIG_X86_KERNEL_IBT),y) > > > diff --git a/rust/Makefile b/rust/Makefile > > > index 87958e864be0..8d75a6ffe951 100644 > > > --- a/rust/Makefile > > > +++ b/rust/Makefile > > > @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 > > > $(obj)/core.o: private skip_flags = -Dunreachable_pub > > > $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) > > > $(obj)/core.o: private rustc_target_flags = $(core-cfgs) > > > -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE > > > +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE > > > $(call if_changed_dep,rustc_library) > > > +ifdef CONFIG_X86_64 > > > +$(obj)/core.o: scripts/target.json > > > +endif > > > > > > $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' > > > $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE > > > diff --git a/scripts/Makefile b/scripts/Makefile > > > index 576cf64be667..c85d130a4125 100644 > > > --- a/scripts/Makefile > > > +++ b/scripts/Makefile > > > @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file > > > hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert > > > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder > > > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen > > > -always-$(CONFIG_RUST) += target.json > > > > > > +ifdef CONFIG_X86_64 > > > +always-$(CONFIG_RUST) += target.json > > > filechk_rust_target = $< < include/config/auto.conf > > > > > > $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE > > > $(call filechk,rust_target) > > > +endif > > > > > > hostprogs += generate_rust_target > > > generate_rust_target-rust := y > > > -- > > > 2.30.2 > > > > > > > > > >
On Sat, Jan 27, 2024 at 3:38 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > On Thu, Jan 25, 2024 at 12:20 PM WANG Rui <wangrui@loongson.cn> wrote: > > > > Hello, > > > > On Mon, Jan 22, 2024 at 5:17 PM Trevor Gross <tmgross@umich.edu> wrote: > > > > > > On Fri, Oct 20, 2023 at 10:59 AM Jamie Cunliffe <Jamie.Cunliffe@arm.com> wrote: > > > > > > > > Eventually we want all architectures to be using the target as defined > > > > by rustc. However currently some architectures can't do that and are > > > > using the target.json specification. This puts in place the foundation > > > > to allow the use of the builtin target definition or a target.json > > > > specification. > > > > > > > > Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> > > > > --- > > > > Makefile | 1 - > > > > arch/x86/Makefile | 1 + > > > > rust/Makefile | 5 ++++- > > > > scripts/Makefile | 4 +++- > > > > 4 files changed, 8 insertions(+), 3 deletions(-) > > > > > > Adding LoongArch maintainers - this patch will need a small update to > > > arch/loongarch/Makefile similar to the change in arch/x86/Makefile > > > (included below), since that support is now in-tree and uses > > > generate_rust_target [1]. Also a very minor conflict in docs at patch > > > 2/2. > > > > > > I believe this patchset is still waiting on an ack from the kbuild > > > team. Series at [2] for reference. > > > > > > Thanks, > > > Trevor > > > > > > [1]: https://lore.kernel.org/rust-for-linux/20240108032117.215171-1-wangrui@loongson.cn/ > > > [2]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ > > > > I can confirm that the fix patch [2], based on patch [1], is suitable > > for LoongArch. LoongArch encounters no issues when using the built-in > > `loongarch64-unknown-none-softfloat` target. Once patch [1] is merged > > into the mainline, I'll send a patch to switch to using the built-in > > target. > > But, [1] and [2] must be squashed together. > Otherwise, [1] is changing the behavior of loongach, > while the commit description does not mention it. I agree. It would be great if Jamie could squash them together. Thanks, Rui > > > > > > Thanks, > > Rui > > > > [1]: https://lore.kernel.org/rust-for-linux/20231020155056.3495121-1-Jamie.Cunliffe@arm.com/ > > [2]: https://github.com/heiher/linux/commit/c504d83a6edd963e2ba58ec538e3f06da78b187e.patch > > > > > > > > > diff --git a/Makefile b/Makefile > > > > index 88ebf6547964..23100f193da3 100644 > > > > --- a/Makefile > > > > +++ b/Makefile > > > > @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing > > > > > > > > KBUILD_CPPFLAGS := -D__KERNEL__ > > > > KBUILD_RUSTFLAGS := $(rust_common_flags) \ > > > > - --target=$(objtree)/scripts/target.json \ > > > > -Cpanic=abort -Cembed-bitcode=n -Clto=n \ > > > > -Cforce-unwind-tables=n -Ccodegen-units=1 \ > > > > -Csymbol-mangling-version=v0 \ > > > > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > > > > index 5bfe5caaa444..0f339d4abd40 100644 > > > > --- a/arch/x86/Makefile > > > > +++ b/arch/x86/Makefile > > > > @@ -68,6 +68,7 @@ export BITS > > > > # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 > > > > # > > > > KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx > > > > +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json > > > > KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 > > > > > > > > ifeq ($(CONFIG_X86_KERNEL_IBT),y) > > > > diff --git a/rust/Makefile b/rust/Makefile > > > > index 87958e864be0..8d75a6ffe951 100644 > > > > --- a/rust/Makefile > > > > +++ b/rust/Makefile > > > > @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 > > > > $(obj)/core.o: private skip_flags = -Dunreachable_pub > > > > $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) > > > > $(obj)/core.o: private rustc_target_flags = $(core-cfgs) > > > > -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE > > > > +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE > > > > $(call if_changed_dep,rustc_library) > > > > +ifdef CONFIG_X86_64 > > > > +$(obj)/core.o: scripts/target.json > > > > +endif > > > > > > > > $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' > > > > $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE > > > > diff --git a/scripts/Makefile b/scripts/Makefile > > > > index 576cf64be667..c85d130a4125 100644 > > > > --- a/scripts/Makefile > > > > +++ b/scripts/Makefile > > > > @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file > > > > hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert > > > > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder > > > > hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen > > > > -always-$(CONFIG_RUST) += target.json > > > > > > > > +ifdef CONFIG_X86_64 > > > > +always-$(CONFIG_RUST) += target.json > > > > filechk_rust_target = $< < include/config/auto.conf > > > > > > > > $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE > > > > $(call filechk,rust_target) > > > > +endif > > > > > > > > hostprogs += generate_rust_target > > > > generate_rust_target-rust := y > > > > -- > > > > 2.30.2 > > > > > > > > > > > > > > > > > > -- > Best Regards > Masahiro Yamada >
On Sat, Jan 27, 2024 at 6:08 AM WANG Rui <wangrui@loongson.cn> wrote: > > I agree. It would be great if Jamie could squash them together. Either that or perhaps Catalin could do it at apply time with your Co-developed-by and/or Huacai's Acked-by? I could also take if needed. Thanks Masahiro & Rui! Cheers, Miguel
diff --git a/Makefile b/Makefile index 88ebf6547964..23100f193da3 100644 --- a/Makefile +++ b/Makefile @@ -566,7 +566,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_RUSTFLAGS := $(rust_common_flags) \ - --target=$(objtree)/scripts/target.json \ -Cpanic=abort -Cembed-bitcode=n -Clto=n \ -Cforce-unwind-tables=n -Ccodegen-units=1 \ -Csymbol-mangling-version=v0 \ diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 5bfe5caaa444..0f339d4abd40 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -68,6 +68,7 @@ export BITS # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 # KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx +KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 ifeq ($(CONFIG_X86_KERNEL_IBT),y) diff --git a/rust/Makefile b/rust/Makefile index 87958e864be0..8d75a6ffe951 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -428,8 +428,11 @@ $(obj)/core.o: private skip_clippy = 1 $(obj)/core.o: private skip_flags = -Dunreachable_pub $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) $(obj)/core.o: private rustc_target_flags = $(core-cfgs) -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE $(call if_changed_dep,rustc_library) +ifdef CONFIG_X86_64 +$(obj)/core.o: scripts/target.json +endif $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE diff --git a/scripts/Makefile b/scripts/Makefile index 576cf64be667..c85d130a4125 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen -always-$(CONFIG_RUST) += target.json +ifdef CONFIG_X86_64 +always-$(CONFIG_RUST) += target.json filechk_rust_target = $< < include/config/auto.conf $(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE $(call filechk,rust_target) +endif hostprogs += generate_rust_target generate_rust_target-rust := y
Eventually we want all architectures to be using the target as defined by rustc. However currently some architectures can't do that and are using the target.json specification. This puts in place the foundation to allow the use of the builtin target definition or a target.json specification. Signed-off-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com> --- Makefile | 1 - arch/x86/Makefile | 1 + rust/Makefile | 5 ++++- scripts/Makefile | 4 +++- 4 files changed, 8 insertions(+), 3 deletions(-)