Bug 16510

Summary: LINUX_VERSION_CODE undefined in include/linux/version.h
Product: Other Reporter: jd1008
Component: ConfigurationAssignee: other_configuration (other_configuration)
Status: RESOLVED INVALID    
Severity: high CC: mmarek, ogerlitz, randy.dunlap
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.35 Subsystem:
Regression: No Bisected commit-id:
Attachments: Kernel configuration file

Description jd1008 2010-08-04 07:13:40 UTC
I had just run make oldconfig followed by make xconfig on linux-2.6.35.
During make, I got the following compilation error:

  CC      kernel/irq/autoprobe.o
kernel/power/snapshot.c: In function ‘init_header_complete’:
kernel/power/snapshot.c:1547: error: expected expression before ‘;’ token
kernel/power/snapshot.c: In function ‘check_image_kernel’:
kernel/power/snapshot.c:1553: error: expected expression before ‘)’ token
make[2]: *** [kernel/power/snapshot.o] Error 1
make[1]: *** [kernel/power] Error 2
make[1]: *** Waiting for unfinished jobs....

So, I looked at lines 1547  and  1553
and the problem was that LINUX_VERSION_CODE
was left undefined in include/linux/version.h

My .config file is attached.
Comment 1 jd1008 2010-08-04 07:15:47 UTC
Created attachment 27338 [details]
Kernel configuration file

My kernel configuration file (.config)
Comment 2 Randy Dunlap 2010-08-04 16:59:40 UTC
LINUX_VERSION_CODE is defined in a generated file.  Yes,
that file is include/linux/version.h.  What does that file
contain in your build tree?

I used your .config file and built the kernel in directory tt32,
so LINUX_VERSION_CODE is contained in tt32/include/linux/version.h:

> cat version.h 
#define LINUX_VERSION_CODE 132643
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
Comment 3 jd1008 2010-08-04 17:58:24 UTC
On my machine (after running make old config and then make xconfig):
$ cat ./include/linux/version.h
#define LINUX_VERSION_CODE
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

It does not seem to add the the value 132643
to the definition of LINUX_VERSION_CODE
So that is why the compilation failed.

I tried the 
mainline:  	2.6.35
and
stable: 	2.6.35

Same result.

Which script or executable is supposed to populate this header file
with the definition for LINUX_VERSION_CODE ?
Comment 4 Randy Dunlap 2010-08-04 18:20:39 UTC
It's generated in the top-level Makefile, at line 945 in 2.6.35:

define filechk_version.h
	(echo \#define LINUX_VERSION_CODE $(shell                             \
	expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL));     \
	echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
endef

include/linux/version.h: $(srctree)/Makefile FORCE
	$(call filechk,version.h)

Just guessing:  what shell are you using?
Maybe running make with V=1 (verbose) would give us more info also.
Comment 5 jd1008 2010-08-04 20:04:10 UTC
I use ksh - and I have been using ksh for many years.
I have NEVER had this problem before. I have been
building vanilla linux kernels from source tarballs
for at 10 years.

So I am not sure why that part of the Makefile is
not doing it's job in my case.
Is there a way to force make to echo every line of the Makefile
and every line of shell command and args it invokes?

I want to see exactly what is being stuffed into version.h.
Comment 6 Randy Dunlap 2010-08-04 20:08:46 UTC
Please try building (run 'make') with "V=1" on the command line.
You probably need to run "make clean" first.

Save the output and post it here and/or on the linux-kbuild@vger.kernel.org
mailing list so that other people can look/help.
Comment 7 Michal Marek 2010-08-05 10:00:18 UTC
Unrelated of the exact cause, we should probably just do

echo "#define LINUX_VERSION_CODE KERNEL_VERSION($(VERSION), $(PATCHLEVEL), $(SUBLEVEL))"

and let the compiler compute the bit shifts.
Comment 8 jd1008 2010-08-06 01:38:49 UTC
You are probably right - but I just hate such mysterious behavior of scripts and Makefiles - that for 4 or 5 times, produced the same error, and then on a subsequent try of untarring and ... etc, the build proceeds without errors.

That said, I see other problems unrelated to scripts, but more to
compiler and linker warning about various things.

I should probably open another bug about that.

Cheers,

JD
Comment 9 jd1008 2011-01-18 21:48:35 UTC
After a long time, I can reproduce the
problem - and it is caused my my own error.
I had edited Makefile and set
SUBLEVEL = 35-1

and that is the cause of the error
during make.

Please close as user error.
Comment 10 Or Gerlitz 2011-01-20 10:34:26 UTC
oh yeh, this was my mistake as well, I wanted to change the kernel version
and added something for sublevel instread of extraversion, thanks for pointing this out!