Skip to content

Commit 89d4757

Browse files
committed
rust: rename RUSTCFLAGS to RUSTFLAGS
Cargo uses `RUSTFLAGS` and `rustflags` while currently the name in Kbuild is `RUSTCFLAGS` and `rustcflags`. Rename the flags to be consistent with Rust ecosystem to reduce potential confusion in the future. Signed-off-by: Gary Guo <[email protected]>
1 parent 1b842c3 commit 89d4757

File tree

6 files changed

+47
-47
lines changed

6 files changed

+47
-47
lines changed

Documentation/kbuild/kbuild.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ CFLAGS_MODULE
5757
-------------
5858
Additional module specific options to use for $(CC).
5959

60-
KRUSTCFLAGS
60+
KRUSTFLAGS
6161
-----------
6262
Additional options to the Rust compiler (for built-in and modules).
6363

Makefile

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,11 @@ CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
488488
-Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
489489
NOSTDINC_FLAGS :=
490490
CFLAGS_MODULE =
491-
RUSTCFLAGS_MODULE =
491+
RUSTFLAGS_MODULE =
492492
AFLAGS_MODULE =
493493
LDFLAGS_MODULE =
494494
CFLAGS_KERNEL =
495-
RUSTCFLAGS_KERNEL =
495+
RUSTFLAGS_KERNEL =
496496
AFLAGS_KERNEL =
497497
LDFLAGS_vmlinux =
498498

@@ -521,8 +521,8 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
521521
-Werror=return-type -Wno-format-security \
522522
-std=gnu89
523523
KBUILD_CPPFLAGS := -D__KERNEL__
524-
KBUILD_RUSTC_TARGET := $(srctree)/arch/$(SRCARCH)/rust/target.json
525-
KBUILD_RUSTCFLAGS := --emit=dep-info,obj,metadata --edition=2018 \
524+
KBUILD_RUST_TARGET := $(srctree)/arch/$(SRCARCH)/rust/target.json
525+
KBUILD_RUSTFLAGS := --emit=dep-info,obj,metadata --edition=2018 \
526526
-Cpanic=abort -Cembed-bitcode=n -Clto=n -Crpath=n \
527527
-Cforce-unwind-tables=n -Ccodegen-units=1 \
528528
-Zbinary_dep_depinfo=y -Zsymbol-mangling-version=v0 \
@@ -532,10 +532,10 @@ KBUILD_CLIPPYFLAGS := -Dclippy::correctness -Dclippy::style \
532532
-Dclippy::complexity -Dclippy::perf
533533
KBUILD_AFLAGS_KERNEL :=
534534
KBUILD_CFLAGS_KERNEL :=
535-
KBUILD_RUSTCFLAGS_KERNEL :=
535+
KBUILD_RUSTFLAGS_KERNEL :=
536536
KBUILD_AFLAGS_MODULE := -DMODULE
537537
KBUILD_CFLAGS_MODULE := -DMODULE
538-
KBUILD_RUSTCFLAGS_MODULE := --cfg MODULE
538+
KBUILD_RUSTFLAGS_MODULE := --cfg MODULE
539539
KBUILD_LDFLAGS_MODULE :=
540540
KBUILD_LDFLAGS :=
541541
CLANG_FLAGS :=
@@ -563,10 +563,10 @@ export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
563563

564564
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
565565
export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
566-
export KBUILD_RUSTC_TARGET KBUILD_RUSTCFLAGS RUSTCFLAGS_KERNEL RUSTCFLAGS_MODULE
566+
export KBUILD_RUST_TARGET KBUILD_RUSTFLAGS RUSTFLAGS_KERNEL RUSTFLAGS_MODULE
567567
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
568-
export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_RUSTCFLAGS_MODULE KBUILD_LDFLAGS_MODULE
569-
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL KBUILD_RUSTCFLAGS_KERNEL
568+
export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_RUSTFLAGS_MODULE KBUILD_LDFLAGS_MODULE
569+
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL KBUILD_RUSTFLAGS_KERNEL
570570

571571
# Files to ignore in find ... statements
572572

@@ -793,42 +793,42 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
793793
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
794794

