kbuild variable $(src) broken in 2.6.23-rc3?
Hi Sam, all
What are the chances $(src) variable might be broken in 2.6.26-rc3? With an external module I am seeing it getting expanded to "" (null string) while the same pretty straightforward Makefile works fine with 2.6.25.
Thanks,
Tvrtko
Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom.
Company Reg No 2096520. VAT Reg No GB 348 3873 20.
Quoted 5 lines · On Wed, May 21, 2008 at 03:42:03PM +0100, [email protected] wrote:
Hi Sam, all
What are the chances $(src) variable might be broken in 2.6.26-rc3? With an external module I am seeing it getting expanded to "" (null string) while the same pretty straightforward
Makefileworks fine with 2.6.25.
Andrea Arcangeli <[email protected]> reported a similar issue. I have not gotten around to look at it yet.
I minimal Makefile that exhibits the problem
would be helpfull!
Sam
Quoted 4 lines · Sam Ravnborg
Andrea Arcangeli <[email protected]> reported a similar issue. I have not gotten around to look at it yet.
I minimalMakefilethat exhibits the problem
would be helpfull!
I don't have the minimal but I can easily provide you a way to reproduce:
git clone git://git.kernel.org/pub/scm/virt/kvm/kvm-userspace.git
cd kvm-userspace
patch -p1 -R <../belowinlinedworkaround
./configure --kerneldir=/usr/src/anykernel
cd kernel
make
The below has the benefit of making more robust and higher prio the inclusion of external-module-compat so it may not to be backed out after this 2.6.26-rc regression is fixed.
The problem is that the $(src) in the EXTRA_CFLAGS below is expanded to "".
Thanks.
kernel/Kbuild +0 -1
@@ -1,4 +1,3 @@ -EXTRA_CFLAGS := -I$(src)/include -include $(src)/external-module-compat.h obj-m := kvm.o kvm-intel.o kvm-amd.o kvm-objs := kvm_main.o x86.o mmu.o x86_emulate.o anon_inodes.o irq.o i8259.o \ lapic.o ioapic.o preempt.o i8254.o external-module-compat.o
kernel/Makefile +2 -1
@@ -27,7 +27,8 @@ all:: # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat $(MAKE) -C $(KERNELDIR) M=`pwd` \ LINUXINCLUDE="-I`pwd`/include -Iinclude -I`pwd`/include-compat \ - -include include/linux/autoconf.h" \ + -include include/linux/autoconf.h \ + -include `pwd`/external-module-compat.h" "$$@" sync: header-sync source-sync
Quoted 16 lines · Andrea Arcangeli
Quoted 4 lines · Sam Ravnborg
Andrea Arcangeli <[email protected]> reported a similar issue. I have not gotten around to look at it yet.
I minimalMakefilethat exhibits the problem
would be helpfull!I don't have the minimal but I can easily provide you a way to reproduce:
git clone
git://git.kernel.org/pub/scm/virt/kvm/kvm-userspace.git
cd kvm-userspace
patch -p1 -R <../belowinlinedworkaround
./configure --kerneldir=/usr/src/anykernel
cd kernel
make
Quoted 6 lines
The below has the benefit of making more robust and higher prio the inclusion of external-module-compat so it may not to be backed out after this 2.6.26-rc regression is fixed.
The problem is that the $(src) in the
EXTRA_CFLAGSbelow is expanded to "".
I have now tried to reproduce this bug with no luck.
- I tried to clone the git tree and follow your instructions. But it failed to build due to some files missing in the kernel directory so I gace up on that.
- Then I tried to create a few Makefiles for an external module. I used a copy of the ext-2 filesystem and modifided the Makefile like below:
#
# Makefile for the linux ext2-filesystem routines. #
obj-m += ext2.o
ext2-y := balloc.o dir.o file.o fsync.o ialloc.o inode.o \
ioctl.o namei.o super.o symlink.o
EXTRA_CFLAGS := -I$(src)
Manually inspecting the command lines to gcc told me that $(src) was properly expanded.
So something more subtle is going on.
Can I ask you to in an empty directory to create
a Makefile like this:
obj-m := foo.o
ccflags-y := -I$(src)
Another question. Do you use a -mm or -next kernel. Or do you use a vanlla -linus kernel?
Because Andrew has some patches in -mm that may impact how we handle -I but I do not have -mm available on this box.
Sam
Quoted 46 lines · Sam Ravnborg
Quoted 16 lines · Andrea Arcangeli
Quoted 4 lines · Sam Ravnborg
Andrea Arcangeli <[email protected]> reported a similar issue. I have not gotten around to look at it yet.
I minimalMakefilethat exhibits the problem
would be helpfull!I don't have the minimal but I can easily provide you a way to reproduce:
git clone
git://git.kernel.org/pub/scm/virt/kvm/kvm-userspace.git
cd kvm-userspace
patch -p1 -R <../belowinlinedworkaround
./configure --kerneldir=/usr/src/anykernel
cd kernel
makeQuoted 6 lines
The below has the benefit of making more robust and higher prio the inclusion of external-module-compat so it may not to be backed out after this 2.6.26-rc regression is fixed.
The problem is that the $(src) in the
EXTRA_CFLAGSbelow is expanded to "".I have now tried to reproduce this bug with no luck.
- I tried to clone the git tree and follow your instructions. But it failed to build due to some files missing in the kernel directory so I gace up on that.
- Then I tried to create a few Makefiles for an external module. I used a copy of the ext-2 filesystem and modifided theMakefilelike below:
#
#Makefilefor the linux ext2-filesystem routines. #obj-m += ext2.o
ext2-y := balloc.o dir.o file.o fsync.o ialloc.o inode.o \
ioctl.o namei.o super.o symlink.o
EXTRA_CFLAGS:= -I$(src)Manually inspecting the command lines to gcc told me that $(src) was properly expanded.
Quoted 6 lines
So something more subtle is going on.
Can I ask you to in an empty directory to create
aMakefilelike this:
obj-m := foo.o
ccflags-y := -I$(src)
[Forgot the rest of the instructions...]
touch foo.c
and then run:
make -C path/to/kernelsrc/ M=pwd V=1
Inspect the gcc commandlien to see if the last -I
contains the expected value (which is pwd)
Sam
Quoted 2 lines · Sam Ravnborg
Inspect the gcc commandlien to see if the last -I
contains the expected value (which ispwd)
I can reproduce a failure, not sure if it's the same one but it ends up with -I. Actually on the good build it seems the -I wasn't there at all.
andrea@duo /tmp $ mkdir xx
andrea@duo /tmp $ cat x/Makefile
obj-m := foo.o
ccflags-y := -I$(src)
andrea@duo /tmp $ cat x/Makefile >xx/Makefile
andrea@duo /tmp $ touch xx/foo.c
andrea@duo /tmp $ cd xx
andrea@duo /tmp/xx $ make -C /home/andrea/kernel/linux-2.6-mmu M=pwd V=1
make: Entering directory `/crypto/home/andrea/devel/kernel/linux-2.6-mmu'
test -e include/linux/autoconf.h -a -e include/config/auto.conf || ( \
echo; \
echo " ERROR: Kernel configuration is invalid."; \
echo " include/linux/autoconf.h or include/config/auto.conf are missing."; \
echo " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
echo; \
/bin/false)mkdir -p /tmp/xx/.tmp_versions ; rm -f /tmp/xx/.tmp_versions/* make -f scripts/Makefile.build obj=/tmp/xx
rm -f /tmp/xx/built-in.o; ar rcs /tmp/xx/built-in.o
gcc -Wp,-MD,/tmp/xx/.foo.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include -D__KERNEL__ -Iinclude -include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -O2 -fno-stack-protector -m64 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Iinclude/asm-x86/mach-default -fomit-frame-pointer -Wdeclaration-after-statement -Wno-pointer-sign -I/tmp/xx -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(foo)" -D"KBUILD_MODNAME=KBUILD_STR(foo)" -c -o /tmp/xx/.tmp_foo.o /tmp/xx/foo.c
(cat /dev/null; echo kernel//tmp/xx/foo.ko;) > /tmp/xx/modules.order
Building modules, stage 2.
make -f /crypto/home/andrea/devel/kernel/linux-2.6-mmu/scripts/Makefile.modpost
scripts/mod/modpost -m -i /crypto/home/andrea/devel/kernel/linux-2.6-mmu/Module.symvers -I /tmp/xx/Module.symvers -o /tmp/xx/Module.symvers -S -w -s
gcc -Wp,-MD,/tmp/xx/.foo.mod.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include -D__KERNEL__ -Iinclude -include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -O2 -fno-stack-protector -m64 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Iinclude/asm-x86/mach-default -fomit-frame-pointer -Wdeclaration-after-statement -Wno-pointer-sign -I -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(foo.mod)" -D"KBUILD_MODNAME=KBUILD_STR(foo)" -DMODULE -c -o /tmp/xx/foo.mod.o /tmp/xx/foo.mod.c/tmp/xx/foo.mod.c:9: error: implicit declaration of function KBUILD_STR' /tmp/xx/foo.mod.c:9: error: foo' undeclared here (not in a function) /tmp/xx/foo.mod.c:9: warning: missing braces around initializer /tmp/xx/foo.mod.c:9: warning: (near initialization for __this_module.name') /tmp/xx/foo.mod.c:9: error: initializer element is not constant /tmp/xx/foo.mod.c:9: error: (near initialization for __this_module.name[0]') make[1]: *** [/tmp/xx/foo.mod.o] Error 1
make: *** [modules] Error 2
make: Leaving directory `/crypto/home/andrea/devel/kernel/linux-2.6-mmu'
Here the same but on a distro .24 kernel:
make: Entering directory `/usr/src/linux-2.6.24-gentoo-r8'
test -e include/linux/autoconf.h -a -e include/config/auto.conf || ( \
echo; \
echo " ERROR: Kernel configuration is invalid."; \
echo " include/linux/autoconf.h or include/config/auto.conf are missing."; \
echo " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
echo; \
/bin/false)mkdir -p /tmp/xx/.tmp_versions ; rm -f /tmp/xx/.tmp_versions/*
make -f scripts/Makefile.build obj=/tmp/xx
rm -f /tmp/xx/built-in.o; ar rcs /tmp/xx/built-in.o
gcc -Wp,-MD,/tmp/xx/.foo.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include -D__KERNEL__ -Iinclude -include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -O2 -m64 -mno-red-zone -mcmodel=kernel -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -funit-at-a-time -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -fomit-frame-pointer -g -fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign -I/tmp/xx -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(foo)" -D"KBUILD_MODNAME=KBUILD_STR(foo)" -c -o /tmp/xx/.tmp_foo.o /tmp/xx/foo.c
Building modules, stage 2.
make -f /usr/src/linux-2.6.24-gentoo-r8/scripts/Makefile.modpost
scripts/mod/modpost -m -i /usr/src/linux-2.6.24-gentoo-r8/Module.symvers -I /tmp/xx/Module.symvers -o /tmp/xx/Module.symvers -w -s
gcc -Wp,-MD,/tmp/xx/.foo.mod.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include -D__KERNEL__ -Iinclude -include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -O2 -m64 -mno-red-zone -mcmodel=kernel -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -funit-at-a-time -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -fomit-frame-pointer -g -fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(foo.mod)" -D"KBUILD_MODNAME=KBUILD_STR(foo)" -DMODULE -c -o /tmp/xx/foo.mod.o /tmp/xx/foo.mod.c
ld -r -m elf_x86_64 --build-id -o /tmp/xx/foo.ko /tmp/xx/foo.o /tmp/xx/foo.mod.o
make: Leaving directory `/usr/src/linux-2.6.24-gentoo-r8'
Quoted 7 lines · Andrea Arcangeli
Quoted 2 lines · Sam Ravnborg
Inspect the gcc commandlien to see if the last -I
contains the expected value (which ispwd)I can reproduce a failure, not sure if it's the same one but it ends up with -I. Actually on the good build it seems the -I wasn't there at all.
Now I see. So we suddenly started to include ccflags-y in the modpost build - which we did no do before.
I will look at it tomorrow.
Thanks,
Sam
Quoted 7 lines · Andrea Arcangeli
Quoted 2 lines · Sam Ravnborg
Inspect the gcc commandlien to see if the last -I
contains the expected value (which ispwd)I can reproduce a failure, not sure if it's the same one but it ends up with -I. Actually on the good build it seems the -I wasn't there at all.
I tracked it down now (a simple bisect would have doen the trick too). It was the introduction of KBUILD_EXTRA_SYMBOLS that caused us troubles because we started to include the Makefile
in Makefile.modpost and thus ccflags-y (EXTRA_CFLAGS) were assigned the value "-I$(src)" but $(src) was not defined so we ended up with an empty -I which then picked up the following parameter on the command line.
I cooked up the following fix:
scripts/Makefile.modpost +4 -0
@@ -37,6 +37,10 @@ # symbols in the final module linking stage # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. # This is solely usefull to speed up test compiles + +# Assign src as it may be used in ccflags-y +src = . + PHONY := _modpost _modpost: __modpost
Please let me know if this solves your problem or more issues reamin.
Sam
Sam Ravnborg <[email protected]> wrote on 29/05/2008 20:36:58:
Quoted 35 lines · Andrea Arcangeli
Quoted 7 lines · Sam Ravnborg
Quoted 2 lines
Inspect the gcc commandlien to see if the last -I
contains the expected value (which ispwd)I can reproduce a failure, not sure if it's the same one but it ends up with -I. Actually on the good build it seems the -I wasn't there at all.
I tracked it down now (a simple bisect would have doen the trick too). It was the introduction of
KBUILD_EXTRA_SYMBOLSthat caused us troubles because we started to include theMakefile
in Makefile.modpost and thus ccflags-y (EXTRA_CFLAGS) were assigned the value "-I$(src)" but $(src) was not defined so we ended up with an empty -I which then picked up the following parameter on the command line.I cooked up the following fix:
scripts/Makefile.modpost +4
-0@@ -37,6 +37,10 @@ # symbols in the final module linking stage # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. # This is solely usefull to speed up test compiles + +# Assign src as it may be used in ccflags-y +src = . + PHONY := _modpost _modpost: __modpost
Quoted 1 line
Please let me know if this solves your problem or more issues reamin.
For me this changes the output but $(src) is still wrong. Shouldn't it contain the thing passed in M ie. pwd?
Excerpts from make ... V=1 below.
2.6.26-rc3:
--------------------------------
Building modules, stage 2.
make -f /usr/src/linux-2.6.26-rc3/scripts/Makefile.modpost /root/talpa-0.9.46/Makefile:52: /src/app-ctrl/core/talpa-linux/common.mk:
No such file or directory
2.6.26-rc3 with the above patch:
--------------------------------
Building modules, stage 2.
make -f /usr/src/linux-2.6.26-rc3/scripts/Makefile.modpost /root/talpa-0.9.46/Makefile:52: src/app-ctrl/core/talpa-linux/common.mk:
No such file or directory
2.6.25:
--------------------------------
Building modules, stage 2.
make -f /usr/src/linux-2.6.25/scripts/Makefile.modpostscripts/mod/modpost -i /usr/src/linux-2.6.25/Module.symvers -I/root/2.6.25/talpa-0.9.46/Module.symvers -o/root/2.6.25/talpa-0.9.46/Module.symvers -S -w -s
Tvrtko
Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom.
Company Reg No 2096520. VAT Reg No GB 348 3873 20.
Quoted 24 lines · Sam Ravnborg
Quoted 7 lines · Andrea Arcangeli
Quoted 2 lines · Sam Ravnborg
Inspect the gcc commandlien to see if the last -I
contains the expected value (which ispwd)I can reproduce a failure, not sure if it's the same one but it ends up with -I. Actually on the good build it seems the -I wasn't there at all.
I tracked it down now (a simple bisect would have doen the trick too). It was the introduction of
KBUILD_EXTRA_SYMBOLSthat caused us troubles because we started to include theMakefile
in Makefile.modpost and thus ccflags-y (EXTRA_CFLAGS) were assigned the value "-I$(src)" but $(src) was not defined so we ended up with an empty -I which then picked up the following parameter on the command line.I cooked up the following fix:
scripts/Makefile.modpost +0
-0
scripts/Makefile.modpost line 46
Quoted 10 lines
scripts/Makefile.modpost +4
-0@@ -37,6 +37,10 @@ # symbols in the final module linking stage # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. # This is solely usefull to speed up test compiles + +# Assign src as it may be used in ccflags-y +src = . + PHONY := _modpost _modpost: __modpost
The module source is the src, so this fixes the build for KVM at least.
scripts/Makefile.modpost +4 -0
@@ -37,6 +37,10 @@ # symbols in the final module linking stage # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. # This is solely usefull to speed up test compiles + +# Assign src as it may be used in ccflags-y +src = $(KBUILD_EXTMOD) + PHONY := _modpost _modpost: __modpost
Andrea Arcangeli <[email protected]> wrote on 30/05/2008 13:41:11:
Quoted 11 lines · Sam Ravnborg
Quoted 10 lines
I tracked it down now (a simple bisect would have doen the trick too). It was the introduction of
KBUILD_EXTRA_SYMBOLSthat caused us troubles because we started to include theMakefile
in Makefile.modpost and thus ccflags-y (EXTRA_CFLAGS) were assigned the value "-I$(src)" but $(src) was not defined so we ended up with an empty -I which then picked up the following parameter on the command line.I cooked up the following fix:
Quoted 7 lines
scripts/Makefile.modpost line 38
Quoted 7 lines
scripts/Makefile.modpost +0
-0@@ -37,6 +37,10 @@ # symbols in the final module linking stage # KBUILD_MODPOST_NOFINAL can be set to skip the final link of
modules.
Quoted 17 lines
scripts/Makefile.modpost line 46
Quoted 8 lines
scripts/Makefile.modpost +4
-0# This is solely usefull to speed up test compiles + +# Assign src as it may be used in ccflags-y +src = . + PHONY := _modpost _modpost: __modpostThe module source is the src, so this fixes the build for KVM at least.
Signed-off-by Andrea Arcangeli <[email protected]>diff -r
d99f6640491escripts/Makefile.modpost
scripts/Makefile.modpost Fri May 30 14:40:16 2008 +0200 line 45
Quoted 9 lines
scripts/Makefile.modpost Fri May 30 14:40:16 2008 +0200 renamed from scripts/Makefile.modpost Tue May 20 18:19:45 2008 +0200 +4
-0@@ -37,6 +37,10 @@ # symbols in the final module linking stage # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. # This is solely usefull to speed up test compiles + +# Assign src as it may be used in ccflags-y +src = $(KBUILD_EXTMOD) + PHONY := _modpost _modpost: __modpost
This works for me as well.
Tvrtko
Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom.
Company Reg No 2096520. VAT Reg No GB 348 3873 20.
Rafael.
Can you add this to your regression list.
Handled by me.
Thanks,
Sam
Quoted 16 lines · On Wed, May 21, 2008 at 03:42:03PM +0100, [email protected] wrote:
Hi Sam, all
What are the chances $(src) variable might be broken in 2.6.26-rc3? With an external module I am seeing it getting expanded to "" (null string) while the same pretty straightforward
Makefileworks fine with 2.6.25.Thanks,
Tvrtko
Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom.
Company Reg No 2096520. VAT Reg No GB 348 3873 20.
Quoted 1 line · Sam Ravnborg
Rafael.
Hi,
Sorry for the late response.
Quoted 3 lines
Can you add this to your regression list.
Handled by me.
Added as http://bugzilla.kernel.org/show_bug.cgi?id=10798 .
Thanks,
Rafael
Quoted 19 lines · On Wed, May 21, 2008 at 03:42:03PM +0100, [email protected] wrote:
Quoted 16 lines
Hi Sam, all
What are the chances $(src) variable might be broken in 2.6.26-rc3? With an external module I am seeing it getting expanded to "" (null string) while the same pretty straightforward
Makefileworks fine with 2.6.25.Thanks,
Tvrtko
Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom.
Company Reg No 2096520. VAT Reg No GB 348 3873 20.
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth