Skip to content

Commit 6e5948e

Browse files
committed
fixup! BCM2708: Add core Device Tree support
1 parent e697a3b commit 6e5948e

File tree

8 files changed

+308
-195
lines changed

8 files changed

+308
-195
lines changed

scripts/Makefile.btf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ else
2323
# Switch to using --btf_features for v1.26 and later.
2424
pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j$(JOBS) --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs
2525

26-
pahole-flags-$(call test-ge, $(pahole-ver), 130) += --btf_features=attributes
27-
2826
ifneq ($(KBUILD_EXTMOD),)
2927
module-pahole-flags-$(call test-ge, $(pahole-ver), 128) += --btf_features=distilled_base
3028
endif

scripts/Makefile.build

Lines changed: 34 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -37,88 +37,18 @@ include $(srctree)/scripts/Makefile.compiler
3737
include $(kbuild-file)
3838
include $(srctree)/scripts/Makefile.lib
3939

40-
# flags that take effect in current and sub directories
41-
KBUILD_AFLAGS += $(subdir-asflags-y)
42-
KBUILD_CFLAGS += $(subdir-ccflags-y)
43-
KBUILD_RUSTFLAGS += $(subdir-rustflags-y)
44-
45-
# Figure out what we need to build from the various variables
46-
# ===========================================================================
47-
48-
# When an object is listed to be built compiled-in and modular,
49-
# only build the compiled-in version
50-
obj-m := $(filter-out $(obj-y),$(obj-m))
51-
52-
# Libraries are always collected in one lib file.
53-
# Filter out objects already built-in
54-
lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
55-
56-
# Subdirectories we need to descend into
57-
subdir-ym := $(sort $(subdir-y) $(subdir-m) \
58-
$(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m))))
59-
60-
# Handle objects in subdirs:
61-
# - If we encounter foo/ in $(obj-y), replace it by foo/built-in.a and
62-
# foo/modules.order
63-
# - If we encounter foo/ in $(obj-m), replace it by foo/modules.order
64-
#
65-
# Generate modules.order to determine modorder. Unfortunately, we don't have
66-
# information about ordering between -y and -m subdirs. Just put -y's first.
67-
68-
ifdef need-modorder
69-
obj-m := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m))
70-
else
71-
obj-m := $(filter-out %/, $(obj-m))
72-
endif
73-
74-
ifdef need-builtin
75-
obj-y := $(patsubst %/, %/built-in.a, $(obj-y))
76-
else
77-
obj-y := $(filter-out %/, $(obj-y))
40+
# Do not include hostprogs rules unless needed.
41+
# $(sort ...) is used here to remove duplicated words and excessive spaces.
42+
hostprogs := $(sort $(hostprogs))
43+
ifneq ($(hostprogs),)
44+
include $(srctree)/scripts/Makefile.host
7845
endif
7946

80-
# Expand $(foo-objs) $(foo-y) etc. by replacing their individuals
81-
suffix-search = $(strip $(foreach s, $3, $($(1:%$(strip $2)=%$s))))
82-
# List composite targets that are constructed by combining other targets
83-
multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $m)))
84-
# List primitive targets that are compiled from source files
85-
real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $(call suffix-search, $m, $2, $3), $m))
86-
87-
# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
88-
multi-obj-y := $(call multi-search, $(obj-y), .o, -objs -y)
89-
multi-obj-m := $(call multi-search, $(obj-m), .o, -objs -y -m)
90-
multi-obj-ym := $(multi-obj-y) $(multi-obj-m)
91-
92-
# Replace multi-part objects by their individual parts,
93-
# including built-in.a from subdirectories
94-
real-obj-y := $(call real-search, $(obj-y), .o, -objs -y)
95-
real-obj-m := $(call real-search, $(obj-m), .o, -objs -y -m)
96-
97-
always-y += $(always-m)
98-
99-
# hostprogs-always-y += foo
100-
# ... is a shorthand for
101-
# hostprogs += foo
102-
# always-y += foo
103-
hostprogs += $(hostprogs-always-y) $(hostprogs-always-m)
104-
always-y += $(hostprogs-always-y) $(hostprogs-always-m)
105-
106-
# userprogs-always-y is likewise.
107-
userprogs += $(userprogs-always-y) $(userprogs-always-m)
108-
always-y += $(userprogs-always-y) $(userprogs-always-m)
109-
110-
# Add subdir path
111-
112-
ifneq ($(obj),.)
113-
extra-y := $(addprefix $(obj)/, $(extra-y))
114-
always-y := $(addprefix $(obj)/, $(always-y))
115-
targets := $(addprefix $(obj)/, $(targets))
116-
obj-m := $(addprefix $(obj)/, $(obj-m))
117-
lib-y := $(addprefix $(obj)/, $(lib-y))
118-
real-obj-y := $(addprefix $(obj)/, $(real-obj-y))
119-
real-obj-m := $(addprefix $(obj)/, $(real-obj-m))
120-
multi-obj-m := $(addprefix $(obj)/, $(multi-obj-m))
121-
subdir-ym := $(addprefix $(obj)/, $(subdir-ym))
47+
# Do not include userprogs rules unless needed.
48+
# $(sort ...) is used here to remove duplicated words and excessive spaces.
49+
userprogs := $(sort $(userprogs))
50+
ifneq ($(userprogs),)
51+
include $(srctree)/scripts/Makefile.userprogs
12252
endif
12353

