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.diff -r1.24 -r1.25 src/sys/arch/aarch64/conf/Makefile.aarch64
(rin)
--- 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 | |||
87 | locore.o: ${ARM}/aarch64/locore.S assym.h | 87 | locore.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 | ## | |
93 | KERNLDSCRIPT?= ${ARM}/conf/kern.ldscript | 93 | KERNLDSCRIPT?= ${ARM}/conf/kern.ldscript | |
94 | LOADADDRESS?= 0xffffc00000000000 | 94 | LOADADDRESS?= 0xffffc00000000000 | |
95 | LINKFLAGS_NORMAL= -X | 95 | LINKFLAGS_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. | |
99 | AA64_STRIP_SYMBOLS= --strip-symbol='[$$][dx]' \ | 99 | ARCH_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")) | |||
103 | OBJCOPY_STRIPFLAGS= -g -w ${AA64_STRIP_SYMBOLS} | |||
104 | .else | |||
105 | SYSTEM_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. | |
113 | cpuswitch.o fault.o machdep.o: Makefile | 107 | cpuswitch.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 | |
116 | atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h | 110 | atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h | |
117 | exception.o sigcode.o: assym.h | 111 | exception.o sigcode.o: assym.h | |
118 | spl.o vectors.o: assym.h | 112 | spl.o vectors.o: assym.h | |
119 | 113 |
--- 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 | |||
100 | locore.o: ${ARM}/arm32/locore.S assym.h | 100 | locore.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 | ## | |
106 | LOADADDRESS?= 0xF0000000 | 106 | LOADADDRESS?= 0xF0000000 | |
107 | LINKFLAGS_NORMAL= -X | 107 | LINKFLAGS_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. | |
110 | ARM_STRIP_SYMBOLS= --strip-symbol='[$$][atd]' \ | 110 | ARCH_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")) | |||
114 | OBJCOPY_STRIPFLAGS= -g -w ${ARM_STRIP_SYMBOLS} | |||
115 | .else | |||
116 | SYSTEM_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 | |
124 | cpufunc.o cpufunc_asm.o: Makefile | 118 | cpufunc.o cpufunc_asm.o: Makefile | |
125 | 119 | |||
126 | # depend on DIAGNOSTIC etc. | 120 | # depend on DIAGNOSTIC etc. | |
127 | cpuswitch.o fault.o machdep.o: Makefile | 121 | cpuswitch.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 | |
130 | atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h | 124 | atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h |
--- 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 | |||
237 | TEXTADDR?= ${LOADADDRESS} # backwards compatibility | 237 | TEXTADDR?= ${LOADADDRESS} # backwards compatibility | |
238 | LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/} | 238 | LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/} | |
239 | LINKDATA?= ${DATAADDR:C/.+/-Tdata &/} | 239 | LINKDATA?= ${DATAADDR:C/.+/-Tdata &/} | |
240 | ENTRYPOINT?= start | 240 | ENTRYPOINT?= start | |
241 | LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/} | 241 | LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/} | |
242 | LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \ | 242 | LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \ | |
243 | ${EXTRA_LINKFLAGS} | 243 | ${EXTRA_LINKFLAGS} | |
244 | 244 | |||
245 | LINKFLAGS_DEBUG?= -X | 245 | LINKFLAGS_DEBUG?= -X | |
246 | KERNEL_CONFIG?= ${KERNEL_BUILD:T} | 246 | KERNEL_CONFIG?= ${KERNEL_BUILD:T} | |
247 | 247 | |||
248 | SYSTEM_LD_TAIL?= @${_MKSHECHO} | 248 | SYSTEM_LD_TAIL?= @${_MKSHECHO} | |
249 | SYSTEM_LD_TAIL+= && ${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c && \ | 249 | OBJCOPY_STRIPFLAGS?= -g | |
250 | ${SIZE} $@ && ${SYSTEM_CTFMERGE} && chmod 755 $@ | |||
251 | SYSTEM_LD_TAIL+= && runit() { echo $$@; $$@; } | |||
252 | 250 | |||
253 | OBJCOPY_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*) | |||
255 | SYSTEM_LD_TAIL+= && ${OBJCOPY} -w ${ARCH_STRIP_SYMBOLS} $@ | |||
256 | .endif | |||
257 | OBJCOPY_STRIPFLAGS+= -w ${ARCH_STRIP_SYMBOLS} | |||
258 | .endif | |||
259 | ||||
260 | SYSTEM_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 | |||
255 | SYSTEM_LD_TAIL_DEBUG?=&& \ | 265 | SYSTEM_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 | |||
262 | LINKFLAGS_NORMAL?= -S | 272 | LINKFLAGS_NORMAL?= -S | |
263 | STRIPFLAGS?= -g | 273 | STRIPFLAGS?= -g | |
264 | 274 | |||
265 | .if !empty(DEBUG:M-g*) | 275 | .if !empty(DEBUG:M-g*) | |
266 | SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG} | 276 | SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG} |