Skip to content

Commit 86feeaa

Browse files
author
Sam Ravnborg
committed
kbuild: full dependency check on asm-offsets.h
Building asm-offsets.h has been moved to a seperate Kbuild file located in the top-level directory. This allow us to share the functionality across the architectures. The old rules in architecture specific Makefiles will die in subsequent patches. Furhtermore the usual kbuild dependency tracking is now used when deciding to rebuild asm-offsets.s. So we no longer risk to fail a rebuild caused by asm-offsets.c dependencies being touched. With this common rule-set we now force the same name across all architectures. Following patches will fix the rest. Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1 parent 8920e8f commit 86feeaa

8 files changed

Lines changed: 57 additions & 42 deletions

File tree

‎Kbuild‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Kbuild for top-level directory of the kernel
3+
# This file takes care of the following:
4+
# 1) Generate asm-offsets.h
5+
6+
#####
7+
# 1) Generate asm-offsets.h
8+
#
9+
10+
offsets-file := include/asm-$(ARCH)/asm-offsets.h
11+
12+
always := $(offsets-file)
13+
targets := $(offsets-file)
14+
targets += arch/$(ARCH)/kernel/asm-offsets.s
15+
16+
quiet_cmd_offsets = GEN $@
17+
define cmd_offsets
18+
cat $< | \
19+
(set -e; \
20+
echo "#ifndef __ASM_OFFSETS_H__"; \
21+
echo "#define __ASM_OFFSETS_H__"; \
22+
echo "/*"; \
23+
echo " * DO NOT MODIFY."; \
24+
echo " *"; \
25+
echo " * This file was generated by $(srctree)/Kbuild"; \
26+
echo " *"; \
27+
echo " */"; \
28+
echo ""; \
29+
sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
30+
echo ""; \
31+
echo "#endif" ) > $@
32+
endef
33+
34+
# We use internal kbuild rules to avoid the "is up to date" message from make
35+
arch/$(ARCH)/kernel/asm-offsets.s: arch/$(ARCH)/kernel/asm-offsets.c FORCE
36+
$(Q)mkdir -p $(dir $@)
37+
$(call if_changed_dep,cc_s_c)
38+
39+
$(srctree)/$(offsets-file): arch/$(ARCH)/kernel/asm-offsets.s Kbuild
40+
$(call cmd,offsets)
41+

‎Makefile‎

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -776,14 +776,14 @@ $(vmlinux-dirs): prepare-all scripts
776776
# A multi level approach is used. prepare1 is updated first, then prepare0.
777777
# prepare-all is the collection point for the prepare targets.
778778

779-
.PHONY: prepare-all prepare prepare0 prepare1 prepare2
779+
.PHONY: prepare-all prepare prepare0 prepare1 prepare2 prepare3
780780

781-
# prepare2 is used to check if we are building in a separate output directory,
781+
# prepare3 is used to check if we are building in a separate output directory,
782782
# and if so do:
783783
# 1) Check that make has not been executed in the kernel src $(srctree)
784784
# 2) Create the include2 directory, used for the second asm symlink
785785

