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 unified 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,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile.aarch64,v 1.24 2023/07/26 03:39:55 rin Exp $ 1# $NetBSD: Makefile.aarch64,v 1.25 2023/07/28 02:41:30 rin Exp $
2 2
3# Makefile for NetBSD 3# Makefile for NetBSD
4# 4#
5# This makefile is constructed from a machine description: 5# This makefile is constructed from a machine description:
6# config machineid 6# config machineid
7# Most changes should be made in the machine description 7# Most changes should be made in the machine description
8# /sys/arch/<arch>/conf/``machineid'' 8# /sys/arch/<arch>/conf/``machineid''
9# after which you should do 9# after which you should do
10# config machineid 10# config machineid
11# Machine generic makefile changes should be made in 11# Machine generic makefile changes should be made in
12# /sys/arch/arm/conf/Makefile.arm 12# /sys/arch/arm/conf/Makefile.arm
13# after which config should be rerun for all machines of that type. 13# after which config should be rerun for all machines of that type.
14# 14#
@@ -85,35 +85,29 @@ ${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFIL @@ -85,35 +85,29 @@ ${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFIL
85.endif 85.endif
86 86
87locore.o: ${ARM}/aarch64/locore.S assym.h 87locore.o: ${ARM}/aarch64/locore.S assym.h
88 ${NORMAL_S} 88 ${NORMAL_S}
89 89
90## 90##
91## (5) link settings 91## (5) link settings
92## 92##
93KERNLDSCRIPT?= ${ARM}/conf/kern.ldscript 93KERNLDSCRIPT?= ${ARM}/conf/kern.ldscript
94LOADADDRESS?= 0xffffc00000000000 94LOADADDRESS?= 0xffffc00000000000
95LINKFLAGS_NORMAL= -X 95LINKFLAGS_NORMAL= -X
96 96
97# Strip AArch64 mapping symbols from the kernel image, as they interfere 97# Strip AArch64 mapping symbols from the kernel image, as they interfere
98# with ddb, but don't strip them in netbsd.gdb. 98# with ddb, but don't strip them in netbsd.gdb. See Makefile.kern.inc.
99AA64_STRIP_SYMBOLS= --strip-symbol='[$$][dx]' \ 99ARCH_STRIP_SYMBOLS= --strip-symbol='[$$][dx]' \
100 --strip-symbol='[$$][dx]\.*' 100 --strip-symbol='[$$][dx]\.*'
101.if (defined(DEBUG) && !empty(DEBUG:M-g*)) || (!defined(DEBUG) && \ 
102 (${MKDEBUGKERNEL:Uno} == "yes" || ${MKDEBUG:Uno} == "yes")) 
103OBJCOPY_STRIPFLAGS= -g -w ${AA64_STRIP_SYMBOLS} 
104.else 
105SYSTEM_LD_TAIL= @${OBJCOPY} -w ${AA64_STRIP_SYMBOLS} $@ 
106.endif 
107 101
108## 102##
109## (6) port specific target dependencies 103## (6) port specific target dependencies
110## 104##
111 105
112# depend on DIAGNOSTIC etc. 106# depend on DIAGNOSTIC etc.
113cpuswitch.o fault.o machdep.o: Makefile 107cpuswitch.o fault.o machdep.o: Makefile
114 108
115# various assembly files that depend on assym.h 109# various assembly files that depend on assym.h
116atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h 110atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h
117exception.o sigcode.o: assym.h 111exception.o sigcode.o: assym.h
118spl.o vectors.o: assym.h 112spl.o vectors.o: assym.h
119 113

cvs diff -r1.56 -r1.57 src/sys/arch/arm/conf/Makefile.arm (expand / switch to unified 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,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile.arm,v 1.56 2023/07/26 03:39:55 rin Exp $ 1# $NetBSD: Makefile.arm,v 1.57 2023/07/28 02:41:30 rin Exp $
2 2
3# Makefile for NetBSD 3# Makefile for NetBSD
4# 4#
5# This makefile is constructed from a machine description: 5# This makefile is constructed from a machine description:
6# config machineid 6# config machineid
7# Most changes should be made in the machine description 7# Most changes should be made in the machine description
8# /sys/arch/<arch>/conf/``machineid'' 8# /sys/arch/<arch>/conf/``machineid''
9# after which you should do 9# after which you should do
10# config machineid 10# config machineid
11# Machine generic makefile changes should be made in 11# Machine generic makefile changes should be made in
12# /sys/arch/arm/conf/Makefile.arm 12# /sys/arch/arm/conf/Makefile.arm
13# after which config should be rerun for all machines of that type. 13# after which config should be rerun for all machines of that type.
14# 14#
@@ -96,35 +96,29 @@ MD_SFILES+= ${SYSTEM_FIRST_SFILE} ${ARM} @@ -96,35 +96,29 @@ MD_SFILES+= ${SYSTEM_FIRST_SFILE} ${ARM}
96${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h 96${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
97 ${NORMAL_S} 97 ${NORMAL_S}
98.endif 98.endif
99 99
100locore.o: ${ARM}/arm32/locore.S assym.h 100locore.o: ${ARM}/arm32/locore.S assym.h
101 ${NORMAL_S} 101 ${NORMAL_S}
102 102
103## 103##
104## (5) link settings 104## (5) link settings
105## 105##
106LOADADDRESS?= 0xF0000000 106LOADADDRESS?= 0xF0000000
107LINKFLAGS_NORMAL= -X 107LINKFLAGS_NORMAL= -X
108# Strip ARM mapping symbols from the kernel image, as they interfere 108# Strip ARM mapping symbols from the kernel image, as they interfere
109# with ddb, but don't strip them in netbsd.gdb. 109# with ddb, but don't strip them in netbsd.gdb. See Makefile.kern.inc.
110ARM_STRIP_SYMBOLS= --strip-symbol='[$$][atd]' \ 110ARCH_STRIP_SYMBOLS= --strip-symbol='[$$][atd]' \
111 --strip-symbol='[$$][atd]\.*' 111 --strip-symbol='[$$][atd]\.*'
112.if (defined(DEBUG) && !empty(DEBUG:M-g*)) || (!defined(DEBUG) && \ 
113 (${MKDEBUGKERNEL:Uno} == "yes" || ${MKDEBUG:Uno} == "yes")) 
114OBJCOPY_STRIPFLAGS= -g -w ${ARM_STRIP_SYMBOLS} 
115.else 
116SYSTEM_LD_TAIL= @${OBJCOPY} -w ${ARM_STRIP_SYMBOLS} $@ 
117.endif 
118 112
119## 113##
120## (6) port specific target dependencies 114## (6) port specific target dependencies
121## 115##
122 116
123# depend on CPU configuration 117# depend on CPU configuration
124cpufunc.o cpufunc_asm.o: Makefile 118cpufunc.o cpufunc_asm.o: Makefile
125 119
126# depend on DIAGNOSTIC etc. 120# depend on DIAGNOSTIC etc.
127cpuswitch.o fault.o machdep.o: Makefile 121cpuswitch.o fault.o machdep.o: Makefile
128 122
129# various assembly files that depend on assym.h 123# various assembly files that depend on assym.h
130atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h 124atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h

cvs diff -r1.298 -r1.299 src/sys/conf/Makefile.kern.inc (expand / switch to unified 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,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile.kern.inc,v 1.298 2023/07/26 03:39:55 rin Exp $ 1# $NetBSD: Makefile.kern.inc,v 1.299 2023/07/28 02:41:31 rin Exp $
2# 2#
3# This file contains common `MI' targets and definitions and it is included 3# This file contains common `MI' targets and definitions and it is included
4# at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}. 4# at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
5# 5#
6# Each target in this file should be protected with `if !target(target)' 6# Each target in this file should be protected with `if !target(target)'
7# or `if !commands(target)' and each variable should only be conditionally 7# or `if !commands(target)' and each variable should only be conditionally
8# assigned `VAR ?= VALUE', so that everything can be overridden. 8# assigned `VAR ?= VALUE', so that everything can be overridden.
9# 9#
10# DEBUG is set to -g if debugging. 10# DEBUG is set to -g if debugging.
11# PROF is set to -pg if profiling. 11# PROF is set to -pg if profiling.
12# 12#
13# To specify debugging, add the config line: makeoptions DEBUG="-g" 13# To specify debugging, add the config line: makeoptions DEBUG="-g"
14# A better way is to specify -g only for a few files. 14# A better way is to specify -g only for a few files.
@@ -235,32 +235,42 @@ SYSTEM_LD?= ${_MKSHMSG} " link ${.CUR @@ -235,32 +235,42 @@ SYSTEM_LD?= ${_MKSHMSG} " link ${.CUR
235 ${OBJS:M*swap${.TARGET}.o} 235 ${OBJS:M*swap${.TARGET}.o}
236 236
237TEXTADDR?= ${LOADADDRESS} # backwards compatibility 237TEXTADDR?= ${LOADADDRESS} # backwards compatibility
238LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/} 238LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/}
239LINKDATA?= ${DATAADDR:C/.+/-Tdata &/} 239LINKDATA?= ${DATAADDR:C/.+/-Tdata &/}
240ENTRYPOINT?= start 240ENTRYPOINT?= start
241LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/} 241LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/}
242LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \ 242LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \
243 ${EXTRA_LINKFLAGS} 243 ${EXTRA_LINKFLAGS}
244 244
245LINKFLAGS_DEBUG?= -X 245LINKFLAGS_DEBUG?= -X
246KERNEL_CONFIG?= ${KERNEL_BUILD:T} 246KERNEL_CONFIG?= ${KERNEL_BUILD:T}
247 247
248SYSTEM_LD_TAIL?= @${_MKSHECHO} 248SYSTEM_LD_TAIL?= @${_MKSHECHO}
249SYSTEM_LD_TAIL+= && ${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c && \ 249OBJCOPY_STRIPFLAGS?= -g
250 ${SIZE} $@ && ${SYSTEM_CTFMERGE} && chmod 755 $@ 
251SYSTEM_LD_TAIL+= && runit() { echo $$@; $$@; } 
252 250
253OBJCOPY_STRIPFLAGS?= -g 251# Strip some architecture-defined symbols from kernel image, while
 252# keep them in netbsd.gdb.
 253.if defined(ARCH_STRIP_SYMBOLS)
 254.if empty(DEBUG:M-g*)
 255SYSTEM_LD_TAIL+= && ${OBJCOPY} -w ${ARCH_STRIP_SYMBOLS} $@
 256.endif
 257OBJCOPY_STRIPFLAGS+= -w ${ARCH_STRIP_SYMBOLS}
 258.endif
 259
 260SYSTEM_LD_TAIL+= && ${TOOL_SED} \
 261 '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c && \
 262 ${SIZE} $@ && ${SYSTEM_CTFMERGE} && chmod 755 $@ && \
 263 runit() { echo $$@; $$@; }
254 264
255SYSTEM_LD_TAIL_DEBUG?=&& \ 265SYSTEM_LD_TAIL_DEBUG?=&& \
256 runit mv -f $@ $@.gdb && \ 266 runit mv -f $@ $@.gdb && \
257 runit ${OBJCOPY} --only-keep-debug $@.gdb $@-${KERNEL_CONFIG}.debug && \ 267 runit ${OBJCOPY} --only-keep-debug $@.gdb $@-${KERNEL_CONFIG}.debug && \
258 runit ${OBJCOPY} ${OBJCOPY_STRIPFLAGS} -p -R .gnu_debuglink \ 268 runit ${OBJCOPY} ${OBJCOPY_STRIPFLAGS} -p -R .gnu_debuglink \
259 --add-gnu-debuglink=$@-${KERNEL_CONFIG}.debug $@.gdb $@ && \ 269 --add-gnu-debuglink=$@-${KERNEL_CONFIG}.debug $@.gdb $@ && \
260 runit chmod 755 $@ $@.gdb $@-${KERNEL_CONFIG}.debug 270 runit chmod 755 $@ $@.gdb $@-${KERNEL_CONFIG}.debug
261 271
262LINKFLAGS_NORMAL?= -S 272LINKFLAGS_NORMAL?= -S
263STRIPFLAGS?= -g 273STRIPFLAGS?= -g
264 274
265.if !empty(DEBUG:M-g*) 275.if !empty(DEBUG:M-g*)
266SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG} 276SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG}