Skip to contentSkip to conversation

kbuild

GIT Sam Ravnborg 4 participants 10 messages Apr 19, 2009 – Apr 20, 2009

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

Hi Linus.

We have on the lists recently discussed two features:
1) Move generated files to include/generated
2) Introduce support for subdir-ccflags-y

Both features has low risk of introducing regressions and including them now allow us to use the features for next merge window.

This will for example allow arm to support mach-types.h in include/generated without touching files outside arch/arm.

Please pull.

Sam

The following changes since commit ff54250a0ebab7f90a5f848a0ba63f999830c872:
Linus Torvalds (1):
Remove 'recurse into child resources' logic from 'reserve_region_with_split()'

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-fixes.git master

Sam Ravnborg (2):
kbuild: support include/generated
kbuild: introduce subdir-ccflags-y

 .gitignore                         |    1 +
 Documentation/kbuild/makefiles.txt |   10 ++++++++++
 Makefile                           |    2 +-
 scripts/Makefile.build             |    3 +++
 scripts/Makefile.lib               |    9 +++++++--
 5 files changed, 22 insertions(+), 3 deletions(-)
.gitignore +1 -0
index 869e1a3..51bd99d 100644
@@ -49,6 +49,7 @@ include/linux/compile.h
 include/linux/version.h
 include/linux/utsrelease.h
 include/linux/bounds.h
+include/generated
 
 # stgit generated dirs
 patches-*
Documentation/kbuild/makefiles.txt +10 -0
index d4b0567..d76cfd8 100644
@@ -316,6 +316,16 @@ more details, with real examples.
 		#arch/m68k/fpsp040/Makefile
 		ldflags-y := -x
 
+    subdir-ccflags-y, subdir-asflags-y
+	The two flags listed above are similar to ccflags-y and as-falgs-y.
+	The difference is that the subdir- variants has effect for the kbuild
+	file where tey are present and all subdirectories.
+	Options specified using subdir-* are added to the commandline before
+	the options specified using the non-subdir variants.
+
+	Example:
+		subdir-ccflags-y := -Werror
+
     CFLAGS_$@, AFLAGS_$@
 
 	CFLAGS_$@ and AFLAGS_$@ only apply to commands in current
Makefile +1 -1
index bfdef56..6f4208f 100644
@@ -1200,7 +1200,7 @@ CLEAN_FILES +=	vmlinux System.map \
                 .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
 
 # Directories & files removed with 'make mrproper'
-MRPROPER_DIRS  += include/config include2 usr/include
+MRPROPER_DIRS  += include/config include2 usr/include include/generated
 MRPROPER_FILES += .config .config.old include/asm .version .old_version \
                   include/linux/autoconf.h include/linux/version.h      \
                   include/linux/utsrelease.h                            \
scripts/Makefile.build +3 -0
index 39a9642..5c4b7a4 100644
@@ -27,6 +27,9 @@ ccflags-y  :=
 cppflags-y :=
 ldflags-y  :=
 
+subdir-asflags-y :=
+subdir-ccflags-y :=
+
 # Read auto.conf if it exists, otherwise ignore
 -include include/config/auto.conf
 
scripts/Makefile.lib +7 -2
index 9796195..cba61ca 100644
@@ -4,6 +4,11 @@ ccflags-y  += $(EXTRA_CFLAGS)
 cppflags-y += $(EXTRA_CPPFLAGS)
 ldflags-y  += $(EXTRA_LDFLAGS)
 
+#
+# flags that take effect in sub directories
+export KBUILD_SUBDIR_ASFLAGS := $(KBUILD_SUBDIR_ASFLAGS) $(subdir-asflags-y)
+export KBUILD_SUBDIR_CCFLAGS := $(KBUILD_SUBDIR_CCFLAGS) $(subdir-ccflags-y)
+
 # Figure out what we need to build from the various variables
 # ===========================================================================
 
@@ -104,10 +109,10 @@ else
 debug_flags =
 endif
 
-orig_c_flags   = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)                     \
+orig_c_flags   = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
                  $(ccflags-y) $(CFLAGS_$(basetarget).o)
 _c_flags       = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
-_a_flags       = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS)                     \
+_a_flags       = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \
                  $(asflags-y) $(AFLAGS_$(basetarget).o)
 _cpp_flags     = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
 
#1 lore raw
Quoted 11 lines · Sam Ravnborg

We have on the lists recently discussed two features:
1) Move generated files to include/generated
2) Introduce support for subdir-ccflags-y

