1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
# $NetBSD: Makefile.rump,v 1.134 2022/05/03 08:34:00 hannken Exp $
#
.if !defined(_RUMP_MK)
_RUMP_MK= #defined
WARNS?= 3 # XXX: src/sys won't compile with -Wsign-compare yet
NOLINT= # kernel code
.include <bsd.own.mk>
# Use NetBSD kernel ABI by default on x86 archs. Performance-related
# compile-time options may override this at a later date.
.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64")
_RUMP_NATIVEABI= yes
.else
_RUMP_NATIVEABI= no
CPPFLAGS:= -I${RUMPTOP}/include ${CPPFLAGS}
CPPFLAGS+= -D_RUMPKERNEL -I${RUMPTOP}/librump/rumpkern
.endif
# We are compiling the kernel code with no-delete-null-pointer-checks,
# and compiling without it, causes issues at least on sh3 by adding
# aborts after kern_assert on NULL pointer checks.
CFLAGS+= ${${ACTIVE_CC} == "gcc":? -fno-delete-null-pointer-checks :}
.if ${RUMP_SANITIZE:Uno} != "no"
CFLAGS+= -fsanitize=${RUMP_SANITIZE}
LDFLAGS+= -fsanitize=${RUMP_SANITIZE}
.endif
# NULL + 0 arithmetic raises LLVM UBSan warnings, specially in sys/pslist.h
# in the type-safe macros _PSLIST_VALIDATE_PTRS and _PSLIST_VALIDATE_CONTAINER.
.if ${MKSANITIZER:Uno} == "yes" || ${MKLIBCSANITIZER:Uno} == "yes"
CFLAGS+= ${${ACTIVE_CC} == "clang":? -fno-delete-null-pointer-checks :}
.endif
# Define baseline cpu for mips ports, required for
# rumpcomp_sync_icache() hypercall.
.if !empty(MACHINE_ARCH:Mmips*)
.if ${MACHINE_MIPS64}
CPPFLAGS+= -DMIPS64=1
.else
CPPFLAGS+= -DMIPS1=1
.endif
.endif
# which NetBSD compat to build
RUMP_NBCOMPAT?=default
.if ${RUMP_NBCOMPAT} == "all" || ${RUMP_NBCOMPAT} == "default"
RUMP_NBCOMPAT= 50 60 70 80 90
.endif
.if ${RUMP_NBCOMPAT} == "none"
RUMP_NBCOMPAT=
.endif
RUMP_NBCOMPAT:= ${RUMP_NBCOMPAT:S/,/ /g}
CPPFLAGS+= ${RUMP_NBCOMPAT:C/[1-9]0/-DCOMPAT_&/g}
CPPFLAGS+= -nostdinc
CFLAGS+= -ffreestanding -fno-strict-aliasing
CWARNFLAGS+= -Wno-format-zero-length -Wno-pointer-sign
CPPIFLAGS+= -imacros ${RUMPTOP}/include/opt/opt_rumpkernel.h
.ifdef BUILDRUMP_IMACROS
CPPIFLAGS+= -imacros ${BUILDRUMP_IMACROS}
.endif
CPPFLAGS+= -I${.CURDIR} -I.
CPPFLAGS+= -I${RUMPTOP}/../../common/include
CPPFLAGS+= -I${RUMPTOP}/include
CPPFLAGS+= -I${RUMPTOP}/include/opt
SHLIB_MAJOR?= 0
SHLIB_MINOR?= 0
.ifdef NEED_ISYSTEM
CPPIFLAGS+= -isystem ${RUMPTOP}/../arch
CPPIFLAGS+= -isystem ${RUMPTOP}/..
.else
CPPFLAGS+= -I${RUMPTOP}/../arch
CPPFLAGS+= -I${RUMPTOP}/..
.endif
RUMP_LDSCRIPT?= GNU
.if ${RUMP_LDSCRIPT} != "no"
# my ld or yours?
.if ${RUMP_LDSCRIPT} == "sun"
LDFLAGS+= -Wl,-M ${RUMPTOP}/ldscript_sun.rump
SRCS+= linksyms_sun.c
.PATH: ${RUMPTOP}
.elif ${RUMP_LDSCRIPT} == "GNU"
LDFLAGS+= -Wl,-T,${RUMPTOP}/ldscript.rump
.elif ${RUMP_LDSCRIPT} == "ctor"
CPPFLAGS+= -DRUMP_USE_CTOR
.else
.error Unknown ldscript ${RUMP_LDSCRIPT}
.endif
.endif
.if defined(RUMP_CURLWP)
.if ${RUMP_CURLWP} == "hypercall"
CPPFLAGS+= -DRUMP_CURLWP=RUMP_CURLWP_HYPERCALL
.elif ${RUMP_CURLWP} == "__thread"
CPPFLAGS+= -DRUMP_CURLWP=RUMP_CURLWP___THREAD
.elif ${RUMP_CURLWP} == "register"
CPPFLAGS+= -DRUMP_CURLWP=RUMP_CURLWP_REGISTER
.else
.error Unsupported curlwp scheme: ${RUMP_CURLWP}
.endif
.endif
RUMP_DIAGNOSTIC?=yes
.if ${RUMP_DIAGNOSTIC} == "yes"
CPPFLAGS+= -DDIAGNOSTIC
.endif
.ifdef RUMP_DEBUG
CPPFLAGS+= -DDEBUG
.endif
.ifdef RUMP_LOCKDEBUG
CPPFLAGS+= -DLOCKDEBUG
.endif
.ifdef RUMP_VNODE_LOCKDEBUG
CPPFLAGS+= -DVNODE_LOCKDEBUG
.endif
RUMP_KTRACE?=yes
.if ${RUMP_KTRACE} == "yes"
CPPFLAGS+= -DKTRACE
.endif
# kernel libs should not get linked against libc
# XXX: actually, we would like to enable this but cannot, since it
# also leaves out libgcc, it causes problems on some platforms.
# revisit some day.
#LDFLAGS+= -nodefaultlibs
# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
# also, give those builds a way to undef the local compiler's macros
CPPFLAGS+= ${RUMPKERN_UNDEF}
RUMPKERNEL= This is NetBSD and I am the rump. Good evening.
# workaround: evbppc is not a well-defined arch
.if ${MACHINE} == "evbppc"
. if ${MACHINE_ARCH} == "powerpc"
CPPFLAGS+= -DPPC_OEA
. else
CPPFLAGS+= -DPPC_OEA64
. endif
.endif
# If any of these files change, we need a full rebuild
DPSRCS+= ${RUMPTOP}/Makefile.rump
#
# Support for component-specific hypercalls
#
# no easy way to get WARNS out of bsd.sys.mk
RUMPCOMP_USER_WARNFLAGS= -Wall -Wextra -Wno-unused-parameter
RUMPCOMP_USER_WARNFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
.ifdef RUMPCOMP_USER_SRCS && !defined(RUMPKERN_ONLY)
.if empty(DESTDIR)
DESTDIR=/
.endif
BUILDRUMP_CPPFLAGS ?= -isysroot ${DESTDIR}
RUMPCOMP_USER_WERROR = ${${_NOWERROR} == "no" :?-Werror:}
.for rcusrc in ${RUMPCOMP_USER_SRCS:R}
${rcusrc}.d: ${rcusrc}.c
${_MKTARGET_CREATE}
${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} ${CPUFLAGS} ${REPROFLAGS} ${BUILDRUMP_CPPFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${.ALLSRC:O:u:M*${rcusrc}.c}
${rcusrc}.o: ${rcusrc}.c
${_MKTARGET_COMPILE}
${CC} -o ${.TARGET} ${DBG} ${CWARNFLAGS} ${CPUFLAGS} ${REPROFLAGS} ${RUMPCOMP_USER_WERROR} ${RUMPCOMP_USER_WARNFLAGS} ${BUILDRUMP_CPPFLAGS} ${BUILDRUMP_CFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${RUMPCOMP_USER_CFLAGS} -c ${.ALLSRC:O:u:M*${rcusrc}.c}
${rcusrc}.pico: ${rcusrc}.c
${_MKTARGET_COMPILE}
${CC} -o ${.TARGET} -fPIC -DPIC ${DBG} ${CWARNFLAGS} ${CPUFLAGS} ${REPROFLAGS} ${RUMPCOMP_USER_WERROR} ${RUMPCOMP_USER_WARNFLAGS} ${BUILDRUMP_CPPFLAGS} ${BUILDRUMP_CFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${RUMPCOMP_USER_CFLAGS} -c ${.ALLSRC:O:u:M*${rcusrc}.c}
${rcusrc}.po: ${rcusrc}.c
${_MKTARGET_COMPILE}
${CC} -o ${.TARGET} ${PROFFLAGS} -pg ${DBG} ${CWARNFLAGS} ${CPUFLAGS} ${REPROFLAGS} ${RUMPCOMP_USER_WERROR} ${RUMPCOMP_USER_WARNFLAGS} ${BUILDRUMP_CPPFLAGS} ${BUILDRUMP_CFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${RUMPCOMP_USER_CFLAGS} -c ${.ALLSRC:O:u:M*${rcusrc}.c}
RUMPOBJ_NORENAME+=${rcusrc}.o ${rcusrc}.pico ${rcusrc}.po
SRCS+=${rcusrc}.c
.endfor
.endif
#
# Rename library symbols before use. If a symbol does not already belong
# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns". This
# avoids accidentally linking any kernel symbol against host platform
# libraries. The only non-renamed symbols are linkset delimiters and
# the GOT, which are more a property of the compiler than the kernel.
#
# Some toolchains generate unresolved symbols which are supposed to be
# satisfied by the toolchain itself when the program is linked.
# Unfortunately, we do not know which of the symbols are generated by
# the toolchain. Worse, they vary from platform to platform and
# toolchain to toolchain. The good news, however, is that this will
# be detected by a compile-time failure, so we can fairly easily manage
# a quirktable here.
#
# We also allow calling ourselves externally with e.g.:
# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
#
.if ${MACHINE_CPU} == "mips"
_SYMQUIRK='|_gp_disp'
.elif ${MACHINE_CPU} == "hppa"
_SYMQUIRK='|\$$\$$'
.elif ${MACHINE_ARCH} == "powerpc64"
_SYMQUIRK="|PF_funcs"
.endif
#
# Prefix quirks. At least one toolchain generates global
# symbols with prefixes which really need to remain as prefixes
# (i.e. the '.' on the front of some ppc64 globals). The
# way to know if you have the problem is if you get later
# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH';
# the 'X' part was added by the toolchain and will need to
# be mentioned here.
#
.if ${MACHINE_ARCH} == "powerpc64"
_PQ="\.?"
.else
_PQ=
.endif
rump_symren: __archivebuild
.if !defined(RUMP_SYMREN)
@echo "Must supply RUMP_SYMREN for target rump_symren"
@false
.endif
# if we are called from lib build (RUMP_SYMREN is not specified),
# build the arrrrchive. otherwise just rename symbols.
__archivebuild: .USE
.if defined(RUMP_SYMREN) && defined(RUMPTOP)
@echo "ERROR: RUMP_SYMREN can only be used standalone"
@false
.endif
.if defined(RUMP_SYMREN)
${_MKMSG} " symbol rename " ${RUMP_SYMREN}
.else
${_MKTARGET_BUILD}
rm -f ${.TARGET}
.endif
for renameobj in ${RUMP_SYMREN:U${.ALLSRC:C/(${RUMPOBJ_NORENAME:ts|})//g}}; do \
${NM} -go $${renameobj} | ${TOOL_AWK} ' \
$$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE|\.TOC\.'${_SYMQUIRK}'${RUMP_SYM_NORENAME:D|${RUMP_SYM_NORENAME}})/ \
{s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\
| sort | uniq > renametab.$${renameobj}; \
${OBJCOPY} --preserve-dates --redefine-syms \
renametab.$${renameobj} $${renameobj}; \
rm -f renametab.$${renameobj}; \
done
.if !defined(RUMP_SYMREN)
${AR} ${_ARFL} ${.TARGET} \
`NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
.endif
COMMENT?= (no description)
rumpdescribe: .PHONY
@printf '%-24s %s\n' '${LIB}' '${COMMENT}'
CPPFLAGS+= ${CPPIFLAGS}
LINTFLAGS+= ${CPPIFLAGS:S/^/-Z /}
_BSD_IOCONF_MK_USER_=1
.include <bsd.ioconf.mk>
.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
.endif # _RUMP_MK
|