Skip to contentSkip to conversation

sparc: Drop the "-ansi" from the asflags

PATCH In review Thomas Huth 3 participants 3 messages Aug 5, 2025 – Sep 26, 2025 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc: Drop the "-ansi" from the asflags

From: Thomas Huth <[email protected]>

In the very early kernel 1.x days, assembler files were pre-processed with the "-traditional" flag. With kernel 1.1.85, the sparc subsystem was changed to use "-ansi" instead while the other parts of the kernel continued to use "-traditional". That "-traditional" got removed from the other architectures in the course of time, but the sparc part kept the "-ansi" until today.

This is bad since it comes with some disadvantages nowadays: You have to make sure to not include any header that contains a "//" C++ comment by accident (there are now some in the tree that use these for SPDX identifiers for example), and with "-ansi" we also do not get the pre-defined __ASSEMBLER__ macro which we'd like to use instead of the kernel-only __ASSEMBLY__ macro in the future.

Since there does not seem to be any compelling reason anymore to use "-ansi" nowadays, let's simply drop the "-ansi" flag from the sparc subsystem now to get rid of those disadvantages.

---
Note: I've only compile-tested this patch. No runtime testing done.

 arch/sparc/kernel/Makefile | 2 --
 arch/sparc/lib/Makefile    | 2 +-
 arch/sparc/mm/Makefile     | 2 --
 arch/sparc/prom/Makefile   | 1 -
 4 files changed, 1 insertion(+), 6 deletions(-)
arch/sparc/kernel/Makefile +0 -2
index 36f2727e1445d..22170d4f8e060 100644
@@ -4,8 +4,6 @@
 # Makefile for the linux kernel.
 #
 
-asflags-y := -ansi
-
 # Undefine sparc when processing vmlinux.lds - it is used
 # And teach CPP we are doing $(BITS) builds (for this case)
 CPPFLAGS_vmlinux.lds := -Usparc -m$(BITS)
arch/sparc/lib/Makefile +1 -1
index ee5091dd67ed7..783bdec0d7be0 100644
@@ -2,7 +2,7 @@
 # Makefile for Sparc library files..
 #
 
-asflags-y := -ansi -DST_DIV0=0x02
+asflags-y := -DST_DIV0=0x02
 
 lib-$(CONFIG_SPARC32) += ashrdi3.o
 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
arch/sparc/mm/Makefile +0 -2
index 2d1752108d779..e9d232561c82a 100644
@@ -2,8 +2,6 @@
 # Makefile for the linux Sparc-specific parts of the memory manager.
 #
 
-asflags-y := -ansi
-
 obj-$(CONFIG_SPARC64)   += ultra.o tlb.o tsb.o
 obj-y                   += fault_$(BITS).o
 obj-y                   += init_$(BITS).o
arch/sparc/prom/Makefile +0 -1
index a1adc75d80551..92db8bb4ad4cd 100644
@@ -2,7 +2,6 @@
 # Makefile for the Sun Boot PROM interface library under
 # Linux.
 #
-asflags := -ansi
 
 lib-y                 := bootstr_$(BITS).o
 lib-y                 += init_$(BITS).o
Signature · 1 line
2.50.1
maintainer Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Thomas Huth
Quoted 21 lines · Thomas Huth

From: Thomas Huth <[email protected]>

In the very early kernel 1.x days, assembler files were pre-processed with the "-traditional" flag. With kernel 1.1.85, the sparc subsystem was changed to use "-ansi" instead while the other parts of the kernel continued to use "-traditional". That "-traditional" got removed from the other architectures in the course of time, but the sparc part kept the "-ansi" until today.

This is bad since it comes with some disadvantages nowadays: You have to make sure to not include any header that contains a "//" C++ comment by accident (there are now some in the tree that use these for SPDX identifiers for example), and with "-ansi" we also do not get the pre-defined __ASSEMBLER__ macro which we'd like to use instead of the kernel-only __ASSEMBLY__ macro in the future.

Since there does not seem to be any compelling reason anymore to use "-ansi" nowadays, let's simply drop the "-ansi" flag from the sparc subsystem now to get rid of those disadvantages.

Quoted 8 lines

---
Note: I've only compile-tested this patch. No runtime testing done.

 arch/sparc/kernel/Makefile | 2 --
 arch/sparc/lib/Makefile    | 2 +-
 arch/sparc/mm/Makefile     | 2 --
 arch/sparc/prom/Makefile   | 1 -
 4 files changed, 1 insertion(+), 6 deletions(-)

Picking this up to my for-next.

Thanks,
Andreas