Both features has low risk of introducing regressions and including them now allow us to use the features for next merge window.

This will for example allow arm to support mach-types.h in include/generated without touching files outside arch/arm.

This applies to sh also, although apparently I've missed the discussion about how mach-types.h generation should be using this.

#2 lore raw
Quoted 9 lines · Paul Mundt
Quoted 8 lines · Sam Ravnborg

We have on the lists recently discussed two features:
1) Move generated files to include/generated
2) Introduce support for subdir-ccflags-y

Both features has low risk of introducing regressions and including them now allow us to use the features for next merge window.

Quoted 5 lines
Quoted 3 lines

This will for example allow arm to support mach-types.h in include/generated without touching files outside arch/arm.

This applies to sh also, although apparently I've missed the discussion about how mach-types.h generation should be using this.

You will soon see a path from me where I fix sh too.

Sam

#3 lore raw
Quoted 2 lines · Sam Ravnborg

You will soon see a path from me where I fix sh too.

Can we do a global 'sed s:asm/asm-offsets.h:generated/asm-offsets.h:g' thing too? And then get rid of the include/asm symlink?

That asm-offsets.h mess is scary. I don't quite know why kvm on ia64 seems to do it's own asm-offsets.h file, for example. And arch/blackfin/Makefile mentions arch/$(ARCH)/include/asm/asm-offsets.h (but does it actually do one?).

Linus

#4 lore raw
Quoted 6 lines · Linus Torvalds
Quoted 2 lines · Sam Ravnborg

You will soon see a path from me where I fix sh too.

Quoted 7 lines

Can we do a global 'sed s:asm/asm-offsets.h:generated/asm-offsets.h:g' thing too? And then get rid of the include/asm symlink?

That asm-offsets.h mess is scary. I don't quite know why kvm on ia64 seems to do it's own asm-offsets.h file, for example. And arch/blackfin/Makefile mentions arch/$(ARCH)/include/asm/asm-offsets.h (but does it actually do one?).

We'll need to update uml as well (contents of shared/kern_constants.h)

As for the arch/ia64/kvm/asm-offsets, AFAICS that could go straight into arch/ia64/kernel/asm-offsets.c, under ifdef CONFIG_KVM.

I'm not sure about sed job, BTW - might be better to start with arch/*/include/asm/asm-offsets.h containing just one include, then do the transition you want piece by piece. And then kill these files as corresponding architectures lose the last unconverted includes.

Fewer merge conflicts with the stuff in architecture trees that way and the final result will be exactly the same...

#5 lore raw
Quoted 10 lines · Al Viro
Quoted 9 lines · Linus Torvalds
Quoted 2 lines · Sam Ravnborg

You will soon see a path from me where I fix sh too.

Can we do a global 'sed s:asm/asm-offsets.h:generated/asm-offsets.h:g' thing too? And then get rid of the include/asm symlink?

Quoted 6 lines
Quoted 4 lines

That asm-offsets.h mess is scary. I don't quite know why kvm on ia64 seems to do it's own asm-offsets.h file, for example. And arch/blackfin/Makefile mentions arch/$(ARCH)/include/asm/asm-offsets.h (but does it actually do one?).

We'll need to update uml as well (contents of shared/kern_constants.h)

BTW, while we are at it... There's a way to deal with arch/um without that kind of contortions, provided that we are willing to use -idirafter.

For the current tree the minimal patch would be just this, and after that we can simply replace all kern_constants.h includes with asm/asm-offsets.h or generated/asm-offsets.h. And remove kern_constants.h completely once that is done.

Moreover, once include/generated gets in, we can move user_constants.h over there and lose the "add -I$(SHARED_HEADERS) to ARCH_INCLUDE for O=... builds bit" in arch/um/Makefile as well.