795795
ifdef CONFIG_RUST_DEBUG_ASSERTIONS
796-
KBUILD_RUSTCFLAGS += -Cdebug-assertions=y
796+
KBUILD_RUSTFLAGS += -Cdebug-assertions=y
797797
else
798-
KBUILD_RUSTCFLAGS += -Cdebug-assertions=n
798+
KBUILD_RUSTFLAGS += -Cdebug-assertions=n
799799
endif
800800

801801
ifdef CONFIG_RUST_OVERFLOW_CHECKS
802-
KBUILD_RUSTCFLAGS += -Coverflow-checks=y
802+
KBUILD_RUSTFLAGS += -Coverflow-checks=y
803803
else
804-
KBUILD_RUSTCFLAGS += -Coverflow-checks=n
804+
KBUILD_RUSTFLAGS += -Coverflow-checks=n
805805
endif
806806

807807
ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
808808
KBUILD_CFLAGS += -O2
809-
KBUILD_RUSTCFLAGS_OPT_LEVEL_MAP := 2
809+
KBUILD_RUSTFLAGS_OPT_LEVEL_MAP := 2
810810
else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
811811
KBUILD_CFLAGS += -O3
812-
KBUILD_RUSTCFLAGS_OPT_LEVEL_MAP := 3
812+
KBUILD_RUSTFLAGS_OPT_LEVEL_MAP := 3
813813
else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
814814
KBUILD_CFLAGS += -Os
815-
KBUILD_RUSTCFLAGS_OPT_LEVEL_MAP := z
815+
KBUILD_RUSTFLAGS_OPT_LEVEL_MAP := z
816816
endif
817817

818818
ifdef CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C
819-
KBUILD_RUSTCFLAGS += -Copt-level=$(KBUILD_RUSTCFLAGS_OPT_LEVEL_MAP)
819+
KBUILD_RUSTFLAGS += -Copt-level=$(KBUILD_RUSTFLAGS_OPT_LEVEL_MAP)
820820
else ifdef CONFIG_RUST_OPT_LEVEL_0
821-
KBUILD_RUSTCFLAGS += -Copt-level=0
821+
KBUILD_RUSTFLAGS += -Copt-level=0
822822
else ifdef CONFIG_RUST_OPT_LEVEL_1
823-
KBUILD_RUSTCFLAGS += -Copt-level=1
823+
KBUILD_RUSTFLAGS += -Copt-level=1
824824
else ifdef CONFIG_RUST_OPT_LEVEL_2
825-
KBUILD_RUSTCFLAGS += -Copt-level=2
825+
KBUILD_RUSTFLAGS += -Copt-level=2
826826
else ifdef CONFIG_RUST_OPT_LEVEL_3
827-
KBUILD_RUSTCFLAGS += -Copt-level=3
827+
KBUILD_RUSTFLAGS += -Copt-level=3
828828
else ifdef CONFIG_RUST_OPT_LEVEL_S
829-
KBUILD_RUSTCFLAGS += -Copt-level=s
829+
KBUILD_RUSTFLAGS += -Copt-level=s
830830
else ifdef CONFIG_RUST_OPT_LEVEL_Z
831-
KBUILD_RUSTCFLAGS += -Copt-level=z
831+
KBUILD_RUSTFLAGS += -Copt-level=z
832832
endif
833833

834834
# Tell gcc to never replace conditional load with a non-conditional one
@@ -878,7 +878,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
878878
KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
879879
ifdef CONFIG_FRAME_POINTER
880880
KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
881-
KBUILD_RUSTCFLAGS += -Cforce-frame-pointers=y
881+
KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
882882
else
883883
# Some targets (ARM with Thumb2, for example), can't be built with frame
884884
# pointers. For those, we don't have FUNCTION_TRACER automatically
@@ -916,7 +916,7 @@ ifdef CONFIG_CC_IS_GCC
916916
DEBUG_CFLAGS += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
917917
endif
918918

919-
DEBUG_RUSTCFLAGS :=
919+
DEBUG_RUSTFLAGS :=
920920

921921
ifdef CONFIG_DEBUG_INFO
922922

