Skip to contentSkip to conversation

compiling kernels with gcc-3.1

parisc-linux Randolph Chung 5 participants 17 messages Jul 12, 2002 – Jul 15, 2002

lore
Share & tools
lore
#0 lore raw

I seem to recall some reports that you cannot build a working kernel with gcc-3.1....

Well, maybe they've changed things upstream, but I just tried with gcc-3.1.1 (3.1.1 20020708 snapshot) and it seems to work well, at least with my limited testing... this is with the debian default 64-bit smp .config.

I did have to hack up a bunch of code... it seems like gcc-3.1.1 doesn't like this construct:

typedef struct {
        volatile unsigned int __attribute__((aligned(16))) lock;
} spinlock_t;
typedef struct {
        spinlock_t lock;
        volatile unsigned int count;
} rwlock_t;

rwlock_t foo = (rwlock_t) { (spinlock_t) { 1 }, 0 };

it complains that the initializer is not constant in this case. removing the (rwlock_t) cast fixed that....

also it doesn't like it when you have a variable and you initialize it after declaration with the { (spinlock_t) { 1 }, 0 } stuff...

(e.g.
rwlock_t foo;

foo = { (spinlock_t) { 1 }, 0 };

gives a "parse error at {" message)

after working through these problems i got a working kernel...

randolph

Signature · 3 lines
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
#1 lore raw

Hi Randolph,

I am on going to build mirroring on my test server.
But I will test it asap (as I already cvs update gcc-3.1.. ) and let you inform.

Thanks a lot for info,
Joel

PS: Can you do a telnet or an ssh connection when this kernel is running? IIRC as well as gcc-3.1 as gcc-3.2, I always reach well to build and boot kernels (without kdb) but the system crashes as soon as you try to connect it via the network.

Quoting Randolph Chung <[email protected]>:

Quoted 32 lines

I seem to recall some reports that you cannot build a working kernel with gcc-3.1....

Well, maybe they've changed things upstream, but I just tried with gcc-3.1.1 (3.1.1 20020708 snapshot) and it seems to work well, at least with my limited testing... this is with the debian default 64-bit smp .config.

I did have to hack up a bunch of code... it seems like gcc-3.1.1 doesn't
like this construct:

typedef struct {
        volatile unsigned int __attribute__((aligned(16))) lock;
} spinlock_t;
typedef struct {
        spinlock_t lock;
        volatile unsigned int count;
} rwlock_t;

rwlock_t foo = (rwlock_t) { (spinlock_t) { 1 }, 0 };

it complains that the initializer is not constant in this case. removing the (rwlock_t) cast fixed that....

also it doesn't like it when you have a variable and you initialize it after declaration with the { (spinlock_t) { 1 }, 0 } stuff...

(e.g.
rwlock_t foo;

Quoted 16 lines

foo = { (spinlock_t) { 1 }, 0 };

gives a "parse error at {" message)

after working through these problems i got a working kernel...

randolph

Signature · 7 lines
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

-------------------------------------------------
This mail sent through Tiscali Webmail (http://webmail.tiscali.be)

#2 lore raw
Quoted 4 lines

PS: Can you do a telnet or an ssh connection when this kernel is running? IIRC as well as gcc-3.1 as gcc-3.2, I always reach well to build and boot kernels (without kdb) but the system crashes as soon as you try to connect it via the network.

yes, i can ssh into the box.

randolph

Signature · 3 lines
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
#3 lore raw

Quoting Randolph Chung <[email protected]>:

Quoted 10 lines
Quoted 1 line

PS: Can you do a telnet or an ssh connection when this kernel is

running? IIRC

Quoted 1 line

as well as gcc-3.1 as gcc-3.2, I always reach well to build and boot

kernels

Quoted 1 line

(without kdb) but the system crashes as soon as you try to connect it

via the

Quoted 1 line

network.

yes, i can ssh into the box.

Great news, I am impatient to also test it :)

Thanks a lot,
Joel

