diff mbox series

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

Message ID 20240802111729.2154293-1-mark.rutland@arm.com (mailing list archive)
State New, archived
Headers show
Series Revert "configure: allow the use of bare-metal toolchains" | expand

Commit Message

Mark Rutland Aug. 2, 2024, 11:17 a.m. UTC
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@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@arm.com>
Reported-by: Andre Przywara <andre.przywara@arm.com>
Cc: Akos Denke <akos.denke@arm.com>
Cc: Luca Fancellu <luca.fancellu@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
---
 configure.ac | 3 ---
 1 file changed, 3 deletions(-)

Comments

Mark Rutland Aug. 3, 2024, 10:43 a.m. UTC | #1
On Fri, Aug 02, 2024 at 12:17:29PM +0100, Mark Rutland wrote:
> While well-intentioned, the CFLAGS change to support bare metal
> toolchains introduced at least two problems:

[...]

> For now, revert the problematic commit.
> 
> This reverts commit 1fea854771f9aee405c4ae204c0e0f912318da6f.

Applied. To make it possible to use bare-metal toolchains we'll need to
do some more substantial work.

Mark.

> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Reported-by: Andre Przywara <andre.przywara@arm.com>
> Cc: Akos Denke <akos.denke@arm.com>
> Cc: Luca Fancellu <luca.fancellu@arm.com>
> Cc: Marc Zyngier <maz@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
>
diff mbox series

Patch

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