diff mbox series

[BOOT-WRAPPER,3/3] configure: allow the use of bare-metal toolchains

Message ID 20240729143116.1804615-4-mark.rutland@arm.com (mailing list archive)
State New, archived
Headers show
Series Allow use of bare-metal toolchains | expand

Commit Message

Mark Rutland July 29, 2024, 2:31 p.m. UTC
Currently it is not possible to build the boot-wrapper with a bare-metal
toolchain, as the configure script tries to build a hosted object. For
example, trying to build with the bare-metal aarch64-linux GCC 13.2.0
toolchain from kernel.org fails with:

| [mark@lakrids:~/src/boot-wrapper-aarch64]% usekorg 13.2.0 ./configure --enable-gicv3 --host=aarch64-linux   --with-kernel-dir=../linux --with-cmdline="console=ttyAMA0 earlycon=pl011,0x1c090000 root=/dev/vda kvm_arm.mode=vhe"
| checking for a BSD-compatible install... /usr/bin/install -c
| checking whether build environment is sane... yes
| checking for aarch64-linux-strip... aarch64-linux-strip
| checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
| checking for gawk... gawk
| 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 aarch64-linux-gcc... aarch64-linux-gcc
| checking whether the C compiler works... no
| configure: error: in `/home/mark/src/boot-wrapper-aarch64':
| configure: error: C compiler cannot create executables
| See `config.log' for more details

This behaviour was an unintentional side-effect of moving to autotools
in commit:

  bae4ae6a834cd15b ("Add autotools configuration.")

... as the default CFLAGS end up trying to build a hosted object.

Pass the necessary CFLAGS to build a bare-metal object. matching what we
do in Makefile.am, so that the configure script doesn't reject
bare-metal toolchains.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: 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 insertions(+)
diff mbox series

Patch

diff --git a/configure.ac b/configure.ac
index ce41dae..1f2f4f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,6 +128,9 @@  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