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