Commit 35d1e583 authored by Alessandro Rubini's avatar Alessandro Rubini

Makefiles: fix bare builds under newer compilers

While building under ubuntu-12.04 (64 bits, at least), bare builds
were failing because of undefined "__stack_chk_fail" and "__strcpy_chk".

The former is fixed by passing -ffreestanding to the build of pp_printf
(i.e., we now export CFLAGS in the toplevel Makefile), amd the latter
is fixing by preventing use of the inline printf function when building
for bare architectures.

This is from the manpage of gcc under ubuntu-12.04:

     NOTE: In Ubuntu 8.10 and later versions, -D_FORTIFY_SOURCE=2 is set
     by default, and is activated when -O is set to 2 or higher.  This
     enables additional compile-time and run-time checks for several
     libc functions.  To disable, specify either -U_FORTIFY_SOURCE or
     -D_FORTIFY_SOURCE=0.

Thanks Aurelio for reporting ./MAKEALL was failing.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 7573f2d5
......@@ -57,6 +57,7 @@ include proto-standard/Makefile
# we need this -I so <arch/arch.h> can be found
CFLAGS += -Iarch-$(ARCH)/include
include arch-$(ARCH)/Makefile
export CFLAGS
# And this is the rule to build our target.o file. The architecture may
# build more stuff. Please note that ./MAKEALL looks for $(TARGET)
......
......@@ -3,6 +3,11 @@
CFLAGS += -ffreestanding -Os -fno-stack-protector -Itools
ARCH_LDFLAGS = -nostdlib -static -T $(ARCH).lds
# We need to undefine _FORTIFY_SOURCE, to prevent picking up external
# symbols in the inline versions of strcpy etc. This is documented in
# "man gcc" in the Ubuntu version.
CFLAGS += -U_FORTIFY_SOURCE
# All files are under A (short for ARCH) or L (short for lib): I'm lazy
A := arch-$(ARCH)
L := lib-bare
......
......@@ -3,6 +3,11 @@
CFLAGS += -ffreestanding -Os -fno-stack-protector -Itools
ARCH_LDFLAGS = -nostdlib -static -T $(ARCH).lds
# We need to undefine _FORTIFY_SOURCE, to prevent picking up external
# symbols in the inline versions of strcpy etc. This is documented in
# "man gcc" in the Ubuntu version.
CFLAGS += -U_FORTIFY_SOURCE
# All files are under A (short for ARCH) or L (short for lib): I'm lazy
A := arch-$(ARCH)
L := lib-bare
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment