Skip to contentSkip to conversation

Compile error: 2.4.15-pre4 (-tr) in kernel.o (cpu_init()) - advice req'd

DISCUSSION Ben Ryan 3 participants 5 messages Nov 13, 2001 – Nov 15, 2001

lore
Share & tools
lore

Ben Ryan

author
#0 lore raw

hey all

hope this doesn't turn out to be spurious traffic...

ia32/uniproc

linux-2.4.14.tar (kernel tar)
patch-2.4.15-pre4 (merge)
fix-2.4.15-pre4-tr.diff (benlahaise; don't mind the filename, i just
reckon calling the patch for the patch, patch-2.4.* is brokenness)

there is some weirdness on the box i'm compiling on; please check the following for obvious causes...
pre-compile make's worked fine, but the compile itself crashed out with:

arch/i386/kernel/kernel.o: In function 'cpu_init':
arch/i386/kernel/kernel.o(.text.init+0x27f9): undefined reference to 'cpucount' arch/i386/kernel/kernel.o(.text.init+0x2831): undefined reference to 'cpucount'

Can anyone spot if it's code or meatware related?? Thanx, I won't be able to sleep till I know what's going on :)

cheers
ben

Segment of kernel.o containing the offender:
================
* cpu_init() initializes state that is per-CPU. Some data is already
@@ -2815,14 +2817,15 @@
*/
void __init cpu_init (void)
{

-       int nr = smp_processor_id();
+       int nr = cpucount;
+       struct task_struct *cur = init_tasks[nr];
        struct tss_struct * t = &init_tss[nr];
 
        if (test_and_set_bit(nr, &cpu_initialized)) {
                printk(KERN_WARNING "CPU#%d already initialized!\n", nr);
                for (;;) __sti();
author
#1 lore raw

Uniprocessor Compile error: 2.4.15-pre4 (-tr) in kernel.o (cpu_init()) - Works with SMP

Quoted 14 lines

linux-2.4.14.tar (kernel tar)
patch-2.4.15-pre4 (merge)
fix-2.4.15-pre4-tr.diff (benlahaise; don't mind the filename, i just
reckon calling the patch for the patch, patch-2.4.* is brokenness)

arch/i386/kernel/kernel.o: In function 'cpu_init':
arch/i386/kernel/kernel.o(.text.init+0x27f9): undefined reference to 'cpucount' arch/i386/kernel/kernel.o(.text.init+0x2831): undefined reference to 'cpucount' Segment of kernel.o containing the offender:
================
* cpu_init() initializes state that is per-CPU. Some data is already

(quoted diff) +0 -0
@@ -2815,14 +2817,15 @@
  */

Review line 2826

Quoted 10 lines
(quoted diff) +2 -1
 void __init cpu_init (void)
 {
-       int nr = smp_processor_id();
+       int nr = cpucount;
+       struct task_struct *cur = init_tasks[nr];
        struct tss_struct * t = &init_tss[nr];
 
        if (test_and_set_bit(nr, &cpu_initialized)) {
                printk(KERN_WARNING "CPU#%d already initialized!\n", nr);
                for (;;) __sti();

SMP compile succeeded. (albeit with lots of warnings on 'pure')

It seems cpucount is only defined when SMP is compiled in, I guess cpucount hasn't been set to 1 in uniprocessor build, breaking non-smp builds? How can I hardcode that into setup.c? I know little of C, so if someone could point out a line of code to set this (diff even?) :)

#2 lore raw

Re: Uniprocessor Compile error: 2.4.15-pre4 (-tr) in kernel.o (cpu_init()) - Works with SMP

In reply to Ben Ryan

On Wed, Nov 14, 2001 at 07:44:59AM +1100, Ben Ryan wrote:
...

Quoted 1 line

SMP compile succeeded. (albeit with lots of warnings on 'pure')

Which version of gcc? 2.95? I guess the pure attribute needs to be made a compiler.h thing.

Quoted 4 lines

It seems cpucount is only defined when SMP is compiled in, I guess cpucount hasn't been set to 1 in uniprocessor build, breaking non-smp builds? How can I hardcode that into setup.c? I know little of C, so if someone could point out a line of code to set this (diff even?) :)

This will fix the link error by moving cpucount into setup.c. Cheers,

-ben

arch/i386/kernel/setup.c +1 -1
diff -ur tr-2.4.15-pre4/arch/i386/kernel/setup.c tr.prev/arch/i386/kernel/setup.c
@@ -2807,7 +2807,7 @@
 };
 
 unsigned long cpu_initialized __initdata = 0;
-int cpucount;
+extern int cpucount;
 
 /*
  * cpu_init() initializes state that is per-CPU. Some data is already
arch/i386/kernel/smpboot.c +1 -1
diff -ur tr-2.4.15-pre4/arch/i386/kernel/smpboot.c tr.prev/arch/i386/kernel/smpboot.c
@@ -443,7 +443,7 @@
 		synchronize_tsc_ap();
 }
 
-extern int cpucount;
+int cpucount;
 
 extern int cpu_idle(void);
 
#3 lore raw

Re: Uniprocessor Compile error: 2.4.15-pre4 (-tr) in kernel.o (cpu_init()) - Works with SMP

Quoted 1 line · Benjamin LaHaise

This will fix the link error by moving cpucount into setup.c.

Looks like the patch is reversed. Attached is a reversed version of the aforementioned reversed patch.

arch/i386/kernel/setup.c +1 -0
@@ -2806,6 +2807,7 @@
 };
 
 unsigned long cpu_initialized __initdata = 0;
+int cpucount;
 
 /*
  * cpu_init() initializes state that is per-CPU. Some data is already
arch/i386/kernel/smpboot.c +1 -1
@@ -443,7 +443,7 @@
 		synchronize_tsc_ap();
 }
 
-int cpucount;
+extern int cpucount;
 
 extern int cpu_idle(void);
 

Robert Love

#4 lore raw

Re: Uniprocessor Compile error: 2.4.15-pre4 (-tr) in kernel.o (cpu_init()) - Works with SMP

In reply to Benjamin LaHaise
Quoted 1 line · Ben Ryan

SMP compile succeeded. (albeit with lots of warnings on 'pure')

UP users of the patch will want to apply this, too:

include/asm-i386/current_asm.h +1 -1
diff -urN rattlesnake/include/asm-i386/current_asm.h  linux/include/asm-i386/current_asm.h 
@@ -7,7 +7,7 @@
 #include <linux/per_cpu.h>
 #include <asm/desc.h>
 
-#if 1 /*def CONFIG_SMP*/
+#ifdef CONFIG_SMP
 /* Pass in the long and short versions of the register.
  * eg GET_CURRENT(%ebx,%bx)
  * All of this braindamage comes to us c/o a bug in gas: the

Robert Love