12454
ifndef obj
@@ -137,6 +67,7 @@ endif
13767
# subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
13868
subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
13969
subdir-modorder := $(sort $(filter %/modules.order, $(obj-m)))
70+
subdir-dtbslist := $(sort $(filter %/dtbs-list, $(dtb-y)))
14071

14172
targets-for-builtin := $(extra-y)
14273

@@ -167,7 +98,7 @@ else ifeq ($(KBUILD_CHECKSRC),2)
16798
endif
16899

169100
ifneq ($(KBUILD_EXTRA_WARN),)
170-
cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(KDOCFLAGS) \
101+
cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $(KDOCFLAGS) \
171102
$(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \
172103
$<
173104
endif
@@ -306,15 +237,6 @@ $(obj)/%.lst: $(obj)/%.c FORCE
306237
# Compile Rust sources (.rs)
307238
# ---------------------------------------------------------------------------
308239

309-
# The features in this list are the ones allowed for non-`rust/` code.
310-
#
311-
# - Stable since Rust 1.81.0: `feature(lint_reasons)`.
312-
# - Stable since Rust 1.82.0: `feature(asm_const)`, `feature(raw_ref_op)`.
313-
# - Stable since Rust 1.87.0: `feature(asm_goto)`.
314-
# - Expected to become stable: `feature(arbitrary_self_types)`.
315-
#
316-
# Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on
317-
# the unstable features in use.
318240
rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,raw_ref_op
319241

320242
# `--out-dir` is required to avoid temporaries being created by `rustc` in the
@@ -341,15 +263,10 @@ rust_common_cmd = \
341263
# would not match each other.
342264

343265
quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
344-
cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $< $(cmd_objtool)
345-
346-
define rule_rustc_o_rs
347-
$(call cmd_and_fixdep,rustc_o_rs)
348-
$(call cmd,gen_objtooldep)
349-
endef
266+
cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $<
350267

351268
$(obj)/%.o: $(obj)/%.rs FORCE
352-
+$(call if_changed_rule,rustc_o_rs)
269+
+$(call if_changed_dep,rustc_o_rs)
353270

354271
quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
355272
cmd_rustc_rsi_rs = \
@@ -429,7 +346,7 @@ $(obj)/%.o: $(obj)/%.S FORCE
429346

430347
targets += $(filter-out $(subdir-builtin), $(real-obj-y))
431348
targets += $(filter-out $(subdir-modorder), $(real-obj-m))
432-
targets += $(lib-y) $(always-y)
349+
targets += $(real-dtb-y) $(lib-y) $(always-y)
433350

434351
# Linker scripts preprocessor (.lds.S -> .lds)
435352
# ---------------------------------------------------------------------------
@@ -455,6 +372,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
455372
# To build objects in subdirs, we need to descend into the directories
456373
$(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
457374
$(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
375+
$(subdir-dtbslist): $(obj)/%/dtbs-list: $(obj)/% ;
458376

459377
#
460378
# Rule to compile a set of .o files into one .a file (without symbol table)
@@ -470,8 +388,12 @@ quiet_cmd_ar_builtin = AR $@
470388
$(obj)/built-in.a: $(real-obj-y) FORCE
471389
$(call if_changed,ar_builtin)
472390

473-
# This is a list of build artifacts from the current Makefile and its
474-
# sub-directories. The timestamp should be updated when any of the member files.
391+
#
392+
# Rule to create modules.order and dtbs-list
393+
#
394+
# This is a list of build artifacts (module or dtb) from the current Makefile
395+
# and its sub-directories. The timestamp should be updated when any of the
396+
# member files.
475397

476398
cmd_gen_order = { $(foreach m, $(real-prereqs), \
477399
$(if $(filter %/$(notdir $@), $m), cat $m, echo $m);) :; } \
@@ -480,6 +402,9 @@ cmd_gen_order = { $(foreach m, $(real-prereqs), \
480402
$(obj)/modules.order: $(obj-m) FORCE
481403
$(call if_changed,gen_order)
482404

405+
$(obj)/dtbs-list: $(dtb-y) $(dtbo-y) FORCE
406+
$(call if_changed,gen_order)
407+
483408
#
484409
# Rule to compile a set of .o files into one .a file (with symbol table)
485410
#
@@ -508,26 +433,15 @@ intermediate_targets = $(foreach sfx, $(2), \
508433
$(patsubst %$(strip $(1)),%$(sfx), \
509434
$(filter %$(strip $(1)), $(targets))))
510435
# %.asn1.o <- %.asn1.[ch] <- %.asn1
511-
targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h)
512-
513-
# Include additional build rules when necessary
514-
# ---------------------------------------------------------------------------
515-
516-
# $(sort ...) is used here to remove duplicated words and excessive spaces.
517-
hostprogs := $(sort $(hostprogs))
518-
ifneq ($(hostprogs),)
519-
include $(srctree)/scripts/Makefile.host
520-
endif
521-
522-
# $(sort ...) is used here to remove duplicated words and excessive spaces.
523-
userprogs := $(sort $(userprogs))
524-
ifneq ($(userprogs),)
525-
include $(srctree)/scripts/Makefile.userprogs
526-
endif
527-
528-
ifneq ($(need-dtbslist)$(dtb-y)$(dtb-)$(filter %.dtb %.dtb.o %.dtbo.o,$(targets)),)
529-
include $(srctree)/scripts/Makefile.dtbs
530-
endif
436+
# %.dtb.o <- %.dtb.S <- %.dtb <- %.dts
437+
# %.dtbo.o <- %.dtbo.S <- %.dtbo <- %.dtso
438+
# %.lex.o <- %.lex.c <- %.l
439+
# %.tab.o <- %.tab.[ch] <- %.y
440+
targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
441+
$(call intermediate_targets, .dtb.o, .dtb.S .dtb) \
442+
$(call intermediate_targets, .dtbo.o, .dtbo.S .dtbo) \
443+
$(call intermediate_targets, .lex.o, .lex.c) \
444+
$(call intermediate_targets, .tab.o, .tab.c .tab.h)
531445

532446
# Build
533447
# ---------------------------------------------------------------------------

scripts/Makefile.compiler

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ as-instr = $(call try-run,\
4343
# __cc-option
4444
# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
4545
__cc-option = $(call try-run,\
46-
$(1) -Werror $(2) $(3:-Wno-%=-W%) -c -x c /dev/null -o "$$TMP",$(3),$(4))
46+
$(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
4747

4848
# cc-option
4949
# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
@@ -57,10 +57,10 @@ cc-option-yn = $(if $(call cc-option,$1),y,n)
5757

5858
# cc-disable-warning
5959
# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
60-
cc-disable-warning = $(call cc-option,-Wno-$(strip $1))
60+
cc-disable-warning = $(if $(call cc-option,-W$(strip $1)),-Wno-$(strip $1))
6161

6262
# gcc-min-version
63-
# Usage: cflags-$(call gcc-min-version, 110100) += -foo
63+
# Usage: cflags-$(call gcc-min-version, 70100) += -foo
6464
gcc-min-version = $(call test-ge, $(CONFIG_GCC_VERSION), $1)
6565

6666
# clang-min-version

scripts/Makefile.extrawarn

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ KBUILD_CFLAGS += -Werror=return-type
1616
KBUILD_CFLAGS += -Werror=strict-prototypes
1717
KBUILD_CFLAGS += -Wno-format-security
1818
KBUILD_CFLAGS += -Wno-trigraphs
19-
KBUILD_CFLAGS += $(call cc-option, -Wno-frame-address)
20-
KBUILD_CFLAGS += $(call cc-option, -Wno-address-of-packed-member)
19+
KBUILD_CFLAGS += $(call cc-disable-warning, frame-address)
20+
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
2121
KBUILD_CFLAGS += -Wmissing-declarations
2222
KBUILD_CFLAGS += -Wmissing-prototypes
2323

@@ -35,8 +35,8 @@ KBUILD_CFLAGS += -Wno-gnu
3535

3636
# Clang checks for overflow/truncation with '%p', while GCC does not:
3737
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219
38-
KBUILD_CFLAGS += $(call cc-option, -Wno-format-overflow-non-kprintf)
39-
KBUILD_CFLAGS += $(call cc-option, -Wno-format-truncation-non-kprintf)
38+
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow-non-kprintf)
39+
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf)
4040

4141
# Clang may emit a warning when a const variable, such as the dummy variables
4242
# in typecheck(), or const member of an aggregate type are not initialized,
@@ -48,23 +48,18 @@ KBUILD_CFLAGS += $(call cc-option, -Wno-format-truncation-non-kprintf)
4848
# disabled with this same switch, there should not be too much coverage lost
4949
# because -Wuninitialized will still flag when an uninitialized const variable
5050
# is used.
51-
KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe)
51+
KBUILD_CFLAGS += $(call cc-disable-warning, default-const-init-unsafe)
5252
else
5353

5454
# gcc inanely warns about local variables called 'main'
5555
KBUILD_CFLAGS += -Wno-main
5656
endif
5757

5858
# These result in bogus false positives
59-
KBUILD_CFLAGS += $(call cc-option, -Wno-dangling-pointer)
59+
KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer)
6060

61-
# Stack Variable Length Arrays (VLAs) must not be used in the kernel.
62-
# Function array parameters should, however, be usable, but -Wvla will
63-
# warn for those. Clang has no way yet to distinguish between the VLA
64-
# types, so depend on GCC for now to keep stack VLAs out of the tree.
65-
# https://github.com/llvm/llvm-project/issues/57098
66-
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98217
67-
KBUILD_CFLAGS += $(call cc-option,-Wvla-larger-than=1)
61+
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
62+
KBUILD_CFLAGS += -Wvla
6863

6964
# disable pointer signed / unsigned warnings in gcc 4.0
7065
KBUILD_CFLAGS += -Wno-pointer-sign
@@ -75,11 +70,11 @@ KBUILD_CFLAGS += -Wno-pointer-sign
7570
KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
7671

7772
# Currently, disable -Wstringop-overflow for GCC 11, globally.
78-
KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow)
73+
KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-disable-warning, stringop-overflow)
7974
KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
8075