@@ -929,9 +929,9 @@ endif
929929
ifneq ($(LLVM_IAS),1)
930930
KBUILD_AFLAGS += -Wa,-gdwarf-2
931931
ifdef CONFIG_DEBUG_INFO_REDUCED
932-
DEBUG_RUSTCFLAGS += -Cdebuginfo=1
932+
DEBUG_RUSTFLAGS += -Cdebuginfo=1
933933
else
934-
DEBUG_RUSTCFLAGS += -Cdebuginfo=2
934+
DEBUG_RUSTFLAGS += -Cdebuginfo=2
935935
endif
936936
endif
937937

@@ -957,8 +957,8 @@ endif # CONFIG_DEBUG_INFO
957957
KBUILD_CFLAGS += $(DEBUG_CFLAGS)
958958
export DEBUG_CFLAGS
959959

960-
KBUILD_RUSTCFLAGS += $(DEBUG_RUSTCFLAGS)
961-
export DEBUG_RUSTCFLAGS
960+
KBUILD_RUSTFLAGS += $(DEBUG_RUSTFLAGS)
961+
export DEBUG_RUSTFLAGS
962962

963963
ifdef CONFIG_FUNCTION_TRACER
964964
ifdef CONFIG_FTRACE_MCOUNT_USE_CC
@@ -1115,11 +1115,11 @@ include $(addprefix $(srctree)/, $(include-y))
11151115
# Do not add $(call cc-option,...) below this line. When you build the kernel
11161116
# from the clean source tree, the GCC plugins do not exist at this point.
11171117

1118-
# Add user supplied CPPFLAGS, AFLAGS, CFLAGS and RUSTCFLAGS as the last assignments
1118+
# Add user supplied CPPFLAGS, AFLAGS, CFLAGS and RUSTFLAGS as the last assignments
11191119
KBUILD_CPPFLAGS += $(KCPPFLAGS)
11201120
KBUILD_AFLAGS += $(KAFLAGS)
11211121
KBUILD_CFLAGS += $(KCFLAGS)
1122-
KBUILD_RUSTCFLAGS += $(KRUSTCFLAGS)
1122+
KBUILD_RUSTFLAGS += $(KRUSTFLAGS)
11231123

11241124
KBUILD_LDFLAGS_MODULE += --build-id=sha1
11251125
LDFLAGS_vmlinux += --build-id=sha1

arch/riscv/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd
5454
riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c
5555
KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
5656
KBUILD_AFLAGS += -march=$(riscv-march-y)
57-
KBUILD_RUSTC_TARGET := $(srctree)/arch/riscv/rust/$(subst fd,,$(riscv-march-y)).json
57+
KBUILD_RUST_TARGET := $(srctree)/arch/riscv/rust/$(subst fd,,$(riscv-march-y)).json
5858

5959
KBUILD_CFLAGS += -mno-save-restore
6060
KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET)

