mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Lior Weintraub <liorw@pliops.com>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/2] ARM: don't assume 32-bit when no boards are selected
Date: Wed,  7 Jun 2023 17:31:52 +0200	[thread overview]
Message-ID: <20230607153152.2681009-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230607153152.2681009-1-a.fatoum@pengutronix.de>

barebox build errors are very confusing if no board is selected.
This should have been fixed with commit 14b296d2a7e6 ("arm: error
out if __LINUX_ARM_ARCH__ is undefined"), but unfortunately that's
only true for ARM32. On ARM64, the error message in question
is not printed, because build aborts even earlier, because Kbuild
assumes it should build for 32-bit ARM and thus passes the ARM64
compiler options that it can't understand:

  aarch64-oe-linux-gcc: error: unrecognized argument in option '-mabi=apcs-gnu'
  aarch64-oe-linux-gcc: note: valid arguments to '-mabi=' are: ilp32 lp64
  aarch64-oe-linux-gcc: error: unrecognized command-line option '-msoft-float'
  aarch64-oe-linux-gcc: error: unrecognized command-line option '-mno-unaligned-access'

Let's fix that for ARM64 builds by not assuming !CONFIG_CPU_64 to be 32-bit,
but instead explicitly check that CONFIG_CPU_32 is set before doing
32-bit specific changes.

This ensures we now fail during compilation on both ARM32 and ARM64 if
no boards were selected. We can't fail earlier via $(error ...) as this
would impact use of targets like menuconfig.

Reported-by: Lior Weintraub <liorw@pliops.com>
Reported-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/Makefile | 35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 926af7387f7f..337b7e9095fa 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -6,7 +6,8 @@ KBUILD_CPPFLAGS	+= -D__ARM__ -fno-strict-aliasing
 # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
 ifeq ($(CONFIG_CPU_64),y)
 KBUILD_CPPFLAGS	+=$(call cc-option,-maarch64,)
-else
+endif
+ifeq ($(CONFIG_CPU_32),y)
 KBUILD_CPPFLAGS	+=$(call cc-option,-marm,)
 KBUILD_CPPFLAGS	+= -msoft-float
 endif
@@ -27,14 +28,12 @@ endif
 # at least some of the code would be executed with MMU off, lets be
 # conservative and instruct the compiler not to generate any unaligned
 # accesses
-ifneq ($(CONFIG_CPU_64),y)
+ifeq ($(CONFIG_CPU_32),y)
 KBUILD_CFLAGS += -mno-unaligned-access
-else
-KBUILD_CFLAGS += -mstrict-align
 endif
-
-# Prevent use of floating point and Advanced SIMD registers.
 ifeq ($(CONFIG_CPU_64),y)
+KBUILD_CFLAGS += -mstrict-align
+# Prevent use of floating point and Advanced SIMD registers.
 KBUILD_CFLAGS += -mgeneral-regs-only
 endif
 
@@ -54,19 +53,11 @@ tune-$(CONFIG_CPU_ARM920T)	:=-mtune=arm9tdmi
 tune-$(CONFIG_CPU_ARM926T)	:=-mtune=arm9tdmi
 tune-$(CONFIG_CPU_XSCALE)	:=$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale
 
-ifeq ($(CONFIG_CPU_64), y)
-CFLAGS_ABI	:=-mabi=lp64
-else
-ifeq ($(CONFIG_AEABI),y)
-CFLAGS_ABI	:=-mabi=aapcs-linux
-else
-CFLAGS_ABI	:=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) $(call cc-option,-mno-thumb-interwork,)
-endif
-endif
+CFLAGS_ABI-$(CONFIG_CPU_64)	:=-mabi=lp64
+CFLAGS_ABI-$(CONFIG_CPU_32)	:=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) $(call cc-option,-mno-thumb-interwork,)
+CFLAGS_ABI-$(CONFIG_AEABI)	:=-mabi=aapcs-linux
 
-ifeq ($(CONFIG_ARM_UNWIND),y)
-CFLAGS_ABI	+=-funwind-tables
-endif
+CFLAGS_ABI-$(CONFIG_ARM_UNWIND)	+=-funwind-tables
 
 ifeq ($(CONFIG_THUMB2_BAREBOX),y)
 AFLAGS_AUTOIT	:=$(call as-option,-Wa$(comma)-mimplicit-it=always,-Wa$(comma)-mauto-it)
@@ -75,13 +66,15 @@ CFLAGS_THUMB2	:=-mthumb $(AFLAGS_AUTOIT) $(AFLAGS_NOWARN)
 AFLAGS_THUMB2	:=$(CFLAGS_THUMB2) -Wa$(comma)-mthumb
 endif
 
+KBUILD_CPPFLAGS += $(CFLAGS_ABI-y) $(arch-y) $(tune-y)
+
 ifeq ($(CONFIG_CPU_64), y)
-KBUILD_CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y)
 KBUILD_AFLAGS   += -include asm/unified.h
 export S64_32 = 64
 export S64 = 64
-else
-KBUILD_CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y) $(CFLAGS_THUMB2)
+endif
+ifeq ($(CONFIG_CPU_32), y)
+KBUILD_CPPFLAGS += $(CFLAGS_THUMB2)
 KBUILD_AFLAGS   += -include asm/unified.h -msoft-float $(AFLAGS_THUMB2)
 export S64_32 = 32
 export S32 = 32
-- 
2.39.2




  reply	other threads:[~2023-06-07 15:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-07 15:31 [PATCH 1/2] ARM: replace CONFIG_CPU_V8 with CONFIG_CPU_64 in Makefile Ahmad Fatoum
2023-06-07 15:31 ` Ahmad Fatoum [this message]
2023-06-08  8:20   ` [PATCH 2/2] ARM: don't assume 32-bit when no boards are selected Lior Weintraub
2023-06-08  8:46     ` Ahmad Fatoum
2023-06-08  8:59       ` Lior Weintraub
2023-06-08  9:17         ` Ahmad Fatoum
2023-06-08 11:13           ` Lior Weintraub
2023-06-08 12:08             ` Ahmad Fatoum
2023-06-08  6:32 ` [PATCH 1/2] ARM: replace CONFIG_CPU_V8 with CONFIG_CPU_64 in Makefile Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230607153152.2681009-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=liorw@pliops.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox