In some arch, _mcount() would be called recursively when built with COPTS=-O0. Normally, functions called from mcount.c are expected to be expanded inline, so _mcount() will never be called recursively. But when build with COPTS=-O0, `static inline' functions aren't inlined, and _mcount() will be called recursively. Even if _mcount() has `__attribute__((__no_ instrument_function__))', it has no effect on the calling external (no-inlined) function. To avoid this, PROF.<fn> is added can be set the profiling flag of any file. "PROF.mcount.c" is set to blank by default, mcount.c itself is compiled without -pg.diff -r1.419 -r1.420 src/share/mk/bsd.README
(ryo)
--- src/share/mk/bsd.README 2021/10/14 11:45:46 1.419
+++ src/share/mk/bsd.README 2021/10/25 07:54:44 1.420
--- src/share/mk/bsd.lib.mk 2021/08/21 11:55:24 1.385
+++ src/share/mk/bsd.lib.mk 2021/10/25 07:54:44 1.386
--- src/sys/conf/Makefile.kern.inc 2021/09/11 20:28:05 1.282
+++ src/sys/conf/Makefile.kern.inc 2021/10/25 07:54:44 1.283
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: Makefile.kern.inc,v 1.282 2021/09/11 20:28:05 andvar Exp $ | 1 | # $NetBSD: Makefile.kern.inc,v 1.283 2021/10/25 07:54:44 ryo 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. | |
@@ -140,28 +140,28 @@ COMPILE_CTFCONVERT= ${_MKSHECHO}\ | @@ -140,28 +140,28 @@ COMPILE_CTFCONVERT= ${_MKSHECHO}\ | |||
140 | ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ | 140 | ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ | |
141 | ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} | 141 | ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} | |
142 | .else | 142 | .else | |
143 | COMPILE_CTFCONVERT= ${_MKSHNOECHO} | 143 | COMPILE_CTFCONVERT= ${_MKSHNOECHO} | |
144 | .endif | 144 | .endif | |
145 | 145 | |||
146 | KCOMPILE.c= ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ | 146 | KCOMPILE.c= ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ | |
147 | KCOMPILE.s= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< -o $@ | 147 | KCOMPILE.s= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< -o $@ | |
148 | KLINK.o= ${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC} | 148 | KLINK.o= ${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC} | |
149 | 149 | |||
150 | # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or | 150 | # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or | |
151 | # NOPROF and SUFFIX is the file suffix, capitalized (e.g. C for a .c file). | 151 | # NOPROF and SUFFIX is the file suffix, capitalized (e.g. C for a .c file). | |
152 | NORMAL_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \ | 152 | NORMAL_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \ | |
153 | ${_MKSHECHO} ${KCOMPILE.c} ${PROF} && \ | 153 | ${_MKSHECHO} ${KCOMPILE.c} ${PROF.${.IMPSRC:T}:U${PROF}} && \ | |
154 | ${KCOMPILE.c} ${PROF} && \ | 154 | ${KCOMPILE.c} ${PROF.${.IMPSRC:T}:U${PROF}} && \ | |
155 | ${COMPILE_CTFCONVERT} | 155 | ${COMPILE_CTFCONVERT} | |
156 | NOPROF_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \ | 156 | NOPROF_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \ | |
157 | ${_MKSHECHO} ${KCOMPILE.c} && \ | 157 | ${_MKSHECHO} ${KCOMPILE.c} && \ | |
158 | ${KCOMPILE.c} && \ | 158 | ${KCOMPILE.c} && \ | |
159 | ${COMPILE_CTFCONVERT} | 159 | ${COMPILE_CTFCONVERT} | |
160 | NORMAL_S?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \ | 160 | NORMAL_S?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \ | |
161 | ${_MKSHECHO} ${KCOMPILE.s} && \ | 161 | ${_MKSHECHO} ${KCOMPILE.s} && \ | |
162 | ${KCOMPILE.s} | 162 | ${KCOMPILE.s} | |
163 | 163 | |||
164 | # link rules: | 164 | # link rules: | |
165 | LINK_O?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}" && \ | 165 | LINK_O?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}" && \ | |
166 | ${_MKSHECHO} ${KLINK.o} && \ | 166 | ${_MKSHECHO} ${KLINK.o} && \ | |
167 | ${KLINK.o} | 167 | ${KLINK.o} |
--- src/sys/lib/libkern/Makefile.libkern 2021/05/17 08:50:36 1.51
+++ src/sys/lib/libkern/Makefile.libkern 2021/10/25 07:54:44 1.52
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: Makefile.libkern,v 1.51 2021/05/17 08:50:36 mrg Exp $ | 1 | # $NetBSD: Makefile.libkern,v 1.52 2021/10/25 07:54:44 ryo Exp $ | |
2 | 2 | |||
3 | # | 3 | # | |
4 | # Variable definitions for libkern. | 4 | # Variable definitions for libkern. | |
5 | # | 5 | # | |
6 | # Before including this, you _must_ set | 6 | # Before including this, you _must_ set | |
7 | # KERNDIR: location of sys/lib/libkern | 7 | # KERNDIR: location of sys/lib/libkern | |
8 | # | 8 | # | |
9 | # You *may* set: | 9 | # You *may* set: | |
10 | # LIBKERN_ARCH: architecture subdir to be used | 10 | # LIBKERN_ARCH: architecture subdir to be used | |
11 | # KERNCPPFLAGS: see Makefile.inc | 11 | # KERNCPPFLAGS: see Makefile.inc | |
12 | # KERNMISCCPPFLAGS: see Makefile.inc | 12 | # KERNMISCCPPFLAGS: see Makefile.inc | |
13 | # | 13 | # | |
14 | 14 | |||
@@ -45,27 +45,27 @@ CPPFLAGS+= -I${KERNDIR}/../../../common/ | @@ -45,27 +45,27 @@ CPPFLAGS+= -I${KERNDIR}/../../../common/ | |||
45 | .endif | 45 | .endif | |
46 | 46 | |||
47 | .if !defined(RUMPKERNEL) | 47 | .if !defined(RUMPKERNEL) | |
48 | .include "${.PARSEDIR}/Makefile.compiler-rt" | 48 | .include "${.PARSEDIR}/Makefile.compiler-rt" | |
49 | .endif | 49 | .endif | |
50 | 50 | |||
51 | # Other stuff | 51 | # Other stuff | |
52 | SRCS+= kern_assert.c __main.c | 52 | SRCS+= kern_assert.c __main.c | |
53 | SRCS+= cpuset.c inet_addr.c intoa.c | 53 | SRCS+= cpuset.c inet_addr.c intoa.c | |
54 | .if empty(SRCS:Mbyte_swap_8.*) | 54 | .if empty(SRCS:Mbyte_swap_8.*) | |
55 | SRCS+= bswap64.c | 55 | SRCS+= bswap64.c | |
56 | .endif | 56 | .endif | |
57 | SRCS+= md4c.c md5c.c rmd160.c sha1.c sha2.c sha3.c keccak.c murmurhash.c | 57 | SRCS+= md4c.c md5c.c rmd160.c sha1.c sha2.c sha3.c keccak.c murmurhash.c | |
58 | SRCS+= pmatch.c mcount.c crc32.c | 58 | SRCS+= pmatch.c crc32.c | |
59 | SRCS+= strlist.c | 59 | SRCS+= strlist.c | |
60 | 60 | |||
61 | SRCS+= ppath_kmem_alloc.c | 61 | SRCS+= ppath_kmem_alloc.c | |
62 | 62 | |||
63 | SRCS+= copystr.c | 63 | SRCS+= copystr.c | |
64 | SRCS+= strsep.c strstr.c | 64 | SRCS+= strsep.c strstr.c | |
65 | SRCS+= strlcpy.c strlcat.c | 65 | SRCS+= strlcpy.c strlcat.c | |
66 | 66 | |||
67 | SRCS+= imax.c imin.c lmax.c lmin.c uimax.c uimin.c ulmax.c ulmin.c | 67 | SRCS+= imax.c imin.c lmax.c lmin.c uimax.c uimin.c ulmax.c ulmin.c | |
68 | SRCS+= memmove.c | 68 | SRCS+= memmove.c | |
69 | SRCS+= strchr.c strrchr.c | 69 | SRCS+= strchr.c strrchr.c | |
70 | SRCS+= memcmp.c memmem.c | 70 | SRCS+= memcmp.c memmem.c | |
71 | 71 | |||
@@ -92,26 +92,30 @@ SRCS+= xlat_mbr_fstype.c | @@ -92,26 +92,30 @@ SRCS+= xlat_mbr_fstype.c | |||
92 | 92 | |||
93 | SRCS+= heapsort.c ptree.c radixtree.c rb.c rpst.c | 93 | SRCS+= heapsort.c ptree.c radixtree.c rb.c rpst.c | |
94 | 94 | |||
95 | SRCS+= hexdump.c | 95 | SRCS+= hexdump.c | |
96 | 96 | |||
97 | # for crypto | 97 | # for crypto | |
98 | SRCS+= explicit_memset.c consttime_memequal.c | 98 | SRCS+= explicit_memset.c consttime_memequal.c | |
99 | 99 | |||
100 | SRCS+= entpool.c | 100 | SRCS+= entpool.c | |
101 | 101 | |||
102 | SRCS+= dkcksum.c | 102 | SRCS+= dkcksum.c | |
103 | SRCS+= disklabel_swap.c | 103 | SRCS+= disklabel_swap.c | |
104 | 104 | |||
105 | # for profiling | |||
106 | SRCS+= mcount.c | |||
107 | PROF.mcount.c= # mcount.c itself is never a profiling target | |||
108 | ||||
105 | .PATH: ${NETBSDSRCDIR}/common/lib/libc/cdb | 109 | .PATH: ${NETBSDSRCDIR}/common/lib/libc/cdb | |
106 | SRCS+= cdbr.c | 110 | SRCS+= cdbr.c | |
107 | SRCS+= mi_vector_hash.c | 111 | SRCS+= mi_vector_hash.c | |
108 | 112 | |||
109 | # Files to clean up | 113 | # Files to clean up | |
110 | CLEANFILES+= lib${LIB}.o lib${LIB}.po | 114 | CLEANFILES+= lib${LIB}.o lib${LIB}.po | |
111 | 115 | |||
112 | # Remove from SRCS the .c files for any .S files added by the MD makefiles, | 116 | # Remove from SRCS the .c files for any .S files added by the MD makefiles, | |
113 | # also remove from SRCS the .c files for the .c files in NO_SRCS. | 117 | # also remove from SRCS the .c files for the .c files in NO_SRCS. | |
114 | # (Unlike libc, we don't worry about lint) | 118 | # (Unlike libc, we don't worry about lint) | |
115 | 119 | |||
116 | .for check_file in ${SRCS:M*.S} ${NO_SRCS} | 120 | .for check_file in ${SRCS:M*.S} ${NO_SRCS} | |
117 | unwanted_file := ${SRCS:M${check_file:.S=.c}} | 121 | unwanted_file := ${SRCS:M${check_file:.S=.c}} |