-------------------------------------------------
This mail sent through Tiscali Webmail (http://webmail.tiscali.be)

#4 lore raw

Hi Randolph,

I am not so luky as you are:
The kernel compiles well and also boot well but always the same problem (in addition to modules problems) as soon as I do an network connection with ssh the system crash:
(I just note on the sti console)
sshd (pid 322): illegal instruction (code 8)
...
kernel panic...

Humm I try to boot from serial consol but there the behaviour is not quiet the same:
the system always panic but this time only a long list of:
Warning! stack pointer and cr30 do not correspond!
Dumping virtual address stack instead
Dumping satck from ... to ...:
....
(no stop or very very long?)

Well a last test (after I have to unplug replug power cable) at the serial console :

jso@palinux:~$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
RSA key fingerprint is ..:..:..:..:..:..:..:..:..:..:..:..:..:..:..:...
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
jso@localhost's password: 

and the system also crashes (whithout any messages?).

So may I believe that the problems come first from ip stack itself and not from ethernet driver?

Hmm I am also curious to test your .config file?

Joel

Quoting [email protected]:

Quoted 21 lines

Quoting Randolph Chung <[email protected]>:

Quoted 3 lines
Quoted 1 line

PS: Can you do a telnet or an ssh connection when this kernel is

running? IIRC

Quoted 1 line

as well as gcc-3.1 as gcc-3.2, I always reach well to build and

boot

Quoted 2 lines

kernels

Quoted 1 line

(without kdb) but the system crashes as soon as you try to connect

it

Quoted 5 lines

via the

Quoted 1 line

network.

yes, i can ssh into the box.

Great news, I am impatient to also test it :)

Thanks a lot,
Joel

Quoted 7 lines