786-
prepare2:
786+
prepare3:
787787
ifneq ($(KBUILD_SRC),)
788788
@echo ' Using $(srctree) as source for kernel'
789789
$(Q)if [ -f $(srctree)/.config ]; then \
@@ -795,18 +795,21 @@ ifneq ($(KBUILD_SRC),)
795795
$(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm
796796
endif
797797

798-
# prepare1 creates a makefile if using a separate output directory
799-
prepare1: prepare2 outputmakefile
798+
# prepare2 creates a makefile if using a separate output directory
799+
prepare2: prepare3 outputmakefile
800800

801-
prepare0: prepare1 include/linux/version.h include/asm \
801+
prepare1: prepare2 include/linux/version.h include/asm \
802802
include/config/MARKER
803803
ifneq ($(KBUILD_MODULES),)
804804
$(Q)rm -rf $(MODVERDIR)
805805
$(Q)mkdir -p $(MODVERDIR)
806806
endif
807807

808+
prepare0: prepare prepare1 FORCE
809+
$(Q)$(MAKE) $(build)=$(srctree)
810+
808811
# All the preparing..
809-
prepare-all: prepare0 prepare
812+
prepare-all: prepare0
810813

811814
# Leave this as default for preprocessing vmlinux.lds.S, which is now
812815
# done in arch/$(ARCH)/kernel/Makefile
@@ -949,26 +952,6 @@ modules modules_install: FORCE
949952

950953
endif # CONFIG_MODULES
951954

952-
# Generate asm-offsets.h
953-
# ---------------------------------------------------------------------------
954-
955-
define filechk_gen-asm-offsets
956-
(set -e; \
957-
echo "#ifndef __ASM_OFFSETS_H__"; \
958-
echo "#define __ASM_OFFSETS_H__"; \
959-
echo "/*"; \
960-
echo " * DO NOT MODIFY."; \
961-
echo " *"; \
962-
echo " * This file was generated by arch/$(ARCH)/Makefile"; \
963-
echo " *"; \
964-
echo " */"; \
965-
echo ""; \
966-
sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
967-
echo ""; \
968-
echo "#endif" )
969-
endef
970-
971-
972955
###
973956
# Cleaning is done on three levels.
974957
# make clean Delete most generated files
@@ -991,7 +974,7 @@ MRPROPER_FILES += .config .config.old include/asm .version \
991974
#
992975
clean: rm-dirs := $(CLEAN_DIRS)
993976
clean: rm-files := $(CLEAN_FILES)
994-
clean-dirs := $(addprefix _clean_,$(vmlinux-alldirs))
977+
clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs))
995978

996979
.PHONY: $(clean-dirs) clean archclean
997980
$(clean-dirs):

‎arch/i386/Makefile‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,6 @@ install: vmlinux
156156
install kernel_install:
157157
$(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install
158158

159-
prepare: include/asm-$(ARCH)/asm_offsets.h
160-
CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h
161-
162-
arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \
163-
include/config/MARKER
164-
165-
include/asm-$(ARCH)/asm_offsets.h: arch/$(ARCH)/kernel/asm-offsets.s
166-
$(call filechk,gen-asm-offsets)
167-
168159
archclean:
169160
$(Q)$(MAKE) $(clean)=arch/i386/boot
170161

‎arch/i386/kernel/head.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <asm/desc.h>
1818
#include <asm/cache.h>
1919
#include <asm/thread_info.h>
20-
#include <asm/asm_offsets.h>
20+
#include <asm/asm-offsets.h>
2121
#include <asm/setup.h>
2222

2323
/*

‎arch/i386/kernel/vsyscall-sigreturn.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
#include <asm/unistd.h>
10-
#include <asm/asm_offsets.h>
10+
#include <asm/asm-offsets.h>
1111

1212

1313
/* XXX

‎arch/i386/kernel/vsyscall.lds.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* object prelinked to its virtual address, and with only one read-only
44
* segment (that fits in one page). This script controls its layout.
55
*/
6-
#include <asm/asm_offsets.h>
6+
#include <asm/asm-offsets.h>
77

88
SECTIONS
99
{

‎arch/i386/power/swsusp.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <linux/linkage.h>
1313
#include <asm/segment.h>
1414
#include <asm/page.h>
15-
#include <asm/asm_offsets.h>
15+
#include <asm/asm-offsets.h>
1616

1717
.text
1818

‎include/asm-i386/thread_info.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct thread_info {
4848

4949
#else /* !__ASSEMBLY__ */
5050

51-
#include <asm/asm_offsets.h>
51+
#include <asm/asm-offsets.h>
5252

5353
#endif
5454

0 commit comments

Comments
 (0)