[2.6 patch] compile with -ffreestanding

From: Adrian Bunk (bunk_at_stusta.de)
Date: 12/02/04

  • Next message: Magnus Damm: "[PATCH] documentation - mem="
    Date:	Thu, 2 Dec 2004 00:38:53 +0100
    To: Andrew Morton <akpm@osdl.org>
    
    

    Hi Andrew,

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

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

    I'm currently running a 2.6.10-rc2-mm4 with this patch applied and
    compiled with gcc 2.95 and haven't yet observed any problems.

    Regarding changes caused by this patch:

    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.

    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 \

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Magnus Damm: "[PATCH] documentation - mem="

    Relevant Pages

    • CONFIG_OPTIMIZE_INLINING fun
      ... I'm wondering whether we need this patch: ... This option determines if the kernel forces gcc to inline the functions ...
      (Linux-Kernel)
    • Re: [Announce] Linux-tiny project revival
      ... kernel BIIIIIG. ... change the source file path anyway? ... gcc -E sam.c ... I once posted a patch to fix up on this, ...
      (Linux-Kernel)
    • Re: [Bug #13185] New x86 warning
      ... This patch regresses on older GCC versions ... the 64bit kernel runs slower than the 32bit kernel because ... Also the general trend in the kernel is to inline less ...
      (Linux-Kernel)
    • printflike vs kprintflike
      ... I have a patch from Neal Fachan of isilon that implements a new gcc ... attribute 'kprintflike' that is used in place of 'printflike' in the ... This is done to stop us from leaking kernel printf formats into ... This patch was made against 5.4 sources with some local changes. ...
      (freebsd-arch)
    • AW: Kernel 2.6.3 patch for Intel Compiler 8.0
      ... the kernel. ... 33% of the lmbench procs faster on icc, 66% faster on gcc. ... take the kernel patch as a good basis for modifying the ... compiler switches and other things to get more performance gains. ...
      (Linux-Kernel)