Skip to content

Commit 9c7c6e9

Browse files
JamieCunliffefbq
authored andcommitted
rust: Refactor the build target to allow the use of builtin targets
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1b8c8bd commit 9c7c6e9

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ KBUILD_CFLAGS += -fno-strict-aliasing
555555

556556
KBUILD_CPPFLAGS := -D__KERNEL__
557557
KBUILD_RUSTFLAGS := $(rust_common_flags) \
558-
--target=$(objtree)/scripts/target.json \
559558
-Cpanic=abort -Cembed-bitcode=n -Clto=n \
560559
-Cforce-unwind-tables=n -Ccodegen-units=1 \
561560
-Csymbol-mangling-version=v0 \

arch/x86/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export BITS
6868
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
6969
#
7070
KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
71+
KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json
7172
KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
7273

7374
ifeq ($(CONFIG_X86_KERNEL_IBT),y)

rust/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,11 @@ $(obj)/core.o: private skip_clippy = 1
433433
$(obj)/core.o: private skip_flags = -Dunreachable_pub
434434
$(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
435435
$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
436-
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE
436+
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE
437437
$(call if_changed_dep,rustc_library)
438+
ifdef CONFIG_X86_64
439+
$(obj)/core.o: scripts/target.json
440+
endif
438441

439442
$(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*'
440443
$(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE

scripts/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file
1111
hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
1212
hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder
1313
hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen
14-
always-$(CONFIG_RUST) += target.json
1514

15+
ifdef CONFIG_X86_64
16+
always-$(CONFIG_RUST) += target.json
1617
filechk_rust_target = $< < include/config/auto.conf
1718

1819
$(obj)/target.json: scripts/generate_rust_target include/config/auto.conf FORCE
1920
$(call filechk,rust_target)
21+
endif
2022

2123
hostprogs += generate_rust_target
2224
generate_rust_target-rust := y

0 commit comments

Comments
 (0)