Fri Jul 28 02:41:31 2023 UTC ()
Simplify fix for PR toolchain/57146

Introduce ARCH_STRIP_SYMBOLS variable to centralize logic for debug
symbols from MD Makefile's to Makefile.kern.inc.


(rin)
diff -r1.24 -r1.25 src/sys/arch/aarch64/conf/Makefile.aarch64
diff -r1.56 -r1.57 src/sys/arch/arm/conf/Makefile.arm
diff -r1.298 -r1.299 src/sys/conf/Makefile.kern.inc

cvs diff -r1.24 -r1.25 src/sys/arch/aarch64/conf/Makefile.aarch64 (expand / switch to context diff)
--- src/sys/arch/aarch64/conf/Makefile.aarch64 2023/07/26 03:39:55 1.24
+++ src/sys/arch/aarch64/conf/Makefile.aarch64 2023/07/28 02:41:30 1.25
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.aarch64,v 1.24 2023/07/26 03:39:55 rin Exp $
+#	$NetBSD: Makefile.aarch64,v 1.25 2023/07/28 02:41:30 rin Exp $
 
 # Makefile for NetBSD
 #
@@ -95,15 +95,9 @@
 LINKFLAGS_NORMAL=	-X
 
 # Strip AArch64 mapping symbols from the kernel image, as they interfere
-# with ddb, but don't strip them in netbsd.gdb.
-AA64_STRIP_SYMBOLS=	--strip-symbol='[$$][dx]' \
+# with ddb, but don't strip them in netbsd.gdb. See Makefile.kern.inc.
+ARCH_STRIP_SYMBOLS=	--strip-symbol='[$$][dx]' \
 			--strip-symbol='[$$][dx]\.*'
-.if (defined(DEBUG) && !empty(DEBUG:M-g*)) || (!defined(DEBUG) && \
-	(${MKDEBUGKERNEL:Uno} == "yes" || ${MKDEBUG:Uno} == "yes"))
-OBJCOPY_STRIPFLAGS=	-g -w ${AA64_STRIP_SYMBOLS}
-.else
-SYSTEM_LD_TAIL=		@${OBJCOPY} -w ${AA64_STRIP_SYMBOLS} $@
-.endif
 
 ##
 ## (6) port specific target dependencies

cvs diff -r1.56 -r1.57 src/sys/arch/arm/conf/Makefile.arm (expand / switch to context diff)
--- src/sys/arch/arm/conf/Makefile.arm 2023/07/26 03:39:55 1.56
+++ src/sys/arch/arm/conf/Makefile.arm 2023/07/28 02:41:30 1.57
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.arm,v 1.56 2023/07/26 03:39:55 rin Exp $
+#	$NetBSD: Makefile.arm,v 1.57 2023/07/28 02:41:30 rin Exp $
 
 # Makefile for NetBSD
 #
@@ -106,15 +106,9 @@
 LOADADDRESS?=	0xF0000000
 LINKFLAGS_NORMAL=	-X
 # Strip ARM mapping symbols from the kernel image, as they interfere
-# with ddb, but don't strip them in netbsd.gdb.
-ARM_STRIP_SYMBOLS=	--strip-symbol='[$$][atd]' \
+# with ddb, but don't strip them in netbsd.gdb. See Makefile.kern.inc.
+ARCH_STRIP_SYMBOLS=	--strip-symbol='[$$][atd]' \
 			--strip-symbol='[$$][atd]\.*'
-.if (defined(DEBUG) && !empty(DEBUG:M-g*)) || (!defined(DEBUG) && \
-	(${MKDEBUGKERNEL:Uno} == "yes" || ${MKDEBUG:Uno} == "yes"))
-OBJCOPY_STRIPFLAGS=	-g -w ${ARM_STRIP_SYMBOLS}
-.else
-SYSTEM_LD_TAIL=		@${OBJCOPY} -w ${ARM_STRIP_SYMBOLS} $@
-.endif
 
 ##
 ## (6) port specific target dependencies

cvs diff -r1.298 -r1.299 src/sys/conf/Makefile.kern.inc (expand / switch to context diff)
--- src/sys/conf/Makefile.kern.inc 2023/07/26 03:39:55 1.298
+++ src/sys/conf/Makefile.kern.inc 2023/07/28 02:41:31 1.299
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.kern.inc,v 1.298 2023/07/26 03:39:55 rin Exp $
+#	$NetBSD: Makefile.kern.inc,v 1.299 2023/07/28 02:41:31 rin Exp $
 #
 # This file contains common `MI' targets and definitions and it is included
 # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
@@ -245,12 +245,22 @@
 LINKFLAGS_DEBUG?=	-X
 KERNEL_CONFIG?=	${KERNEL_BUILD:T}
 
-SYSTEM_LD_TAIL?= @${_MKSHECHO}
-SYSTEM_LD_TAIL+= && ${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c && \
-		${SIZE} $@ && ${SYSTEM_CTFMERGE} && chmod 755 $@
-SYSTEM_LD_TAIL+= && runit() { echo $$@; $$@; }
+SYSTEM_LD_TAIL?=	@${_MKSHECHO}
+OBJCOPY_STRIPFLAGS?=	-g
 
-OBJCOPY_STRIPFLAGS?= -g
+# Strip some architecture-defined symbols from kernel image, while
+# keep them in netbsd.gdb.
+.if defined(ARCH_STRIP_SYMBOLS)
+.if empty(DEBUG:M-g*)
+SYSTEM_LD_TAIL+=	&& ${OBJCOPY} -w ${ARCH_STRIP_SYMBOLS} $@
+.endif
+OBJCOPY_STRIPFLAGS+=	-w ${ARCH_STRIP_SYMBOLS}
+.endif
+
+SYSTEM_LD_TAIL+= && ${TOOL_SED} \
+	'/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c && \
+	${SIZE} $@ && ${SYSTEM_CTFMERGE} && chmod 755 $@ && \
+	runit() { echo $$@; $$@; }
 
 SYSTEM_LD_TAIL_DEBUG?=&& \
 	runit mv -f $@ $@.gdb && \