2001-11-12 19:40:54

by Daniel I. Applebaum

[permalink] [raw]
Subject: 2.4.15-pre4 compile problem


While compiling 2.4.15-pre4:
+++++++++++++++
gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=i686 -c -o setup.o setup.c
setup.c: In function `c_start':
setup.c:2791: subscripted value is neither array nor pointer
setup.c:2792: warning: control reaches end of non-void function
gmake[1]: *** [setup.o] Error 1
gmake[1]: Leaving directory `/usr/src/linux/arch/i386/kernel'
gmake: *** [_dir_arch/i386/kernel] Error 2
+++++++++++++++++

Here's the block of code:
+++++++++++++++++
static void *c_start(struct seq_file *m, loff_t *pos)
{
return *pos < NR_CPUS ? &cpu_data[*pos] : NULL;
}
+++++++++++++++++

Note that I'm compiling a non-SMP kernel.

Do I have to generate my .config from scatch each time, or can I copy
2.4.14/.config to 2.4.15-pre4/.config and run 'gmake menuconfig'?
(I've been doing the latter.)

Dan.


2001-11-12 20:23:39

by Daniel I. Applebaum

[permalink] [raw]
Subject: Re: 2.4.15-pre4 compile problem


Thanks to all for the pointers about "make oldconfig" I tried that,
and it didn't make any difference.

I just compiled with SMP enabled and the compile succeeds. So, there
seems to be some problem with a uniprocessor compile.

Dan.
(Wishing I did have a quad 1.8GHz machine so these compiles wouldn't
take so frelling long.)

2001-11-12 20:31:59

by Linus Torvalds

[permalink] [raw]
Subject: Re: 2.4.15-pre4 compile problem

In article <[email protected]>,
Daniel I. Applebaum <[email protected]> wrote:
>
>While compiling 2.4.15-pre4:
>+++++++++++++++
>gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=i686 -c -o setup.o setup.c
>setup.c: In function `c_start':
>setup.c:2791: subscripted value is neither array nor pointer

Ugh. That's because a buggy #define on UP in x86.

It should be trivially fixed by changing include/asm-i386/processor.h:

#define cpu_data &boot_cpu_data

to

#define cpu_data (&boot_cpu_data)

in order to get the right parsing order for all users of cpu_data. Ie
just add the parenthesis around the thing.

Oh, well. "Always put parentesis around define-expands" is a really
really good rule. Along with "Always put parenthesis around the
argument expansion too".

Oh, and cleaning up the particular offending user will hide the problem
too, if you just use

cpu_data+*pos

instead of using

&cpu_data[*pos]

in arch/i386/kernel/setup.c: c_start(). Which is cleaner and simpler
anyway, and which is defined by C to be exactly the same thing (as long
as "cpu_data" behaves like a real array, not a broken #define that
depends on operator precedence around it).

I'll do both in my tree. Thanks,

Linus

2001-11-12 20:33:49

by Slo Mo Snail

[permalink] [raw]
Subject: Re: 2.4.15-pre4 compile problem

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi
Am Montag, 12. November 2001 20:39 schrieb Daniel I. Applebaum:
> While compiling 2.4.15-pre4:
> +++++++++++++++
> gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes
> -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common
> -pipe -mpreferred-stack-boundary=2 -march=i686 -c -o setup.o setup.c
> setup.c: In function `c_start':
> setup.c:2791: subscripted value is neither array nor pointer
> setup.c:2792: warning: control reaches end of non-void function
> gmake[1]: *** [setup.o] Error 1
> gmake[1]: Leaving directory `/usr/src/linux/arch/i386/kernel'
> gmake: *** [_dir_arch/i386/kernel] Error 2
> +++++++++++++++++
I have exactly the same problem...
Strange, that nobody else has reported it, yet ;)
I use gcc-2.95.3 and binutils 2.11.92.0.7 on a LFS
I'll send you my .config but I don't think it's a config-specific problem

> Do I have to generate my .config from scatch each time, or can I copy
> 2.4.14/.config to 2.4.15-pre4/.config and run 'gmake menuconfig'?
> (I've been doing the latter.)

I think this should work but it's better when you copy you .config and run a
make oldconfig in the new kernel tree to avoid errors
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE78DJfvIHrJes3kVIRApLEAJ9/p3nhPxL7Hc5jFBDmdQX2iMM8xgCeOx/w
sIpKyjuFaAJ13ZXeYsYglbA=
=Hecv
-----END PGP SIGNATURE-----


Attachments:
.config (19.36 kB)

2001-11-12 20:41:49

by Wayne.Brown

[permalink] [raw]
Subject: Re: 2.4.15-pre4 compile problem



Try this patch (it works for me):

--- ./arch/i386/kernel/setup.c Mon Nov 12 14:16:11 2001
+++ ./arch/i386/kernel/setup.c.fixed Mon Nov 12 14:19:54 2001
@@ -2788,7 +2788,7 @@

static void *c_start(struct seq_file *m, loff_t *pos)
{
- return *pos < NR_CPUS ? &cpu_data[*pos] : NULL;
+ return *pos < NR_CPUS ? &(cpu_data)[*pos] : NULL;
}
static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{







"Daniel I. Applebaum" <[email protected]> on 11/12/2001 01:39:33 PM

To: [email protected]
cc: (bcc: Wayne Brown/Corporate/Altec)

Subject: 2.4.15-pre4 compile problem




While compiling 2.4.15-pre4:
+++++++++++++++
gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes
-Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe
-mpreferred-stack-boundary=2 -march=i686 -c -o setup.o setup.c
setup.c: In function `c_start':
setup.c:2791: subscripted value is neither array nor pointer
setup.c:2792: warning: control reaches end of non-void function
gmake[1]: *** [setup.o] Error 1
gmake[1]: Leaving directory `/usr/src/linux/arch/i386/kernel'
gmake: *** [_dir_arch/i386/kernel] Error 2
+++++++++++++++++

Here's the block of code:
+++++++++++++++++
static void *c_start(struct seq_file *m, loff_t *pos)
{
return *pos < NR_CPUS ? &cpu_data[*pos] : NULL;
}
+++++++++++++++++

Note that I'm compiling a non-SMP kernel.

Do I have to generate my .config from scatch each time, or can I copy
2.4.14/.config to 2.4.15-pre4/.config and run 'gmake menuconfig'?
(I've been doing the latter.)

Dan.

2001-11-12 20:45:49

by Robert Love

[permalink] [raw]
Subject: Re: 2.4.15-pre4 compile problem

On Mon, 2001-11-12 at 15:34, Slo Mo Snail wrote:
> I have exactly the same problem...
> Strange, that nobody else has reported it, yet ;)
> I use gcc-2.95.3 and binutils 2.11.92.0.7 on a LFS
> I'll send you my .config but I don't think it's a config-specific problem

The patch below will solve the problem ...

diff -u linux-2.4.15-pre4/include/asm-i386/processor.h linux/include/asm-i386/processor.h
--- linux-2.4.15-pre4/include/asm-i386/processor.h Mon Nov 12 15:17:47 2001+++ linux/include/asm-i386/processor.h Mon Nov 12 15:40:32 2001
@@ -76,7 +76,7 @@
extern struct cpuinfo_x86 cpu_data[];
#define current_cpu_data cpu_data[smp_processor_id()]
#else
-#define cpu_data &boot_cpu_data
+#define cpu_data (&boot_cpu_data)
#define current_cpu_data boot_cpu_data
#endif

Robert Love