[PATCH] Revert "configure: allow the use of bare-metal toolchains"

Mark Rutland mark.rutland at arm.com
Fri Aug 2 04:17:29 PDT 2024


While well-intentioned, the CFLAGS change to support bare metal
toolchains introduced at least two problems:

(1) It broke building on an AArch64 host when *not* passing '--host=[...]', as
    the bare-metal object files built during the configure step can't be
    executed on the host:

    | [mark at gravadlaks:~/src/boot-wrapper-aarch64]% ./configure --enable-gicv3 --with-kernel-dir=../linux-kvm
    | checking for a BSD-compatible install... /usr/bin/install -c
    | checking whether build environment is sane... yes
    | checking for a race-free mkdir -p... /usr/bin/mkdir -p
    | checking for gawk... no
    | checking for mawk... mawk
    | checking whether make sets $(MAKE)... yes
    | checking whether make supports nested variables... yes
    | checking whether DTB file exists... yes
    | checking whether kernel image exists... yes
    | checking for gcc... gcc
    | checking whether the C compiler works... yes
    | checking for C compiler default output file name... a.out
    | checking for suffix of executables...
    | checking whether we are cross compiling... configure: error: in `/home/mark/src/boot-wrapper-aarch64':
    | configure: error: cannot run C compiled programs.
    | If you meant to cross compile, use `--host'.
    | See `config.log' for more details

(2) It removed the implicit default CFLAGS used by autoconf ('-g -O2'),
    and consequently the boot-wrapper was compiled at a lower
    optimization level. This caused functions to use more stack space,
    and for CPUs to clobber other CPUs' stacks during initialization,
    leading to various potential issues including misconfiguration of
    the system.

We can solve (2) by adding '-O2' manually and/or increasing STACK_SIZE
from 256 bytes, but (1) is much more painful to solve as we end up
having to work around the core design of autoconf.

For now, revert the problematic commit.

This reverts commit 1fea854771f9aee405c4ae204c0e0f912318da6f.

Signed-off-by: Mark Rutland <mark.rutland at arm.com>
Reported-by: Andre Przywara <andre.przywara at arm.com>
Cc: Akos Denke <akos.denke at arm.com>
Cc: Luca Fancellu <luca.fancellu at arm.com>
Cc: Marc Zyngier <maz at kernel.org>
---
 configure.ac | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1f2f4f6..ce41dae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,9 +128,6 @@ AC_ARG_ENABLE([gicv3],
 AM_CONDITIONAL([GICV3], [test "x$USE_GICV3" = "xyes"])
 AS_IF([test "x$USE_GICV3" = "xyes"], [], [USE_GICV3=no])
 
-# Ensure AC_PROG_CC tries to build a bare-metal object
-CFLAGS="${CFLAGS} -ffreestanding -nostdlib"
-
 # Ensure that we have all the needed programs
 AC_PROG_CC
 AC_PROG_CPP
-- 
2.30.2




More information about the linux-arm-kernel mailing list