8176
# Currently, disable -Wunterminated-string-initialization as broken
82-
KBUILD_CFLAGS += $(call cc-option, -Wno-unterminated-string-initialization)
77+
KBUILD_CFLAGS += $(call cc-disable-warning, unterminated-string-initialization)
8378

8479
# The allocators already balk at large sizes, so silence the compiler
8580
# warnings for bounds checks involving those possible values. While
@@ -125,14 +120,14 @@ else
125120

126121
# Some diagnostics enabled by default are noisy.
127122
# Suppress them by using -Wno... except for W=1.
128-
KBUILD_CFLAGS += $(call cc-option, -Wno-unused-but-set-variable)
129-
KBUILD_CFLAGS += $(call cc-option, -Wno-unused-const-variable)
130-
KBUILD_CFLAGS += $(call cc-option, -Wno-packed-not-aligned)
131-
KBUILD_CFLAGS += $(call cc-option, -Wno-format-overflow)
123+
KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
124+
KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
125+
KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
126+
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
132127
ifdef CONFIG_CC_IS_GCC
133-
KBUILD_CFLAGS += $(call cc-option, -Wno-format-truncation)
128+
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
134129
endif
135-
KBUILD_CFLAGS += $(call cc-option, -Wno-stringop-truncation)
130+
KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
136131

137132
KBUILD_CFLAGS += -Wno-override-init # alias for -Wno-initializer-overrides in clang
138133

@@ -150,9 +145,9 @@ ifeq ($(call clang-min-version, 120000),y)
150145
KBUILD_CFLAGS += -Wformat-insufficient-args
151146
endif
152147
endif
153-
KBUILD_CFLAGS += $(call cc-option, -Wno-pointer-to-enum-cast)
148+
KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)
154149
KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
155-
KBUILD_CFLAGS += $(call cc-option, -Wno-unaligned-access)
150+
KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
156151
KBUILD_CFLAGS += -Wno-enum-compare-conditional
157152
endif
158153

0 commit comments

Comments
 (0)