* [Patch] make 2.4 compile with GCC-3.4.3...
@ 2004-12-03 3:14 David Daney
2004-12-03 4:55 ` Thiemo Seufer
0 siblings, 1 reply; 6+ messages in thread
From: David Daney @ 2004-12-03 3:14 UTC (permalink / raw)
To: linux-mips
[-- Attachment #1: Type: text/plain, Size: 828 bytes --]
I just upgraded to the most recent 2.4.29-pre1 sources from the CVS archive
with the intent of being able to compile with gcc-3.4.3.
It turns out that the compiler is splitting:
save_static_function(sys_fork);
static_unused int _sys_fork(struct pt_regs regs)
The result being an unusable kernel.
I think that this issue has been discussed before, but I couldn't find the
solution in the mail group. So I applied this small hack. The
modifications to syscall.c and signal.c may not be necessary, but I
borrowed them from the 2.6 tree in hopes of fixing the problem and then
moved to the Makefile change.
It may be that only the Makefile change is necessary (I suspect so), but I
have not tried it alone.
The CVS versions in the diff are from my local cvs and do not correspond to
the linux-mips.org CVS.
David Daney.
[-- Attachment #2: uat.d --]
[-- Type: text/plain, Size: 3592 bytes --]
Index: kernel/Makefile
===================================================================
RCS file: /linux/linux/arch/mips/kernel/Makefile,v
retrieving revision 1.2
diff -c -p -r1.2 Makefile
*** kernel/Makefile 2 Dec 2004 19:50:05 -0000 1.2
--- kernel/Makefile 3 Dec 2004 03:00:44 -0000
*************** obj-y += branch.o cpu-probe.o irq.o pro
*** 18,23 ****
--- 18,27 ----
traps.o ptrace.o reset.o semaphore.o setup.o syscall.o \
sysmips.o ipc.o scall_o32.o time.o unaligned.o
+ check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi)
+
+ syscall.o signal.o : override CFLAGS += $(call check_gcc, -fno-unit-at-a-time,)
+
obj-$(CONFIG_MODULES) += mips_ksyms.o
obj-$(CONFIG_CPU_R3000) += r2300_fpu.o r2300_switch.o
Index: kernel/signal.c
===================================================================
RCS file: /linux/linux/arch/mips/kernel/signal.c,v
retrieving revision 1.1.1.2
diff -c -p -r1.1.1.2 signal.c
*** kernel/signal.c 1 Dec 2004 21:50:39 -0000 1.1.1.2
--- kernel/signal.c 3 Dec 2004 03:00:44 -0000
***************
*** 18,23 ****
--- 18,24 ----
#include <linux/errno.h>
#include <linux/wait.h>
#include <linux/unistd.h>
+ #include <linux/compiler.h>
#include <asm/asm.h>
#include <asm/bitops.h>
*************** int copy_siginfo_to_user(siginfo_t *to,
*** 76,82 ****
* Atomically swap in the new signal mask, and wait for a signal.
*/
save_static_function(sys_sigsuspend);
! static_unused int _sys_sigsuspend(struct pt_regs regs)
{
sigset_t *uset, saveset, newset;
--- 77,84 ----
* Atomically swap in the new signal mask, and wait for a signal.
*/
save_static_function(sys_sigsuspend);
! __attribute_used__ static int
! _sys_sigsuspend(struct pt_regs regs)
{
sigset_t *uset, saveset, newset;
*************** static_unused int _sys_sigsuspend(struct
*** 102,108 ****
}
save_static_function(sys_rt_sigsuspend);
! static_unused int _sys_rt_sigsuspend(struct pt_regs regs)
{
sigset_t *unewset, saveset, newset;
size_t sigsetsize;
--- 104,111 ----
}
save_static_function(sys_rt_sigsuspend);
! __attribute_used__ static int
! _sys_rt_sigsuspend(struct pt_regs regs)
{
sigset_t *unewset, saveset, newset;
size_t sigsetsize;
Index: kernel/syscall.c
===================================================================
RCS file: /linux/linux/arch/mips/kernel/syscall.c,v
retrieving revision 1.1.1.2
diff -c -p -r1.1.1.2 syscall.c
*** kernel/syscall.c 1 Dec 2004 21:50:39 -0000 1.1.1.2
--- kernel/syscall.c 3 Dec 2004 03:00:44 -0000
***************
*** 25,30 ****
--- 25,31 ----
#include <linux/slab.h>
#include <linux/utsname.h>
#include <linux/unistd.h>
+ #include <linux/compiler.h>
#include <asm/branch.h>
#include <asm/offset.h>
#include <asm/ptrace.h>
*************** sys_mmap2(unsigned long addr, unsigned l
*** 158,164 ****
}
save_static_function(sys_fork);
! static_unused int _sys_fork(struct pt_regs regs)
{
int res;
--- 159,166 ----
}
save_static_function(sys_fork);
! __attribute_used__ static int
! _sys_fork(struct pt_regs regs)
{
int res;
*************** static_unused int _sys_fork(struct pt_re
*** 168,174 ****
save_static_function(sys_clone);
! static_unused int _sys_clone(struct pt_regs regs)
{
unsigned long clone_flags;
unsigned long newsp;
--- 170,177 ----
save_static_function(sys_clone);
! __attribute_used__ static int
! _sys_clone(struct pt_regs regs)
{
unsigned long clone_flags;
unsigned long newsp;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] make 2.4 compile with GCC-3.4.3...
2004-12-03 3:14 [Patch] make 2.4 compile with GCC-3.4.3 David Daney
@ 2004-12-03 4:55 ` Thiemo Seufer
0 siblings, 0 replies; 6+ messages in thread
From: Thiemo Seufer @ 2004-12-03 4:55 UTC (permalink / raw)
To: David Daney; +Cc: linux-mips
David Daney wrote:
[snip]
> *** kernel/Makefile 2 Dec 2004 19:50:05 -0000 1.2
> --- kernel/Makefile 3 Dec 2004 03:00:44 -0000
> *************** obj-y += branch.o cpu-probe.o irq.o pro
> *** 18,23 ****
> --- 18,27 ----
> traps.o ptrace.o reset.o semaphore.o setup.o syscall.o \
> sysmips.o ipc.o scall_o32.o time.o unaligned.o
>
> + check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi)
> +
> + syscall.o signal.o : override CFLAGS += $(call check_gcc, -fno-unit-at-a-time,)
What difference does this cause?
[snip]
> --- 77,84 ----
> * Atomically swap in the new signal mask, and wait for a signal.
> */
> save_static_function(sys_sigsuspend);
> ! __attribute_used__ static int
> ! _sys_sigsuspend(struct pt_regs regs)
These should also use "noinline", like 2.6.
Thiemo
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [Patch] make 2.4 compile with GCC-3.4.3...
@ 2004-12-03 6:20 ` David Daney
0 siblings, 0 replies; 6+ messages in thread
From: David Daney @ 2004-12-03 6:20 UTC (permalink / raw)
To: Thiemo Seufer; +Cc: linux-mips
Thiemo Seufer wrote:
>David Daney wrote:
>[snip]
>> *** kernel/Makefile 2 Dec 2004 19:50:05 -0000 1.2
>> --- kernel/Makefile 3 Dec 2004 03:00:44 -0000
>> *************** obj-y += branch.o cpu-probe.o irq.o pro
>> *** 18,23 ****
>> --- 18,27 ----
>> traps.o ptrace.o reset.o semaphore.o setup.o syscall.o \
>> sysmips.o ipc.o scall_o32.o time.o unaligned.o
>>
>> + check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi)
>> +
>> + syscall.o signal.o : override CFLAGS += $(call check_gcc, -fno-unit-at-a-time,)
>
>What difference does this cause?
It causes -fno-unit-at-a-time to be added to CFLAGS when compiling
syscall.c and signal.c. All other files are compiled with the "normal" CFLAGS.
-fno-unit-at-a-time prevents GCC from rearranging things in its output thus preventing
the save_static_function() from being separated from its companion. As far as I could tell
only syscall.c and signal.c need this.
One small issue is that these two files now seem to get recompiled with each
make invocation. But that is better than being miscompiled.
I am not sure if check_gcc is inherited from the higher level makefile so I put it in this one
as well. If you think it is a good approach I will try to simplify the patch a little.
>[snip]
>> --- 77,84 ----
>> * Atomically swap in the new signal mask, and wait for a signal.
>> */
>> save_static_function(sys_sigsuspend);
>> ! __attribute_used__ static int
>> ! _sys_sigsuspend(struct pt_regs regs)
>
>These should also use "noinline", like 2.6.
noinline was not defined for me :( so I removed it. It seems that in 2.6 it is
just #defined to be nothing. The alternative is to add:
#ifndef noinline
#define noinline
#endif
to compiler.h as is done in 2.6
David Daney.
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [Patch] make 2.4 compile with GCC-3.4.3...
@ 2004-12-03 6:20 ` David Daney
0 siblings, 0 replies; 6+ messages in thread
From: David Daney @ 2004-12-03 6:20 UTC (permalink / raw)
To: Thiemo Seufer; +Cc: linux-mips
Thiemo Seufer wrote:
>David Daney wrote:
>[snip]
>> *** kernel/Makefile 2 Dec 2004 19:50:05 -0000 1.2
>> --- kernel/Makefile 3 Dec 2004 03:00:44 -0000
>> *************** obj-y += branch.o cpu-probe.o irq.o pro
>> *** 18,23 ****
>> --- 18,27 ----
>> traps.o ptrace.o reset.o semaphore.o setup.o syscall.o \
>> sysmips.o ipc.o scall_o32.o time.o unaligned.o
>>
>> + check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi)
>> +
>> + syscall.o signal.o : override CFLAGS += $(call check_gcc, -fno-unit-at-a-time,)
>
>What difference does this cause?
It causes -fno-unit-at-a-time to be added to CFLAGS when compiling
syscall.c and signal.c. All other files are compiled with the "normal" CFLAGS.
-fno-unit-at-a-time prevents GCC from rearranging things in its output thus preventing
the save_static_function() from being separated from its companion. As far as I could tell
only syscall.c and signal.c need this.
One small issue is that these two files now seem to get recompiled with each
make invocation. But that is better than being miscompiled.
I am not sure if check_gcc is inherited from the higher level makefile so I put it in this one
as well. If you think it is a good approach I will try to simplify the patch a little.
>[snip]
>> --- 77,84 ----
>> * Atomically swap in the new signal mask, and wait for a signal.
>> */
>> save_static_function(sys_sigsuspend);
>> ! __attribute_used__ static int
>> ! _sys_sigsuspend(struct pt_regs regs)
>
>These should also use "noinline", like 2.6.
noinline was not defined for me :( so I removed it. It seems that in 2.6 it is
just #defined to be nothing. The alternative is to add:
#ifndef noinline
#define noinline
#endif
to compiler.h as is done in 2.6
David Daney.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] make 2.4 compile with GCC-3.4.3...
2004-12-03 6:20 ` David Daney
(?)
@ 2004-12-03 6:40 ` Thiemo Seufer
2004-12-03 13:50 ` Maciej W. Rozycki
-1 siblings, 1 reply; 6+ messages in thread
From: Thiemo Seufer @ 2004-12-03 6:40 UTC (permalink / raw)
To: David Daney; +Cc: linux-mips
David Daney wrote:
[snip]
> -fno-unit-at-a-time prevents GCC from rearranging things in its output thus preventing
> the save_static_function() from being separated from its companion. As far as I could tell
> only syscall.c and signal.c need this.
Ah, I missed that. It's probably better to use the same way as in 2.6,
that is, to add a jump at the end of save_static_function().
> noinline was not defined for me :( so I removed it. It seems that in 2.6 it is
> just #defined to be nothing. The alternative is to add:
>
> #ifndef noinline
> #define noinline
> #endif
>
> to compiler.h as is done in 2.6
Yes, that's the better idea. gcc-4.0 ff may need it.
Thiemo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] make 2.4 compile with GCC-3.4.3...
2004-12-03 6:40 ` Thiemo Seufer
@ 2004-12-03 13:50 ` Maciej W. Rozycki
0 siblings, 0 replies; 6+ messages in thread
From: Maciej W. Rozycki @ 2004-12-03 13:50 UTC (permalink / raw)
To: Thiemo Seufer; +Cc: David Daney, linux-mips
On Fri, 3 Dec 2004, Thiemo Seufer wrote:
> > -fno-unit-at-a-time prevents GCC from rearranging things in its output thus preventing
> > the save_static_function() from being separated from its companion. As far as I could tell
> > only syscall.c and signal.c need this.
>
> Ah, I missed that. It's probably better to use the same way as in 2.6,
> that is, to add a jump at the end of save_static_function().
Note, that I've send a patch for this twice already. Still no approval,
though, for whatever (unstated) reason.
> > noinline was not defined for me :( so I removed it. It seems that in 2.6 it is
> > just #defined to be nothing. The alternative is to add:
> >
> > #ifndef noinline
> > #define noinline
> > #endif
> >
> > to compiler.h as is done in 2.6
>
> Yes, that's the better idea. gcc-4.0 ff may need it.
I'll update the patch accordingly and resend.
Maciej
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-12-03 13:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-03 3:14 [Patch] make 2.4 compile with GCC-3.4.3 David Daney
2004-12-03 4:55 ` Thiemo Seufer
-- strict thread matches above, loose matches on Subject: below --
2004-12-03 6:20 David Daney
2004-12-03 6:20 ` David Daney
2004-12-03 6:40 ` Thiemo Seufer
2004-12-03 13:50 ` Maciej W. Rozycki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.