mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [2.6 patch] Use -ffreestanding? (fwd)
@ 2004-11-22  5:49 Adrian Bunk
  2004-11-22  6:10 ` Linus Torvalds
  2004-11-22  8:36 ` Jan Engelhardt
  0 siblings, 2 replies; 5+ messages in thread
From: Adrian Bunk @ 2004-11-22  5:49 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linus Torvalds, linux-kernel

Hi Andrew,

for the kernel, it would be logical to use -ffreestanding. The kernel is 
not a hosted environment with a standard C library.

Linus agreed that it would make sense.

The gcc option -ffreestanding is supported by both gcc 2.95 and 3.4, 
which covers the whole range of currently supported compilers.

Could you add the patch below to the next -mm to see whether there are 
any problems I didn't find?

TIA
Adrian



Signed-off-by: Adrian Bunk <bunk@stusta.de>

--- linux-2.6.10-rc1-mm4-full-ffreestanding/Makefile.old	2004-11-09 22:27:06.000000000 +0100
+++ linux-2.6.10-rc1-mm4-full-ffreestanding/Makefile	2004-11-09 22:27:47.000000000 +0100
@@ -349,7 +349,8 @@
 CPPFLAGS        := -D__KERNEL__ $(LINUXINCLUDE)
 
 CFLAGS 		:= -Wall -Wstrict-prototypes -Wno-trigraphs \
-	  	   -fno-strict-aliasing -fno-common
+	  	   -fno-strict-aliasing -fno-common \
+		   -ffreestanding
 AFLAGS		:= -D__ASSEMBLY__
 
 export	VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION LOCALVERSION KERNELRELEASE \




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [2.6 patch] Use -ffreestanding? (fwd)
  2004-11-22  5:49 [2.6 patch] Use -ffreestanding? (fwd) Adrian Bunk
@ 2004-11-22  6:10 ` Linus Torvalds
  2004-11-22 12:46   ` Adrian Bunk
  2004-11-22  8:36 ` Jan Engelhardt
  1 sibling, 1 reply; 5+ messages in thread
From: Linus Torvalds @ 2004-11-22  6:10 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: Andrew Morton, linux-kernel



On Mon, 22 Nov 2004, Adrian Bunk wrote:
> 
> for the kernel, it would be logical to use -ffreestanding. The kernel is 
> not a hosted environment with a standard C library.
> 
> Linus agreed that it would make sense.

Note that while I agree that it sounds sensible, it would be good to have 
somebody specify exactly what changes from the use of "-ffreestanding".

I _assume_ that all the things that gcc takes for granted are things that 
Linux already has its own definitions for, and that -ffreestanding doesn't 
actually change anything for at least the regular architectures. But if 
there is any object code changes, can you check those out and explain 
them?

		Linus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [2.6 patch] Use -ffreestanding? (fwd)
  2004-11-22  5:49 [2.6 patch] Use -ffreestanding? (fwd) Adrian Bunk
  2004-11-22  6:10 ` Linus Torvalds
@ 2004-11-22  8:36 ` Jan Engelhardt
  2004-11-22 12:48   ` Adrian Bunk
  1 sibling, 1 reply; 5+ messages in thread
From: Jan Engelhardt @ 2004-11-22  8:36 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: Andrew Morton, Linus Torvalds, linux-kernel

>Hi Andrew,
>
>for the kernel, it would be logical to use -ffreestanding. The kernel is
>not a hosted environment with a standard C library.

Note the GCC docs:

Assert that compilation takes place in a freestanding environment. This
implies -fno-builtin. [...]

This will break a lot of code, since there are many thing that depend upon GCC
builtin magic AFAICS.

(BTW, seems to be supported by GCC 3.3.0 too, because that manpage is packaged
together with gcc-3.3.rpm (suse 9.x))



Jan Engelhardt
-- 
Gesellschaft für Wissenschaftliche Datenverarbeitung
Am Fassberg, 37077 Göttingen, www.gwdg.de

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [2.6 patch] Use -ffreestanding? (fwd)
  2004-11-22  6:10 ` Linus Torvalds
@ 2004-11-22 12:46   ` Adrian Bunk
  0 siblings, 0 replies; 5+ messages in thread
From: Adrian Bunk @ 2004-11-22 12:46 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, linux-kernel

On Sun, Nov 21, 2004 at 10:10:28PM -0800, Linus Torvalds wrote:
> 
> 
> On Mon, 22 Nov 2004, Adrian Bunk wrote:
> > 
> > for the kernel, it would be logical to use -ffreestanding. The kernel is 
> > not a hosted environment with a standard C library.
> > 
> > Linus agreed that it would make sense.
> 
> Note that while I agree that it sounds sensible, it would be good to have 
> somebody specify exactly what changes from the use of "-ffreestanding".
> 
> I _assume_ that all the things that gcc takes for granted are things that 
> Linux already has its own definitions for, and that -ffreestanding doesn't 
> actually change anything for at least the regular architectures. But if 
> there is any object code changes, can you check those out and explain 
> them?

Andi Kleen reported:
  Newer gcc rewrites sprintf(buf,"%s",str) to strcpy(buf,str) transparently.

This is only true with unit-at-a-time (disabled on i386 but enabled
on x86_64). The Linux kernel doesn't offer a standard C library, and 
such transparent replacements of kernel functions with builtins are 
quite fragile.

Even with -ffreestanding, it's still possilble to explicitely use a gcc 
builtin if desired.

> 		Linus

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [2.6 patch] Use -ffreestanding? (fwd)
  2004-11-22  8:36 ` Jan Engelhardt
@ 2004-11-22 12:48   ` Adrian Bunk
  0 siblings, 0 replies; 5+ messages in thread
From: Adrian Bunk @ 2004-11-22 12:48 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Andrew Morton, Linus Torvalds, linux-kernel

On Mon, Nov 22, 2004 at 09:36:15AM +0100, Jan Engelhardt wrote:
> >Hi Andrew,
> >
> >for the kernel, it would be logical to use -ffreestanding. The kernel is
> >not a hosted environment with a standard C library.
> 
> Note the GCC docs:
> 
> Assert that compilation takes place in a freestanding environment. This
> implies -fno-builtin. [...]
> 
> This will break a lot of code, since there are many thing that depend upon GCC
> builtin magic AFAICS.
>...

Which code in the kernel is broken by this change?

Note that explicitely using a gcc builtin is still possible.

> Jan Engelhardt

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-11-22 12:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-22  5:49 [2.6 patch] Use -ffreestanding? (fwd) Adrian Bunk
2004-11-22  6:10 ` Linus Torvalds
2004-11-22 12:46   ` Adrian Bunk
2004-11-22  8:36 ` Jan Engelhardt
2004-11-22 12:48   ` Adrian Bunk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome