Skip to content

Commit 7ae4a78

Browse files
masahir0yRussell King
authored andcommitted
ARM: 8969/1: decompressor: simplify libfdt builds
Copying source files during the build time may not end up with as clean code as expected. lib/fdt*.c simply wrap scripts/dtc/libfdt/fdt*.c, and it works nicely. Let's follow this approach for the arm decompressor, too. Add four wrappers, arch/arm/boot/compressed/fdt*.c and remove the Makefile messes. Another nice thing is we no longer need to maintain the own libfdt_env.h because the decompressor can include <linux/libfdt_env.h>. There is a subtle problem when generated files are turned into check-in files. When you are doing a rebuild of an existing object tree with O= option, there exists stale "shipped" copies that the old Makefile implementation created. The build system ends up with compiling the stale generated files because Make searches for prerequisites in the current directory, i.e. $(objtree) first, and then the directory listed in VPATH, i.e. $(srctree). To mend this issue, I added the following code: ifdef building_out_of_srctree $(shell rm -f $(addprefix $(obj)/, fdt_rw.c fdt_ro.c fdt_wip.c fdt.c)) endif This will need to stay for a while because "git bisect" crossing this commit, otherwise, would result in a build error. Signed-off-by: Masahiro Yamada <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent 4f39467 commit 7ae4a78

File tree

8 files changed

+24
-56
lines changed

8 files changed

+24
-56
lines changed

arch/arm/boot/compressed/.gitignore

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,3 @@ hyp-stub.S
77
piggy_data
88
vmlinux
99
vmlinux.lds
10-
11-
# borrowed libfdt files
12-
fdt.c
13-
fdt.h
14-
fdt_ro.c
15-
fdt_rw.c
16-
fdt_wip.c
17-
libfdt.h
18-
libfdt_internal.h

arch/arm/boot/compressed/Makefile

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,30 @@ compress-$(CONFIG_KERNEL_LZMA) = lzma
7676
compress-$(CONFIG_KERNEL_XZ) = xzkern
7777
compress-$(CONFIG_KERNEL_LZ4) = lz4
7878

79-
# Borrowed libfdt files for the ATAG compatibility mode
80-
81-
libfdt := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c
82-
libfdt_hdrs := fdt.h libfdt.h libfdt_internal.h
83-
84-
libfdt_objs := $(addsuffix .o, $(basename $(libfdt)))
85-
86-
$(addprefix $(obj)/,$(libfdt) $(libfdt_hdrs)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/%
87-
$(call cmd,shipped)
88-
89-
$(addprefix $(obj)/,$(libfdt_objs) atags_to_fdt.o): \
90-
$(addprefix $(obj)/,$(libfdt_hdrs))
79+
libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o
9180

9281
ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
9382
OBJS += $(libfdt_objs) atags_to_fdt.o
9483
endif
9584

85+
# -fstack-protector-strong triggers protection checks in this code,
86+
# but it is being used too early to link to meaningful stack_chk logic.
87+
nossp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
88+
$(foreach o, $(libfdt_objs) atags_to_fdt.o, \
89+
$(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt $(nossp-flags-y)))
90+
91+
# These were previously generated C files. When you are building the kernel
92+
# with O=, make sure to remove the stale files in the output tree. Otherwise,
93+
# the build system wrongly compiles the stale ones.
94+
ifdef building_out_of_srctree
95+
$(shell rm -f $(addprefix $(obj)/, fdt_rw.c fdt_ro.c fdt_wip.c fdt.c))
96+
endif
97+
9698
targets := vmlinux vmlinux.lds piggy_data piggy.o \
9799
lib1funcs.o ashldi3.o bswapsdi2.o \
98100
head.o $(OBJS)
99101

100-
clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S \
101-
$(libfdt) $(libfdt_hdrs) hyp-stub.S
102+
clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S hyp-stub.S
102103

103104
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
104105

@@ -107,15 +108,6 @@ ORIG_CFLAGS := $(KBUILD_CFLAGS)
107108
KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
108109
endif
109110

110-
# -fstack-protector-strong triggers protection checks in this code,
111-
# but it is being used too early to link to meaningful stack_chk logic.
112-
nossp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
113-
CFLAGS_atags_to_fdt.o := $(nossp-flags-y)
114-
CFLAGS_fdt.o := $(nossp-flags-y)
115-
CFLAGS_fdt_ro.o := $(nossp-flags-y)
116-
CFLAGS_fdt_rw.o := $(nossp-flags-y)
117-
CFLAGS_fdt_wip.o := $(nossp-flags-y)
118-
119111
ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \
120112
-I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN)
121113
asflags-y := -DZIMAGE

arch/arm/boot/compressed/atags_to_fdt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
#include <linux/libfdt_env.h>
23
#include <asm/setup.h>
34
#include <libfdt.h>
45

arch/arm/boot/compressed/fdt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
#include "../../../../lib/fdt.c"

arch/arm/boot/compressed/fdt_ro.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
#include "../../../../lib/fdt_ro.c"

arch/arm/boot/compressed/fdt_rw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
#include "../../../../lib/fdt_rw.c"

arch/arm/boot/compressed/fdt_wip.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
#include "../../../../lib/fdt_wip.c"

arch/arm/boot/compressed/libfdt_env.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)