Skip to contentSkip to conversation

kbuild/all archs: Sanitize creating offsets.h

DISCUSSION Sam Ravnborg 6 participants 19 messages Oct 28, 2004 – Oct 29, 2004

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

When creating offsets.h from arch/$(ARCH)/Makefile we failed to check all dependencies. A few key dependencies were listed - but a manually edited list of include files are bound to be incomplete.
A few times I have tried building a kernel - which failed because offsets.h needed to be updated but kbuild failed to do so. I wonder what could happen with a kernel with an out-dated offsets.h file with wrong assembler constants.

This serie of patches fixes this.
Generating offsets.h is moved to include/asm-$(ARCH)/Kbuild and the usual dependency tracking is used to detect when an update is needed.

With this mail four patches are posted:
o Accept kbuild file named Kbuild
o generic support for offsets.h
o changes for i386
o changes for arm

The second patch breaks all architectures...

My bk tree at bk://linux-sam.bkbits.net/kbuild contains support for most architectures (sh and cris missing for now).

Sam

#1 lore raw

New kbuild filename: Kbuild

kbuild: Prefer Kbuild as name of the kbuild files

The kbuild syntax is unique and does only have very few things in common with usual Makefile syntax. So to avoid confusion make the filename 'Kbuild' be the preferred name as replacement for 'Makefile'.
No global renaming planned to take place for now, but new stuff expected to use the new 'Kbuild' filename.

Documentation/kbuild/makefiles.txt +5 -2
diff -Nru a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
@@ -6,7 +6,7 @@
 
 	=== 1 Overview
 	=== 2 Who does what
-	=== 3 The kbuild Makefiles
+	=== 3 The kbuild files
 	   --- 3.1 Goal definitions
 	   --- 3.2 Built-in object goals - obj-y
 	   --- 3.3 Loadable module goals - obj-m
@@ -101,11 +101,14 @@
 This document is aimed towards normal developers and arch developers.
 
 
-=== 3 The kbuild Makefiles
+=== 3 The kbuild files
 
 Most Makefiles within the kernel are kbuild Makefiles that use the
 kbuild infrastructure. This chapter introduce the syntax used in the
 kbuild makefiles.
+The preferred name for the kbuild files is 'Kbuild' but 'Makefile' will
+continue to be supported. All new developmen is expected to use the
+Kbuild filename.
 
 Section 3.1 "Goal definitions" is a quick intro, further chapters provide
 more details, with real examples.
scripts/Makefile.build +1 -1
diff -Nru a/scripts/Makefile.build b/scripts/Makefile.build
@@ -10,7 +10,7 @@
 # Read .config if it exist, otherwise ignore
 -include .config
 