arch/um/Makefile +2 -2
index 0728def..dce2d7f 100644
@@ -47,7 +47,7 @@ KBUILD_AFLAGS += $(ARCH_INCLUDE)
 
 USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
 	$(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
-	$(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64
+	$(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
 
 include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
 
@@ -150,6 +150,6 @@ $(SHARED_HEADERS)/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s
 
 $(SHARED_HEADERS)/kern_constants.h:
 	$(Q)mkdir -p $(dir $@)
-	$(Q)echo '#include "../../../../include/asm/asm-offsets.h"' >$@
+	$(Q)echo '#include <asm/asm-offsets.h>' >$@
 
 export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH
#6 lore raw
Quoted 16 lines · Al Viro
Quoted 15 lines · Al Viro
Quoted 13 lines · Linus Torvalds
Quoted 2 lines · Sam Ravnborg

You will soon see a path from me where I fix sh too.

Can we do a global 'sed s:asm/asm-offsets.h:generated/asm-offsets.h:g' thing too? And then get rid of the include/asm symlink?

That asm-offsets.h mess is scary. I don't quite know why kvm on ia64 seems to do it's own asm-offsets.h file, for example. And arch/blackfin/Makefile mentions arch/$(ARCH)/include/asm/asm-offsets.h (but does it actually do one?).

Quoted 4 lines
Quoted 1 line

We'll need to update uml as well (contents of shared/kern_constants.h)

BTW, while we are at it... There's a way to deal with arch/um without that kind of contortions, provided that we are willing to use -idirafter.

For kernel proper the use of -idirafter would be confusing. But for um alone we should be safe provided it is properly commented.

I have already fixed um the obvious way for asm-offsets in my local tree. But if you prefer I can add a -dirafter based patch before the "move asm-offsets.h to incldue/generated" patch.

Sam

#7 lore raw
Quoted 2 lines · Sam Ravnborg

For kernel proper the use of -idirafter would be confusing. But for um alone we should be safe provided it is properly commented.

Less than for all um - it's only for USER_OBJ there. It is special, simply because for uml the counterpart of really low-level glue has to talk to libc. So there we have separation into "normal kernel source" and "userland code that uses userland headers, calls libc functions, etc."

Quoted 3 lines

I have already fixed um the obvious way for asm-offsets in my local tree. But if you prefer I can add a -dirafter based patch before the "move asm-offsets.h to incldue/generated" patch.

I've dumped several header cleanup patches for uml into
git://git.kernel.org/pub/scm/linux/kernel/git/viro/um-header.git/
including the -idirafter, move of user_constants.h, etc. Another fun thing: user.h used to be included directly by just about every userland-side file. Switched it to -include user.h (for USER_CFLAGS, of course - not for normal stuff), killed includes, got rid of shitloads of kern_constants.h includes at the same time. At which point getting rid of kern_constants.h became trivial.

Up to Jeff's approval, obviously - *including* -idirafter patch.

author Acked-by
#8 lore raw
Quoted 23 lines · Al Viro
Quoted 2 lines · Sam Ravnborg

For kernel proper the use of -idirafter would be confusing. But for um alone we should be safe provided it is properly commented.

Less than for all um - it's only for USER_OBJ there. It is special, simply because for uml the counterpart of really low-level glue has to talk to libc. So there we have separation into "normal kernel source" and "userland code that uses userland headers, calls libc functions, etc."

Quoted 3 lines

I have already fixed um the obvious way for asm-offsets in my local tree. But if you prefer I can add a -dirafter based patch before the "move asm-offsets.h to incldue/generated" patch.

I've dumped several header cleanup patches for uml into
git://git.kernel.org/pub/scm/linux/kernel/git/viro/um-header.git/
including the -idirafter, move of user_constants.h, etc. Another fun thing: user.h used to be included directly by just about every userland-side file. Switched it to -include user.h (for USER_CFLAGS, of course - not for normal stuff), killed includes, got rid of shitloads of kern_constants.h includes at the same time. At which point getting rid of kern_constants.h became trivial.

Quoted 1 line

Up to Jeff's approval, obviously - *including* -idirafter patch.

I have skimmed the patches - they all looked good to me. Everyting that cleans up arch/um/Makefile is good!

I you respin them you can add my:

The asm-offsets.h that um picks us is the one generated by um. So we still need to add a dummy file in arch/um/include/asm that only do:

    #include <generated/asm-offsets.h>

I will do so in my patch-set.

Sam

#9 lore raw
In reply to Linus Torvalds
Quoted 8 lines · Linus Torvalds
Quoted 2 lines · Sam Ravnborg

You will soon see a path from me where I fix sh too.

Can we do a global 'sed s:asm/asm-offsets.h:generated/asm-offsets.h:g' thing too? And then get rid of the include/asm symlink?

As Al also suggest I did a one-asm-offsets.h file per arch so we can cnvert them one by one.

Quoted 2 lines

That asm-offsets.h mess is scary. I don't quite know why kvm on ia64 seems to do it's own asm-offsets.h file, for example.

Will take a look.

Quoted 3 lines

And arch/blackfin/Makefile
mentions arch/$(ARCH)/include/asm/asm-offsets.h (but does it actually do one?).

Thats just a left over from older days when the arch's had to clean up after themself.

I will try to finish something within a few days and send it out for review.

Sam