kbuild
Subsystems (3)
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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))
Quoted 11 lines · Sam Ravnborg
We have on the lists recently discussed two features:
1) Move generated files toinclude/generated
2) Introduce support for subdir-ccflags-yBoth 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.hininclude/generatedwithout touching files outsidearch/arm.
This applies to sh also, although apparently I've missed the discussion about how mach-types.h generation should be using this.
Quoted 9 lines · Paul Mundt
Quoted 8 lines · Sam Ravnborg
We have on the lists recently discussed two features:
1) Move generated files toinclude/generated
2) Introduce support for subdir-ccflags-yBoth 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.hininclude/generatedwithout touching files outsidearch/arm.This applies to sh also, although apparently I've missed the discussion about how
mach-types.hgeneration should be using this.
You will soon see a path from me where I fix sh too.
Sam
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
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/asmsymlink?That
asm-offsets.hmess is scary. I don't quite know why kvm on ia64 seems to do it's ownasm-offsets.hfile, for example. Andarch/blackfin/Makefilementions 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...
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/asmsymlink?
Quoted 6 lines
Quoted 4 lines
That
asm-offsets.hmess is scary. I don't quite know why kvm on ia64 seems to do it's ownasm-offsets.hfile, for example. Andarch/blackfin/Makefilementions 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
@@ -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
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/asmsymlink?That
asm-offsets.hmess is scary. I don't quite know why kvm on ia64 seems to do it's ownasm-offsets.hfile, for example. Andarch/blackfin/Makefilementions 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/umwithout 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
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.hto incldue/generated" patch.
I've dumped several header cleanup patches for uml intogit://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.
Sam Ravnborg
Acked-byQuoted 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_OBJthere. 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.hto 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 ofuser_constants.h, etc. Another fun thing:user.hused to be included directly by just about every userland-side file. Switched it to -includeuser.h(forUSER_CFLAGS, of course - not for normal stuff), killed includes, got rid of shitloads ofkern_constants.hincludes at the same time. At which point getting rid ofkern_constants.hbecame 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
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/asmsymlink?
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.hmess is scary. I don't quite know why kvm on ia64 seems to do it's ownasm-offsets.hfile, 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