-include $(obj)/Makefile
+include $(if $(wildcard $(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile)
 
 include scripts/Makefile.lib
 
scripts/Makefile.clean +1 -1
diff -Nru a/scripts/Makefile.clean b/scripts/Makefile.clean
@@ -7,7 +7,7 @@
 .PHONY: __clean
 __clean:
 
-include $(obj)/Makefile
+include $(if $(wildcard $(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile)
 
 # Figure out what we need to build from the various variables
 # ==========================================================================
#7 lore raw

kbuild: generic support for offsets.h

In reply to Sam Ravnborg

kbuild: introduce a generic method to generate offsets.h

The following patch will break most architectures because it introduce a new way to generate the offsets.h file. The main rationale is to use correct dependencies for the offsets.h file. Before one could change a .h file with no recompile of offsets.h resulting in assembler code to use wrong constants - horror. Follow-up patches will try to unbreak all relevant architectures.

As an added bonus give a nice print-out when .config is missing.

Makefile +5 -21
diff -Nru a/Makefile b/Makefile
@@ -476,6 +476,9 @@
 -include .config.cmd
 
 include .config
+$(if $(wildcard .config),, \
+	$(warning *** Use 'make *config' to generate .config.) \
+	$(error Try 'make help'!))
 
 # If .config needs to be updated, it will be done via the dependency
 # that autoconf has on .config.
@@ -758,6 +761,7 @@
 prepare1: prepare2 outputmakefile
 
 prepare0: prepare1 include/linux/version.h include/asm include/config/MARKER
+	$(Q)$(MAKE) $(build)=$(srctree)/include/asm
 ifneq ($(KBUILD_MODULES),)
 	$(Q)rm -rf $(MODVERDIR)
 	$(Q)mkdir -p $(MODVERDIR)
@@ -904,26 +908,6 @@
 
 endif # CONFIG_MODULES
 
-# Generate asm-offsets.h 
-# ---------------------------------------------------------------------------
-
-define filechk_gen-asm-offsets
-	(set -e; \
-	 echo "#ifndef __ASM_OFFSETS_H__"; \
-	 echo "#define __ASM_OFFSETS_H__"; \
-	 echo "/*"; \
-	 echo " * DO NOT MODIFY."; \
-	 echo " *"; \
-	 echo " * This file was generated by arch/$(ARCH)/Makefile"; \
-	 echo " *"; \
-	 echo " */"; \
-	 echo ""; \
-	 sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
-	 echo ""; \
-	 echo "#endif" )
-endef
-
-
 ###
 # Cleaning is done on three levels.
 # make clean     Delete most generated files
@@ -946,7 +930,7 @@
 #
 clean: rm-dirs  := $(CLEAN_DIRS)
 clean: rm-files := $(CLEAN_FILES)
-clean-dirs      := $(addprefix _clean_,$(vmlinux-alldirs))
+clean-dirs      := $(addprefix _clean_,$(vmlinux-alldirs) include/asm-$(ARCH))
 
 .PHONY: $(clean-dirs) clean archclean
 $(clean-dirs):
include/asm-generic/Kbuild new file +24 -0
diff -Nru a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild
@@ -0,0 +1,24 @@
+# kbuild file for asm-generic contains generic support
+# for usage in asm-$(ARCH)
+# This file is included from include/asm-$(ARCH)/Kbuild
+
+
+# Generate asm-offsets.h 
+# ---------------------------------------------------------------------------
+
+define filechk_gen-asm-offsets
+	(set -e; \
+	 echo "#ifndef __ASM_OFFSETS_H__"; \
+	 echo "#define __ASM_OFFSETS_H__"; \
+	 echo "/*"; \
+	 echo " * DO NOT MODIFY."; \
+	 echo " *"; \
+	 echo " * This file was generated by arch/$(ARCH)/Makefile"; \
+	 echo " *"; \
+	 echo " */"; \
+	 echo ""; \
+	 sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
+	 echo ""; \
+	 echo "#endif" )
+endef
+
#8 lore raw

i386: use generic support for offsets.h

In reply to Sam Ravnborg

i386: use new generic infrastructure to generate offsets.h

Also renamed .h file to offsets.h.

arch/i386/Makefile +0 -9
diff -Nru a/arch/i386/Makefile b/arch/i386/Makefile
@@ -140,15 +140,6 @@
 install fdimage fdimage144 fdimage288: vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@
 
-prepare: include/asm-$(ARCH)/asm_offsets.h
-CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h
-
-arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \
-				   include/config/MARKER
-
-include/asm-$(ARCH)/asm_offsets.h: arch/$(ARCH)/kernel/asm-offsets.s
-	$(call filechk,gen-asm-offsets)
-
 archclean:
 	$(Q)$(MAKE) $(clean)=arch/i386/boot
 
arch/i386/kernel/asm-offsets.c deleted +0 -66

66 lines not on this page · raw message

arch/i386/kernel/head.S +1 -1
diff -Nru a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S
@@ -17,7 +17,7 @@
 #include <asm/desc.h>
 #include <asm/cache.h>
 #include <asm/thread_info.h>
-#include <asm/asm_offsets.h>
+#include <asm/offsets.h>
 #include <asm/setup.h>
 
 /*
arch/i386/kernel/vsyscall-sigreturn.S +1 -1
diff -Nru a/arch/i386/kernel/vsyscall-sigreturn.S b/arch/i386/kernel/vsyscall-sigreturn.S
@@ -7,7 +7,7 @@
  */
 
 #include <asm/unistd.h>
-#include <asm/asm_offsets.h>
+#include <asm/offsets.h>
 
 
 /* XXX
arch/i386/kernel/vsyscall.lds.S +1 -1
diff -Nru a/arch/i386/kernel/vsyscall.lds.S b/arch/i386/kernel/vsyscall.lds.S
@@ -3,7 +3,7 @@
  * object prelinked to its virtual address, and with only one read-only
  * segment (that fits in one page).  This script controls its layout.
  */
-#include <asm/asm_offsets.h>
+#include <asm/offsets.h>
 
 SECTIONS
 {
include/asm-i386/Kbuild new file +17 -0
diff -Nru a/include/asm-i386/Kbuild b/include/asm-i386/Kbuild
@@ -0,0 +1,17 @@
+# Generate header files required for i386
+# Pull in generic stuff from include/asm-generic
+# Used to:
+# 1) Generate include/asm/offset.h
+
+# pull in generic parts
+include $(srctree)/include/asm-generic/Kbuild
+
+
+# generate offsets.h file
+always  := offsets.h
+targets := offsets.s
+
+CFLAGS_offsets.o := -I arch/i386/kernel
+
+$(obj)/offsets.h: $(obj)/offsets.s FORCE
+	$(call filechk,gen-asm-offsets, < $<)
include/asm-i386/offsets.c new file +66 -0

66 lines not on this page · raw message

include/asm-i386/thread_info.h +1 -1
diff -Nru a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h
@@ -47,7 +47,7 @@
 
 #else /* !__ASSEMBLY__ */
 
-#include <asm/asm_offsets.h>
+#include <asm/offsets.h>
 
 #endif
 
#11 lore raw

arm: use generic support for constants.h

In reply to Sam Ravnborg

arm: Use new generic offset.h infrastructure

The symlinking taking place in include/asm-arm had to move also. Did not have an arm toolchain to test it..

arch/arm/Makefile +3 -23
diff -Nru a/arch/arm/Makefile b/arch/arm/Makefile
@@ -108,7 +108,7 @@
 ifeq ($(incdir-y),)
 incdir-y := $(machine-y)
 endif
-INCDIR   := arch-$(incdir-y)
+export INCDIR   := arch-$(incdir-y)
 ifneq ($(machine-y),)
 MACHINE  := arch/arm/mach-$(machine-y)/
 else
@@ -141,21 +141,7 @@
 
 boot := arch/arm/boot
 
-#	Update machine arch and proc symlinks if something which affects
-#	them changed.  We use .arch to indicate when they were updated
-#	last, otherwise make uses the target directory mtime.
-
-include/asm-arm/.arch: $(wildcard include/config/arch/*.h) include/config/MARKER
-	@echo '  SYMLINK include/asm-arm/arch -> include/asm-arm/$(INCDIR)'
-ifneq ($(KBUILD_SRC),)
-	$(Q)mkdir -p include/asm-arm
-	$(Q)ln -fsn $(srctree)/include/asm-arm/$(INCDIR) include/asm-arm/arch
-else
-	$(Q)ln -fsn $(INCDIR) include/asm-arm/arch
-endif
-	@touch $@
-
-prepare: maketools include/asm-arm/.arch
+prepare: maketools
 
 .PHONY: maketools FORCE
 maketools: include/asm-arm/constants.h include/linux/version.h FORCE
@@ -171,7 +157,7 @@
 	$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@
 
 CLEAN_FILES += include/asm-arm/constants.h* include/asm-arm/mach-types.h \
-	       include/asm-arm/arch include/asm-arm/.arch
+	       include/asm-arm/arch
 
 # We use MRPROPER_FILES and CLEAN_FILES now
 archclean:
@@ -180,12 +166,6 @@
 # My testing targets (bypasses dependencies)
 bp:;	$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/bootpImage
 i zi:;	$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@
-
-arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \
-				   include/asm-arm/.arch
-
-include/asm-$(ARCH)/constants.h: arch/$(ARCH)/kernel/asm-offsets.s
-	$(call filechk,gen-asm-offsets)
 
 define archhelp
   echo  '* zImage        - Compressed kernel image (arch/$(ARCH)/boot/zImage)'
arch/arm/kernel/asm-offsets.c deleted +0 -80

80 lines not on this page · raw message

include/asm-arm/Kbuild new file +35 -0
diff -Nru a/include/asm-arm/Kbuild b/include/asm-arm/Kbuild
@@ -0,0 +1,35 @@
+# Generate header files required for $(ARCH)
+# Pull in generic stuff from include/asm-generic
+# Used to:
+# 1) Generate include/asm/offset.h
+
+# pull in generic parts
+include $(srctree)/include/asm-generic/Kbuild
+
+always  := constants.h include/asm-arm/.arch
+
+# Update machine arch and proc symlinks if something which affects
+# them changed.  We use .arch to indicate when they were updated
+# last, otherwise make uses the target directory mtime.
+
+include/asm-arm/.arch: $(wildcard include/config/arch/*.h) include/config/MARKER
+	@echo '  SYMLINK include/asm-arm/arch -> include/asm-arm/$(INCDIR)'
+ifneq ($(KBUILD_SRC),)
+	$(Q)mkdir -p include/asm-arm
+	$(Q)ln -fsn $(srctree)/include/asm-arm/$(INCDIR) include/asm-arm/arch
+else
+	$(Q)ln -fsn $(INCDIR) include/asm-arm/arch
+endif
+	@touch $@
+
+
+# generate offsets.h file
+targets := offsets.s
+
+CFLAGS_offsets.o := -I arch/$(ARCH)/kernel
+
+# explicit dependency
+$(obj)/offsets.s: include/asm-arm/.arch
+
+$(obj)/constants.h: $(obj)/offsets.s FORCE
+	$(call filechk,gen-asm-offsets, < $<)
include/asm-arm/offsets.c new file +80 -0

80 lines not on this page · raw message

#2 lore raw

Re: New kbuild filename: Kbuild

In reply to Sam Ravnborg

Documentation/kbuild/makefiles.txt line 110

Quoted 13 lines · Sam Ravnborg
Documentation/kbuild/makefiles.txt +3 -1
 This document is aimed towards normal developers and arch developers.
 
 
-=== 3 The kbuild Makefiles
+=== 3 The kbuild files
 
 Most Makefiles within the kernel are kbuild Makefiles that use the
 kbuild infrastructure. This chapter introduce the syntax used in the
 kbuild makefiles.
+The preferred name for the kbuild files is 'Kbuild' but 'Makefile' will
+continue to be supported. All new developmen is expected to use the
                                     ^^^^^^^^^^
				     development
Quoted 4 lines

+Kbuild filename.

Section 3.1 "Goal definitions" is a quick intro, further chapters provide more details, with real examples.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#12 lore raw
In reply to Sam Ravnborg
Quoted 7 lines · Sam Ravnborg

When creating offsets.h from arch/$(ARCH)/Makefile we failed to check all dependencies. A few key dependencies were listed - but a manually edited list of include files are bound to be incomplete.
A few times I have tried building a kernel - which failed because offsets.h needed to be updated but kbuild failed to do so. I wonder what could happen with a kernel with an out-dated offsets.h file with wrong assembler constants.

This fails:

rmk@dyn-67:[linux-2.6-rmk]:<1041> amake O=../build/rpc
Using /home/rmk/bk/linux-2.6-rmk as source for kernel
GEN /home/rmk/bk/build/rpc/Makefile

  CHK     include/linux/version.h
  UPD     include/linux/version.h
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/split-include
  HOSTCC  scripts/basic/docproc

GEN /home/rmk/bk/build/rpc/Makefile
SHIPPED scripts/kconfig/zconf.tab.h
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/mconf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/lex.zconf.c
HOSTCC -fPIC scripts/kconfig/zconf.tab.o
HOSTLLD -shared scripts/kconfig/libkconfig.so
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf -s arch/arm/Kconfig
#

# using defaults found in .config
#
  SPLIT   include/linux/autoconf.h -> include/config/*
/home/rmk/bk/linux-2.6-rmk/scripts/Makefile.build:13: /home/rmk/bk/linux-2.6-rmk/include/asm/Makefile: No such file or directory
make[2]: *** No rule to make target `/home/rmk/bk/linux-2.6-rmk/include/asm/Makefile'.  Stop.
make[1]: *** [prepare0] Error 2
make: *** [_all] Error 2

../build/rpc only contained .version and .config

Signature · 4 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core
#13 lore raw
Quoted 38 lines · Russell King
Quoted 7 lines · Sam Ravnborg

When creating offsets.h from arch/$(ARCH)/Makefile we failed to check all dependencies. A few key dependencies were listed - but a manually edited list of include files are bound to be incomplete.
A few times I have tried building a kernel - which failed because offsets.h needed to be updated but kbuild failed to do so. I wonder what could happen with a kernel with an out-dated offsets.h file with wrong assembler constants.

This fails:

rmk@dyn-67:[linux-2.6-rmk]:<1041> amake O=../build/rpc
Using /home/rmk/bk/linux-2.6-rmk as source for kernel
GEN /home/rmk/bk/build/rpc/Makefile

  CHK     include/linux/version.h
  UPD     include/linux/version.h
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/split-include
  HOSTCC  scripts/basic/docproc

GEN /home/rmk/bk/build/rpc/Makefile
SHIPPED scripts/kconfig/zconf.tab.h
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/mconf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/lex.zconf.c
HOSTCC -fPIC scripts/kconfig/zconf.tab.o
HOSTLLD -shared scripts/kconfig/libkconfig.so
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf -s arch/arm/Kconfig
#

# using defaults found in .config
#
  SPLIT   include/linux/autoconf.h -> include/config/*
/home/rmk/bk/linux-2.6-rmk/scripts/Makefile.build:13: /home/rmk/bk/linux-2.6-rmk/include/asm/Makefile: No such file or directory
make[2]: *** No rule to make target `/home/rmk/bk/linux-2.6-rmk/include/asm/Makefile'.  Stop.
make[1]: *** [prepare0] Error 2
make: *** [_all] Error 2
Quoted 1 line

../build/rpc only contained .version and .config

Did you apply the patch that enabled kbuild files to be named Kbuild? It looks like this patch is missing.

If you did apply the patch could you please check if the asm->asm-arm symlink exists when the error happens and that a file named Kbuild is located in the directory:
include/asm-arm/

Sam

#14 lore raw
Quoted 10 lines · Sam Ravnborg
Quoted 7 lines

SPLIT include/linux/autoconf.h -> include/config/*
/home/rmk/bk/linux-2.6-rmk/scripts/Makefile.build:13: /home/rmk/bk/linux-2.6-rmk/include/asm/Makefile: No such file or directory make[2]: *** No rule to make target `/home/rmk/bk/linux-2.6-rmk/include/asm/Makefile'. Stop.
make[1]: *** [prepare0] Error 2
make: *** [_all] Error 2

../build/rpc only contained .version and .config

Did you apply the patch that enabled kbuild files to be named Kbuild? It looks like this patch is missing.

I applied three patches. The first was "kbuild: Prefer Kbuild as name of the kbuild files"

Quoted 3 lines

If you did apply the patch could you please check if the asm->asm-arm symlink exists when the error happens and that a file named Kbuild is located in the directory: include/asm-arm/

In the source tree, I have:

drwxrwxr-x   2 rmk rmk  4096 Oct 28 20:38 include/asm
-rw-rw-r--   1 rmk rmk  1026 Oct 28 20:37 include/asm-arm/Kbuild

Note that kbuild created an extra directory called asm in the source tree. In the output tree:

rmk@dyn-67:[linux-2.6-rmk]:<1047> vdir ../build/rpc/include/
drwxr-xr-x 120 rmk rmk 4096 Oct 28 20:42 config
drwxrwxr-x 2 rmk rmk 4096 Oct 28 20:42 linux
rmk@dyn-67:[linux-2.6-rmk]:<1048> vdir ../build/rpc/include2/
total 0
lrwxrwxrwx 1 rmk rmk 42 Oct 28 20:42 asm -> /home/rmk/bk/linux-2.6-rmk/include/asm-arm

After removing ../build/rpc/include* and include/asm:

rmk@dyn-67:[linux-2.6-rmk]:<1050> amake O=../build/rpc
Using /home/rmk/bk/linux-2.6-rmk as source for kernel
GEN /home/rmk/bk/build/rpc/Makefile
CHK include/linux/version.h
UPD include/linux/version.h
SYMLINK include/asm -> include/asm-arm
GEN /home/rmk/bk/build/rpc/Makefile
scripts/kconfig/conf -s arch/arm/Kconfig
#

# using defaults found in .config
#
  SPLIT   include/linux/autoconf.h -> include/config/*
/home/rmk/bk/linux-2.6-rmk/scripts/Makefile.build:13: /home/rmk/bk/linux-2.6-rmk/include/asm/Makefile: No such file or directory
make[2]: *** No rule to make target `/home/rmk/bk/linux-2.6-rmk/include/asm/Makefile'.  Stop.
make[1]: *** [prepare0] Error 2
make: *** [_all] Error 2
rmk@dyn-67:[linux-2.6-rmk]:<1051> vdir ../build/rpc/include*
../build/rpc/include:
total 8
lrwxrwxrwx    1 rmk rmk    7 Oct 28 21:59 asm -> asm-arm
drwxr-xr-x  120 rmk rmk 4096 Oct 28 21:59 config
drwxrwxr-x    2 rmk rmk 4096 Oct 28 21:59 linux

../build/rpc/include2:
total 0
lrwxrwxrwx 1 rmk rmk 42 Oct 28 21:59 asm -> /home/rmk/bk/linux-2.6-rmk/include/asm-arm rmk@dyn-67:[linux-2.6-rmk]:<1052> vdir include/
...
drwxrwxr-x 2 rmk rmk 4096 Oct 28 21:59 asm
drwxrwxr-x 25 rmk rmk 4096 Oct 28 20:37 asm-arm

Signature · 4 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core
#15 lore raw
Quoted 9 lines · Russell King
Quoted 2 lines

Did you apply the patch that enabled kbuild files to be named Kbuild? It looks like this patch is missing.

I applied three patches. The first was "kbuild: Prefer Kbuild as name of the kbuild files"

Quoted 3 lines

If you did apply the patch could you please check if the asm->asm-arm symlink exists when the error happens and that a file named Kbuild is located in the directory: include/asm-arm/

OK - I see it now.
It's in i386 also - I will have a fix ready tomorrow. Thanks for testing!

Sam

#9 lore raw

Re: i386: use generic support for offsets.h

In reply to Sam Ravnborg

On Thu, 2004-10-28 21:02:21 +0200, Sam Ravnborg <[email protected]> wrote in message <[email protected]>:

include/asm-i386/offsets.c

Quoted 4 lines

diff -Nru a/include/asm-i386/offsets.c b/include/asm-i386/offsets.c

include/asm-i386/offsets.c new file +0 -0
@@ -0,0 +1,66 @@

To be honest, I don't really like to have .c files in the include pathes... However, I don't know about a better idea (except maybe to place this into ./linux/arch/$(ARCH)/lib/)...

MfG, JBG

Signature · 4 lines
Jan-Benedict Glaw       [email protected]    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
 fuer einen Freien Staat voll Freier Bürger" | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
#3 lore raw

Re: New kbuild filename: Kbuild

In reply to Sam Ravnborg
Quoted 7 lines · Sam Ravnborg

kbuild: Prefer Kbuild as name of the kbuild files

The kbuild syntax is unique and does only have very few things in common with usual Makefile syntax. So to avoid confusion make the filename 'Kbuild' be the preferred name as replacement for 'Makefile'.
No global renaming planned to take place for now, but new stuff expected to use the new 'Kbuild' filename.

Disagree. These are just makefiles, and renaming for the sake of it doesn't buy us. If you really want to improve things implement something like

module foo.ko
sources foo.c blah.c
sources foobar.c if FOO_BAR

in Kconfig and get rid of driver makefiles compeltely

#10 lore raw

Re: i386: use generic support for offsets.h

In reply to Jan-Benedict Glaw
Quoted 10 lines · Jan-Benedict Glaw

On Thu, 2004-10-28 21:02:21 +0200, Sam Ravnborg <[email protected]> wrote in message <[email protected]>:

include/asm-i386/offsets.c

Quoted 4 lines

diff -Nru a/include/asm-i386/offsets.c b/include/asm-i386/offsets.c

include/asm-i386/offsets.c new file +0 -0
@@ -0,0 +1,66 @@

To be honest, I don't really like to have .c files in the include pathes... However, I don't know about a better idea (except maybe to place this into ./linux/arch/$(ARCH)/lib/)...

Having the source file in same directory as the result file is a pattern used all over the kernel. Moving the .c file to include/asm-xxx just made this true for offsets.h.
In this process a renaming took place so the name of the source file and the result file match except for the extension.

Some architectures had: asm_offsets.c => offsets.h A non-logical renaming.

As for the idea of having source file located in a separate directory. It's not supported by kbuild today, and I'm reluctant to support it - since it usually triggers misuse. kbuild is about making the trivial stuff easy, but not about full flexibility. If we wanted full flexibility we would not have used so much effort to define a simple syntax.

Sam

#4 lore raw

Re: New kbuild filename: Kbuild

In reply to Christoph Hellwig
Quoted 11 lines · Christoph Hellwig
Quoted 7 lines · Sam Ravnborg

kbuild: Prefer Kbuild as name of the kbuild files

The kbuild syntax is unique and does only have very few things in common with usual Makefile syntax. So to avoid confusion make the filename 'Kbuild' be the preferred name as replacement for 'Makefile'.
No global renaming planned to take place for now, but new stuff expected to use the new 'Kbuild' filename.

Disagree. These are just makefiles, and renaming for the sake of it doesn't buy us.

Makefiles are valid input files to make, and the kbuild files has for a long time had their own documented syntax.
Introduce the Kbuild name just makes this even more apperant for the reader.

When we in two years time start to deal with external modules that only support kernel 2.6.10 and never then we can avoid the ugly:

ifeq ($(KERNELRELEASE),)
...

To separate out the real makefile and the Kbuild stuff.

Quoted 7 lines

If you really want to improve things implement something like

module foo.ko
sources foo.c blah.c
sources foobar.c if FOO_BAR

in Kconfig and get rid of driver makefiles compeltely

I'm in favour of this too - but so far Roman has rejected it. But this still leaves out the other parts where the Kbuild name makes more sense.

PArt of the longer term plaaning is a split of arch/$(ARCH)/Makefile in a Kbuild.define and Kbuild.rules part. This split will allows the kbuild infrastructure to be used also for the top-level part of the kernel - and the next generation kbuild will read in all relevant Kbuild files and create a single Makfilefile for that part of the kernel compilation.

This is part of the vision at least - introducing kbuild contant in Kconfig files is not a hindering for this.

Sam

#5 lore raw

Re: New kbuild filename: Kbuild

Hi,

Quoted 9 lines · Sam Ravnborg
Quoted 7 lines

If you really want to improve things implement something like

module foo.ko
sources foo.c blah.c
sources foobar.c if FOO_BAR

in Kconfig and get rid of driver makefiles compeltely

I'm in favour of this too - but so far Roman has rejected it.

I never rejected this, I just haven't implemented this yet. :)

bye, Roman

#6 lore raw

Re: New kbuild filename: Kbuild

Quoted 10 lines · Roman Zippel

Hi,

Quoted 6 lines · Sam Ravnborg
Quoted 6 lines

If you really want to improve things implement something like

module foo.ko
sources foo.c blah.c
sources foobar.c if FOO_BAR

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

in Kconfig and get rid of driver makefiles compeltely

I'm in favour of this too - but so far Roman has rejected it.

I never rejected this, I just haven't implemented this yet. :)

OK!

Sam

#16 lore raw
In reply to Sam Ravnborg
Quoted 7 lines · Sam Ravnborg
Quoted 6 lines · Russell King
Quoted 2 lines

Did you apply the patch that enabled kbuild files to be named Kbuild? It looks like this patch is missing.

I applied three patches. The first was "kbuild: Prefer Kbuild as name of the kbuild files"

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

If you did apply the patch could you please check if the asm->asm-arm symlink exists when the error happens and that a file named Kbuild is located in the directory: include/asm-arm/

OK - I see it now.
It's in i386 also - I will have a fix ready tomorrow. Thanks for testing!

Fix attached - next time I better check O= support myself. Russell - I would be glad if you could test this version. There is some symlink handling for arm I like to see tested.

Sam

===== Makefile 1.546 vs edited =====

Makefile +1 -1
@@ -761,7 +761,7 @@
 prepare1: prepare2 outputmakefile
 
 prepare0: prepare1 include/linux/version.h include/asm include/config/MARKER
-	$(Q)$(MAKE) $(build)=$(srctree)/include/asm
+	$(Q)$(MAKE) $(build)=include/asm-$(ARCH)
 ifneq ($(KBUILD_MODULES),)
 	$(Q)rm -rf $(MODVERDIR)
 	$(Q)mkdir -p $(MODVERDIR)

===== include/asm-i386/Kbuild 1.1 vs edited =====

include/asm-i386/Kbuild +1 -1
@@ -11,7 +11,7 @@
 always  := offsets.h
 targets := offsets.s
 
-CFLAGS_offsets.o := -I arch/i386/kernel
+CFLAGS_offsets.o := -Iarch/i386/kernel
 
 $(obj)/offsets.h: $(obj)/offsets.s FORCE
 	$(call filechk,gen-asm-offsets, < $<)

===== scripts/Makefile.build 1.51 vs edited =====

scripts/Makefile.build +1 -1
@@ -10,7 +10,7 @@
 # Read .config if it exist, otherwise ignore
 -include .config
 
-include $(if $(wildcard $(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile)
+include $(if $(wildcard $(srctree)/$(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile)
 
 include scripts/Makefile.lib
 

===== scripts/Makefile.clean 1.17 vs edited =====

scripts/Makefile.clean +1 -1
@@ -7,7 +7,7 @@
 .PHONY: __clean
 __clean:
 
-include $(if $(wildcard $(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile)
+include $(if $(wildcard $(srctree)/$(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile)
 
 # Figure out what we need to build from the various variables
 # ==========================================================================
#17 lore raw
Quoted 12 lines · Sam Ravnborg
Quoted 11 lines · Sam Ravnborg
Quoted 9 lines · Russell King
Quoted 2 lines

Did you apply the patch that enabled kbuild files to be named Kbuild? It looks like this patch is missing.

I applied three patches. The first was "kbuild: Prefer Kbuild as name of the kbuild files"

Quoted 3 lines

If you did apply the patch could you please check if the asm->asm-arm symlink exists when the error happens and that a file named Kbuild is located in the directory: include/asm-arm/

Quoted 6 lines
Quoted 2 lines

OK - I see it now.
It's in i386 also - I will have a fix ready tomorrow. Thanks for testing!

Fix attached - next time I better check O= support myself. Russell - I would be glad if you could test this version. There is some symlink handling for arm I like to see tested.

Getting better, but still not right:

make -f /home/rmk/bk/linux-2.6-rmk/scripts/Makefile.build obj=include/asm-arm
SYMLINK include/asm-arm/arch -> include/asm-arm/arch-rpc
mkdir -p include/asm-arm
ln -fsn /home/rmk/bk/linux-2.6-rmk/include/asm-arm/arch-rpc include/asm-arm/arch
arm-linux-gcc -Wp,-MD,include/asm-arm/.offsets.s.d -nostdinc -iwithprefix include -D__KERNEL__ -Iinclude -Iinclude2 -I/home/rmk/bk/linux-2.6-rmk/include -I/home/rmk/bk/linux-2.6-rmk/include/asm-arm -Iinclude/asm-arm -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Os -fno-omit-frame-pointer -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mlittle-endian -mapcs-32 -D__LINUX_ARM_ARCH__=3 -march=armv3 -mtune=strongarm110 -malignment-traps -msoft-float -Uarm -Wdeclaration-after-statement -I/home/rmk/bk/linux-2.6-rmk/ -I arch/arm/kernel -DKBUILD_BASENAME=offsets -DKBUILD_MODNAME=offsets -S -o include/asm-arm/offsets.s /home/rmk/bk/linux-2.6-rmk/include/asm-arm/offsets.c
set -e; echo ' CHK include/asm-arm/constants.h'; mkdir -p include/asm-arm/; (set -e; echo "#ifndef __ASM_OFFSETS_H__"; echo "#define __ASM_OFFSETS_H__"; echo "/*"; echo " * DO NOT MODIFY."; echo " *"; echo " * This file was generated by arch/arm/Makefile"; echo " *"; echo " */"; echo ""; sed -ne "/^->/{s:^->\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; echo ""; echo "#endif" ) < include/asm-arm/offsets.s > include/asm-arm/constants.h.tmp; if [ -r include/asm-arm/constants.h ] && cmp -s include/asm-arm/constants.h include/asm-arm/constants.h.tmp; then rm -f include/asm-arm/constants.h.tmp; else echo ' UPD include/asm-arm/constants.h'; mv -f include/asm-arm/constants.h.tmp include/asm-arm/constants.h; fi
CHK include/asm-arm/constants.h
UPD include/asm-arm/constants.h
make[2]: *** No rule to make target include/asm-arm/include/asm-arm/.arch', needed by __build'. Stop.
make[1]: *** [prepare0] Error 2
make: *** [_all] Error 2

Removing "include/asm-arm/" from the always := line in asm-arm/Kbuild appears to fix this.

Signature · 4 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core
#18 lore raw
Quoted 13 lines · Russell King
Quoted 12 lines · Sam Ravnborg
Quoted 11 lines · Sam Ravnborg
Quoted 9 lines · Russell King
Quoted 2 lines

Did you apply the patch that enabled kbuild files to be named Kbuild? It looks like this patch is missing.

I applied three patches. The first was "kbuild: Prefer Kbuild as name of the kbuild files"

Quoted 3 lines

If you did apply the patch could you please check if the asm->asm-arm symlink exists when the error happens and that a file named Kbuild is located in the directory: include/asm-arm/

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

OK - I see it now.
It's in i386 also - I will have a fix ready tomorrow. Thanks for testing!

Fix attached - next time I better check O= support myself. Russell - I would be glad if you could test this version. There is some symlink handling for arm I like to see tested.

Getting better, but still not right:

Thanks.
Building arm toolchain atm so I can test myself.
The .arch stuff was the main reason to post arm.

Sam