rust/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ endif
3131
quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
3232
cmd_rustdoc = \
3333
RUST_BINDINGS_FILE=$(abspath $(objtree)/rust/bindings_generated.rs) \
34-
$(RUSTDOC) $(if $(rustdoc_host),,$(rustc_cross_flags)) \
34+
$(RUSTDOC) $(if $(rustdoc_host),,$(rust_cross_flags)) \
3535
$(filter-out -Cpanic=abort, $(filter-out --emit=%, $(rustc_flags))) \
3636
$(rustc_target_flags) -L $(objtree)/rust \
3737
--output $(objtree)/rust/doc --crate-name $(subst rustdoc-,,$@) \
@@ -267,7 +267,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
267267
cmd_rustc_library = \
268268
RUST_BINDINGS_FILE=$(abspath $(objtree)/rust/bindings_generated.rs) \
269269
$(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \
270-
$(rustc_flags) $(rustc_cross_flags) $(rustc_target_flags) \
270+
$(rustc_flags) $(rust_cross_flags) $(rustc_target_flags) \
271271
--crate-type rlib --out-dir $(objtree)/rust/ -L $(objtree)/rust/ \
272272
--crate-name $(patsubst %.o,%,$(notdir $@)) $<; \
273273
mv $(objtree)/rust/$(patsubst %.o,%,$(notdir $@)).d $(depfile); \

scripts/Makefile.build

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ EXTRA_CPPFLAGS :=
2626
EXTRA_LDFLAGS :=
2727
asflags-y :=
2828
ccflags-y :=
29-
rustcflags-y :=
29+
rustflags-y :=
3030
cppflags-y :=
3131
ldflags-y :=
3232

@@ -294,12 +294,12 @@ $(obj)/%.lst: $(src)/%.c FORCE
294294

295295
# Need to use absolute path here and have symbolic links resolved;
296296
# otherwise rustdoc and rustc compute different hashes for the target.
297-
rustc_cross_flags := --target=$(realpath $(KBUILD_RUSTC_TARGET))
297+
rust_cross_flags := --target=$(realpath $(KBUILD_RUST_TARGET))
298298

299299
quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
300300
cmd_rustc_o_rs = \
301301
RUST_MODFILE=$(modfile) \
302-
$(RUSTC_OR_CLIPPY) $(rustc_flags) $(rustc_cross_flags) \
302+
$(RUSTC_OR_CLIPPY) $(rustc_flags) $(rust_cross_flags) \
303303
-Zallow-features=allocator_api,bench_black_box,concat_idents,global_asm,try_reserve \
304304
--extern alloc --extern kernel \
305305
--crate-type rlib --out-dir $(obj) -L $(objtree)/rust/ \

scripts/Makefile.lib

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ldflags-y += $(EXTRA_LDFLAGS)
88
# flags that take effect in current and sub directories
99
KBUILD_AFLAGS += $(subdir-asflags-y)
1010
KBUILD_CFLAGS += $(subdir-ccflags-y)
11-
KBUILD_RUSTCFLAGS += $(subdir-rustcflags-y)
11+
KBUILD_RUSTFLAGS += $(subdir-rustflags-y)
1212

1313
# Figure out what we need to build from the various variables
1414
# ===========================================================================
@@ -134,10 +134,10 @@ _c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), \
134134
$(filter-out $(ccflags-remove-y), \
135135
$(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(ccflags-y)) \
136136
$(CFLAGS_$(target-stem).o))
137-
_rustc_flags = $(filter-out $(RUSTCFLAGS_REMOVE_$(target-stem).o), \
138-
$(filter-out $(rustcflags-remove-y), \
139-
$(KBUILD_RUSTCFLAGS) $(rustcflags-y)) \
140-
$(RUSTCFLAGS_$(target-stem).o))
137+
_rustc_flags = $(filter-out $(RUSTFLAGS_REMOVE_$(target-stem).o), \
138+
$(filter-out $(rustflags-remove-y), \
139+
$(KBUILD_RUSTFLAGS) $(rustflags-y)) \
140+
$(RUSTFLAGS_$(target-stem).o))
141141
_a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), \
142142
$(filter-out $(asflags-remove-y), \
143143
$(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(asflags-y)) \
@@ -207,10 +207,10 @@ modkern_cflags = \
207207
$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
208208
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags))
209209

210-
modkern_rustcflags = \
210+
modkern_rustflags = \
211211
$(if $(part-of-module), \
212-
$(KBUILD_RUSTCFLAGS_MODULE) $(RUSTCFLAGS_MODULE), \
213-
$(KBUILD_RUSTCFLAGS_KERNEL) $(RUSTCFLAGS_KERNEL))
212+
$(KBUILD_RUSTFLAGS_MODULE) $(RUSTFLAGS_MODULE), \
213+
$(KBUILD_RUSTFLAGS_KERNEL) $(RUSTFLAGS_KERNEL))
214214

215215
modkern_aflags = $(if $(part-of-module), \
216216
$(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \
@@ -221,7 +221,7 @@ c_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
221221
$(_c_flags) $(modkern_cflags) \
222222
$(basename_flags) $(modname_flags)
223223

224-
rustc_flags = $(_rustc_flags) $(modkern_rustcflags) @$(objtree)/include/generated/rustc_cfg
224+
rustc_flags = $(_rustc_flags) $(modkern_rustflags) @$(objtree)/include/generated/rustc_cfg
225225

226226
a_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
227227
$(_a_flags) $(modkern_aflags)

0 commit comments

Comments
 (0)