-------------------------------------------------
This mail sent through Tiscali Webmail (http://webmail.tiscali.be)
_______________________________________________
parisc-linux mailing list [email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

-------------------------------------------------
This mail sent through Tiscali Webmail (http://webmail.tiscali.be)

#5 lore raw

Quoting [email protected]:

Quoted 33 lines

Hi Randolph,

I am not so luky as you are:
The kernel compiles well and also boot well but always the same problem (in
addition to modules problems) as soon as I do an network connection with ssh the
system crash:
(I just note on the sti console)
sshd (pid 322): illegal instruction (code 8)
...
kernel panic...

Humm I try to boot from serial consol but there the behaviour is not quiet the same:
the system always panic but this time only a long list of:
Warning! stack pointer and cr30 do not correspond! Dumping virtual address stack instead
Dumping satck from ... to ...:
....
(no stop or very very long?)

Well a last test (after I have to unplug replug power cable) at the serial
console :

jso@palinux:~$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
RSA key fingerprint is ..:..:..:..:..:..:..:..:..:..:..:..:..:..:..:...
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known
hosts.
jso@localhost's password: 
Quoted 8 lines

and the system also crashes (whithout any messages?).

So may I believe that the problems come first from ip stack itself and not from
ethernet driver?

Hmm I am also curious to test your .config file?

How do you build gcc (3.1.1) natively or as crosscompiler (I do the last may be it is the problem?)?

Joel

Quoted 5 lines

Quoting [email protected]:

Quoted 2 lines

Quoting Randolph Chung <[email protected]>:

Quoted 17 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

PS: Can you do a telnet or an ssh connection when this kernel is

running? IIRC

Quoted 1 line

as well as gcc-3.1 as gcc-3.2, I always reach well to build and

boot

Quoted 2 lines

kernels

Quoted 1 line

(without kdb) but the system crashes as soon as you try to

connect

Quoted 10 lines

it

Quoted 5 lines

via the

Quoted 1 line

network.

yes, i can ssh into the box.

Great news, I am impatient to also test it :)

Thanks a lot,
Joel

-------------------------------------------------
This mail sent through Tiscali Webmail (http://webmail.tiscali.be)

#6 lore raw
Quoted 1 line
Quoted 1 line

Hmm I am also curious to test your .config file?

i'm using the default config...

arch/parisc/debian-config/64-smp

Quoted 2 lines

How do you build gcc (3.1.1) natively or as crosscompiler (I do the last may be it is the problem?)?

cross-compiler, hppa-linux->hppa64-linux

randolph

Signature · 3 lines
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
#7 lore raw

Quoting Randolph Chung <[email protected]>:

Quoted 5 lines
Quoted 1 line
Quoted 1 line

Hmm I am also curious to test your .config file?

i'm using the default config...

arch/parisc/debian-config/64-smp

I will try (but I need to add md support now)

Quoted 6 lines
Quoted 2 lines

How do you build gcc (3.1.1) natively or as crosscompiler (I do the

last may be

Quoted 1 line

it is the problem?)?

cross-compiler, hppa-linux->hppa64-linux

I just do hppa-linux->hppa-linux?

So I will first change my config file and let you inform.

Thanks for info,
Joel

-------------------------------------------------
This mail sent through Tiscali Webmail (http://webmail.tiscali.be)

#8 lore raw
In reply to [email protected]
Quoted 4 lines

(I just note on the sti console)
sshd (pid 322): illegal instruction (code 8)
...
kernel panic...

This is just a guess but I will wager that this problem is related to the problems with expect, the cc1plus crash and the mmap issues noted elsewhere with SMP kernels. There seem to be circumstances where the kernel crashes when a user application traps unexpectedly.

Joel, you should be able to run sshd under gdb and find what the cause of the illegal instruction is. It should not be a problem to download and build 3.4p1 with gcc 3.2 from <http://www.openssh.org>.
Build at -O1 with debugging enabled. There are examples on their mail list on how to run sshd in debug mode. If the situation is similar to the cc1plus crash, gdb will prevent the system from crashing when the fault occurs.

Dave

Signature · 2 lines
J. David Anglin                                  [email protected]
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)
#9 lore raw

Quoting John David Anglin <[email protected]>:

Quoted 11 lines
Quoted 4 lines

(I just note on the sti console)
sshd (pid 322): illegal instruction (code 8)
...
kernel panic...

This is just a guess but I will wager that this problem is related to the problems with expect, the cc1plus crash and the mmap issues noted
elsewhere with SMP kernels. There seem to be circumstances where the kernel crashes when a user application traps unexpectedly.

Quoted 8 lines

Joel, you should be able to run sshd under gdb and find what the cause of the illegal instruction is. It should not be a problem to download and build 3.4p1 with gcc 3.2 from <http://www.openssh.org>.
Build at -O1 with debugging enabled. There are examples on their mail list on how to run sshd in debug mode. If the situation is similar to the cc1plus crash, gdb will prevent the system from crashing when the fault occurs.

Ok Dave,

I will have a look.

Thanks a lot,
Joel

-------------------------------------------------
This mail sent through Tiscali Webmail (http://webmail.tiscali.be)

#10 lore raw
In reply to John David Anglin
Quoted 4 lines

This is just a guess but I will wager that this problem is related to the problems with expect, the cc1plus crash and the mmap issues noted elsewhere with SMP kernels. There seem to be circumstances where the kernel crashes when a user application traps unexpectedly.

in at least some of the cases, i've seen one CPU is processing an unaligned trap for a kernel space insn. i don't see how the particular pieces of code that's causing the trap are unaligned tho (eg. search_exception_table).

One thing about the unaligned handler is that it wlil fail silently while handling "non-trivial" load/store insns. For example, it doesn't handle the ma/mb or m/sm completors for displacement/indexed load/stores.

It is possible that we haven't needed these in the past for kernel-space with gcc-3.0, but gcc-3.[12] have different optimizations that generate these instructions which we do not handle properly in unaligned cases. Although I think this may just be masking an underlying problem.

I'm working on a more complete unaligned handler to see if that makes a difference. Unfortunately I've found that sometimes when the kernel code is modified in trivial ways (adding printk's, etc) the behaviors become quite different. This definitely suggests some kind of cache flushing problem as Grant described elsewhere.

randolph

#11 lore raw
Quoted 9 lines

in at least some of the cases, i've seen one CPU is processing an unaligned trap for a kernel space insn. i don't see how the particular pieces of code that's causing the trap are unaligned tho (eg. search_exception_table).

One thing about the unaligned handler is that it wlil fail silently while handling "non-trivial" load/store insns. For example, it doesn't handle the ma/mb or m/sm completors for displacement/indexed load/stores.

Is --disable-indexing used in kernel builds? This should stop gcc from generating the above.

Dave

Signature · 2 lines
J. David Anglin                                  [email protected]
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)
#12 lore raw

Quoting John David Anglin <[email protected]>:

Quoted 3 lines

Is --disable-indexing used in kernel builds? This should stop gcc from generating the above.

AFAIK no (I will try tomorrow, I had to leave now :( )

Joel

-------------------------------------------------
This mail sent through Tiscali Webmail (http://webmail.tiscali.be)

#13 lore raw

Re: [parisc-linux] compiling kernels with gcc-3.2

In reply to Randolph Chung

well, after some advice from Dave about how to build gcc-3.2... i now have a gcc-3.2 compiled kernel working as well:

tausq@a500:~$ uname -a
Linux version 2.4.18-pa54 (tausq@a500) (gcc version 3.2 20020711 (experimental)) #2 SMP Fri Jul 12 22:04:23 PDT 2002
tausq@a500:~$

I'm quite perplexed about why it doesn't seem to always work for others... i didn't really have to do anything special with either gcc or the kernel to get it to boot.

randolph

Signature · 3 lines
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
#14 lore raw

Re: [parisc-linux] compiling kernels with gcc-3.2

Hi Randolph,

Quoted 3 lines · Randolph Chung

well, after some advice from Dave about how to build gcc-3.2... i now have a gcc-3.2 compiled kernel working as well:

Great ;) I will try also

Quoted 7 lines
tausq@a500:~$ uname -a
Linux version 2.4.18-pa54 (tausq@a500) (gcc version 3.2 20020711 (experimental)) #2 SMP Fri Jul 12 22:04:23 PDT 2002
tausq@a500:~$

I'm quite perplexed about why it doesn't seem to always work for others... i didn't really have to do anything special with either gcc or the kernel to get it to boot.

Well regarding release 3.2, I frequently encounter problems to compile gcc itself because of some broken part (it seems to me normal because it is the present development branch) for which I open PR which was solved in the mean time. And when I reach to compile gcc and the kernel, this was a problem with network connection which make crash the system.
So now if I can obtain an working kernel (as you) I would be able to continu to test other interesting thing.

Thanks a lot for info,
Joel

#15 lore raw

Re: [parisc-linux] compiling kernels with gcc-3.2

In reply to Randolph Chung
Quoted 10 lines
tausq@a500:~$ uname -a
Linux version 2.4.18-pa54 (tausq@a500) (gcc version 3.2 20020711 (experimental)) #2 SMP Fri Jul 12 22:04:23 PDT 2002
tausq@a500:~$

I'm quite perplexed about why it doesn't seem to always work for others... i didn't really have to do anything special with either gcc or the kernel to get it to boot.

randolph

I think the issue is one of quality assurance. We don't have a strict set of criteria for testing/validating/certifying that a given snapshot of a given toolchain, in a given configuration, will work.

I'm trying to address some of these things by building a cross-check test-suite to test the toolchain weekly or nightly. This all came out of a talk I had with Matt Taggart :) who is another toolchain-junkie.

When I get more work done I'll post.

c.

#16 lore raw
In reply to Randolph Chung

Hi Randolph,

Well I reach to compile gcc-3.1.1 without error (xc toolchain hppa -> hppa as gcc bootstrap).

Now I compile kernel 2.4.18-pa54 (last cvs I got Friday morning) for 32-bits config first (not 64-bits yet) and may be that is why I do not met the problem mentioned below

Quoted 24 lines

Well, maybe they've changed things upstream, but I just tried with gcc-3.1.1 (3.1.1 20020708 snapshot) and it seems to work well, at least with my limited testing... this is with the debian default 64-bit smp .config.

I did have to hack up a bunch of code... it seems like gcc-3.1.1 doesn't like this construct:

typedef struct {
        volatile unsigned int __attribute__((aligned(16))) lock;
} spinlock_t;
typedef struct {
        spinlock_t lock;
        volatile unsigned int count;
} rwlock_t;

rwlock_t foo = (rwlock_t) { (spinlock_t) { 1 }, 0 };

it complains that the initializer is not constant in this case. removing the (rwlock_t) cast fixed that....

also it doesn't like it when you have a variable and you initialize it after declaration with the { (spinlock_t) { 1 }, 0 } stuff...

Quoted 8 lines

(e.g. rwlock_t foo;

foo = { (spinlock_t) { 1 }, 0 };

gives a "parse error at {" message)

after working through these problems i got a working kernel...

OTC I met a strange problem with modules:

find kernel -path '*/pcmcia/*' -name '*.o' | xargs -i -r ln -sf ../{} pcmcia if [ -r System.map ]; then /sbin/depmod -ae -F System.map 2.4.18-pa54; fi

depmod: *** Unresolved symbols in /lib/modules/2.4.18-pa54/kernel/drivers/input/input.o
depmod:         mod_timer_R1f13d309
depmod:         unregister_chrdev_Rc192d491
depmod:         printk_Rdd132261
depmod:         jiffies_R0da02d67
depmod:         del_timer_Rfc62f16d
depmod:         register_chrdev_Rddc3984b
depmod:         sprintf_R1d26aa98
depmod:         try_inc_mod_count_R133c9d8f
depmod: *** Unresolved symbols in /lib/modules/2.4.18-pa54/kernel/drivers/input/keybdev.o
depmod:         kmalloc_R93d4cfe6

...

Any idea?

Thanks again for help and advises,
Joel

PS: I join my compile log just in case you notice other details