[RFC PATCH 3/4] arm: do not force -marm on some C files and allow LTO everywhere
Jerome Forissier
jerome.forissier at linaro.org
Tue Jul 8 12:02:49 CEST 2025
Now that CP15 instructions are not inline assembly anymore, there is no
obstacle to building all C files in Thumb mode if desired, and having
LTO enabled as well.
Signed-off-by: Jerome Forissier <jerome.forissier at linaro.org>
---
arch/arm/cpu/arm926ejs/Makefile | 5 -----
arch/arm/cpu/arm926ejs/cpu.c | 3 ++-
arch/arm/lib/Makefile | 8 --------
arch/arm/mach-kirkwood/Makefile | 7 -------
common/Makefile | 4 ----
5 files changed, 2 insertions(+), 25 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/Makefile b/arch/arm/cpu/arm926ejs/Makefile
index 1b40d901413..0021722f6f3 100644
--- a/arch/arm/cpu/arm926ejs/Makefile
+++ b/arch/arm/cpu/arm926ejs/Makefile
@@ -20,11 +20,6 @@ obj-$(CONFIG_ARCH_SUNXI) += sunxi/
ifdef CONFIG_$(PHASE_)SYS_THUMB_BUILD
ifndef CONFIG_HAS_THUMB2
-CFLAGS_cpu.o := -marm
-CFLAGS_cache.o := -marm
-CFLAGS_REMOVE_cpu.o := $(LTO_CFLAGS)
-CFLAGS_REMOVE_cache.o := $(LTO_CFLAGS)
-
AFLAGS_REMOVE_cp15.o := -mthumb -mthumb-interwork
endif
diff --git a/arch/arm/cpu/arm926ejs/cpu.c b/arch/arm/cpu/arm926ejs/cpu.c
index 9e59ff6c66f..e57f54181c4 100644
--- a/arch/arm/cpu/arm926ejs/cpu.c
+++ b/arch/arm/cpu/arm926ejs/cpu.c
@@ -29,7 +29,8 @@ static void cache_flush(void);
*************************************************************/
void sdelay(unsigned long loops)
{
- __asm__ volatile ("1:\n" "subs %0, %1, #1\n"
+ __asm__ volatile (".syntax unified\n"
+ "1:\n" "subs %0, %1, #1\n"
"bne 1b":"=r" (loops):"0"(loops));
}
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 23f73dbba32..136ecf5267e 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -80,7 +80,6 @@ endif
obj-y += cache.o
obj-$(CONFIG_SYS_ARM_CACHE_CP15) += cache-cp15.o
-CFLAGS_REMOVE_cache-cp15.o := $(LTO_CFLAGS)
# Low-level CP15 instructions (mrc p15...) cause problems with LTO
# when they are coded as inline assembly. They are implemented
# in their own .S file instead.
@@ -105,13 +104,6 @@ ifdef CONFIG_$(PHASE_)SYS_THUMB_BUILD
asflags-$(CONFIG_HAS_THUMB2) += -DCONFIG_THUMB2_KERNEL
ifndef CONFIG_HAS_THUMB2
-# for C files, just apend -marm, which will override previous -mthumb*
-
-ifndef CONFIG_ARM64
-CFLAGS_cache.o := -marm
-CFLAGS_cache-cp15.o := -marm
-endif
-
# For .S, drop -mthumb* and other thumb-related options.
# CFLAGS_REMOVE_* would not have an effet, so AFLAGS_REMOVE_*
# was implemented and is used here.
diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile
index 9581c315af8..0da110b8d69 100644
--- a/arch/arm/mach-kirkwood/Makefile
+++ b/arch/arm/mach-kirkwood/Makefile
@@ -10,10 +10,3 @@ obj-y += cp15.o
obj-y += cache.o
obj-y += lowlevel.o
obj-y += mpp.o
-
-# cpu.o, cpu_asm.o and cache.o contain CP15 instructions which cannot be run in
-# Thumb state, so build them for ARM state even with CONFIG_SYS_THUMB_BUILD
-
-CFLAGS_cpu.o := -marm
-CFLAGS_cpu_asm.o := -marm
-CFLAGS_cache.o := -marm
diff --git a/common/Makefile b/common/Makefile
index e589f307262..35991562a12 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -19,10 +19,6 @@ obj-y += version.o
# # boards
obj-y += board_f.o
obj-y += board_r.o
-ifdef CONFIG_$(PHASE_)SYS_THUMB_BUILD
-CFLAGS_REMOVE_board_f.o := $(LTO_CFLAGS)
-CFLAGS_REMOVE_board_r.o := $(LTO_CFLAGS)
-endif
obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
--
2.43.0
More information about the U-Boot
mailing list