Makefile.rump revision 1.132
11.132Schristos# $NetBSD: Makefile.rump,v 1.132 2021/04/25 15:16:56 christos Exp $ 21.1Spooka# 31.1Spooka 41.95Spooka.if !defined(_RUMP_MK) 51.95Spooka_RUMP_MK= #defined 61.95Spooka 71.33SlukemWARNS?= 3 # XXX: src/sys won't compile with -Wsign-compare yet 81.10SpookaNOLINT= # kernel code 91.1Spooka 101.20Spooka.include <bsd.own.mk> 111.20Spooka 121.90Spooka# Use NetBSD kernel ABI by default on x86 archs. Performance-related 131.90Spooka# compile-time options may override this at a later date. 141.92Spooka.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64") 151.90Spooka_RUMP_NATIVEABI= yes 161.90Spooka.else 171.90Spooka_RUMP_NATIVEABI= no 181.18SpookaCPPFLAGS:= -I${RUMPTOP}/include ${CPPFLAGS} 191.92SpookaCPPFLAGS+= -D_RUMPKERNEL -I${RUMPTOP}/librump/rumpkern 201.18Spooka.endif 211.18Spooka 221.124Schristos# We are compiling the kernel code with no-delete-null-pointer-checks, 231.124Schristos# and compiling without it, causes issues at least on sh3 by adding 241.124Schristos# aborts after kern_assert on NULL pointer checks. 251.127SkamilCFLAGS+= ${${ACTIVE_CC} == "gcc":? -fno-delete-null-pointer-checks :} 261.124Schristos 271.128Skamil# NULL + 0 arithmetic raises LLVM UBSan warnings, specially in sys/pslist.h 281.128Skamil# in the type-safe macros _PSLIST_VALIDATE_PTRS and _PSLIST_VALIDATE_CONTAINER. 291.128Skamil.if ${MKSANITIZER:Uno} == "yes" || ${MKLIBCSANITIZER:Uno} == "yes" 301.128SkamilCFLAGS+= ${${ACTIVE_CC} == "clang":? -fno-delete-null-pointer-checks :} 311.128Skamil.endif 321.128Skamil 331.99Salnsn# Define baseline cpu for mips ports, required for 341.99Salnsn# rumpcomp_sync_icache() hypercall. 351.99Salnsn.if !empty(MACHINE_ARCH:Mmips*) 361.132Schristos.if ${MACHINE_MIPS64} 371.99SalnsnCPPFLAGS+= -DMIPS64=1 381.99Salnsn.else 391.99SalnsnCPPFLAGS+= -DMIPS1=1 401.99Salnsn.endif 411.99Salnsn.endif 421.99Salnsn 431.112Spooka# which NetBSD compat to build 441.113SpookaRUMP_NBCOMPAT?=default 451.113Spooka.if ${RUMP_NBCOMPAT} == "all" || ${RUMP_NBCOMPAT} == "default" 461.129SroyRUMP_NBCOMPAT= 50 60 70 80 90 471.112Spooka.endif 481.112Spooka.if ${RUMP_NBCOMPAT} == "none" 491.112SpookaRUMP_NBCOMPAT= 501.112Spooka.endif 511.110SpookaRUMP_NBCOMPAT:= ${RUMP_NBCOMPAT:S/,/ /g} 521.110SpookaCPPFLAGS+= ${RUMP_NBCOMPAT:C/[1-9]0/-DCOMPAT_&/g} 531.104Spooka 541.66SpookaCPPFLAGS+= -nostdinc 551.22SpookaCFLAGS+= -ffreestanding -fno-strict-aliasing 561.66Spooka 571.50SpookaCWARNFLAGS+= -Wno-format-zero-length -Wno-pointer-sign 581.114Spooka 591.131SchristosCPPIFLAGS+= -imacros ${RUMPTOP}/include/opt/opt_rumpkernel.h 601.115Spooka.ifdef BUILDRUMP_IMACROS 611.131SchristosCPPIFLAGS+= -imacros ${BUILDRUMP_IMACROS} 621.115Spooka.endif 631.114Spooka 641.15SpookaCPPFLAGS+= -I${.CURDIR} -I. 651.65SpookaCPPFLAGS+= -I${RUMPTOP}/../../common/include 661.18SpookaCPPFLAGS+= -I${RUMPTOP}/include 671.117SpookaCPPFLAGS+= -I${RUMPTOP}/include/opt 681.65Spooka 691.103SpookaSHLIB_MAJOR?= 0 701.103SpookaSHLIB_MINOR?= 0 711.103Spooka 721.65Spooka.ifdef NEED_ISYSTEM 731.131SchristosCPPIFLAGS+= -isystem ${RUMPTOP}/../arch 741.131SchristosCPPIFLAGS+= -isystem ${RUMPTOP}/.. 751.65Spooka.else 761.65SpookaCPPFLAGS+= -I${RUMPTOP}/../arch 771.65SpookaCPPFLAGS+= -I${RUMPTOP}/.. 781.65Spooka.endif 791.65Spooka 801.93SpookaRUMP_LDSCRIPT?= GNU 811.79Spooka.if ${RUMP_LDSCRIPT} != "no" 821.72Spooka# my ld or yours? 831.97Spooka.if ${RUMP_LDSCRIPT} == "sun" 841.72SpookaLDFLAGS+= -Wl,-M ${RUMPTOP}/ldscript_sun.rump 851.72SpookaSRCS+= linksyms_sun.c 861.74Spooka.PATH: ${RUMPTOP} 871.93Spooka.elif ${RUMP_LDSCRIPT} == "GNU" 881.93SpookaLDFLAGS+= -Wl,-T,${RUMPTOP}/ldscript.rump 891.96Spooka.elif ${RUMP_LDSCRIPT} == "ctor" 901.96SpookaCPPFLAGS+= -DRUMP_USE_CTOR 911.72Spooka.else 921.93Spooka.error Unknown ldscript ${RUMP_LDSCRIPT} 931.73Spooka.endif 941.79Spooka.endif 951.62Spooka 961.94Spooka.if defined(RUMP_CURLWP) 971.94Spooka.if ${RUMP_CURLWP} == "hypercall" 981.94SpookaCPPFLAGS+= -DRUMP_CURLWP=RUMP_CURLWP_HYPERCALL 991.94Spooka.elif ${RUMP_CURLWP} == "__thread" 1001.94SpookaCPPFLAGS+= -DRUMP_CURLWP=RUMP_CURLWP___THREAD 1011.94Spooka.elif ${RUMP_CURLWP} == "register" 1021.94SpookaCPPFLAGS+= -DRUMP_CURLWP=RUMP_CURLWP_REGISTER 1031.94Spooka.else 1041.94Spooka.error Unsupported curlwp scheme: ${RUMP_CURLWP} 1051.94Spooka.endif 1061.94Spooka.endif 1071.94Spooka 1081.62SpookaRUMP_DIAGNOSTIC?=yes 1091.62Spooka.if ${RUMP_DIAGNOSTIC} == "yes" 1101.62SpookaCPPFLAGS+= -DDIAGNOSTIC 1111.62Spooka.endif 1121.62Spooka 1131.62Spooka.ifdef RUMP_DEBUG 1141.62SpookaCPPFLAGS+= -DDEBUG 1151.62Spooka.endif 1161.1Spooka 1171.59Spooka.ifdef RUMP_LOCKDEBUG 1181.59SpookaCPPFLAGS+= -DLOCKDEBUG 1191.59Spooka.endif 1201.59Spooka 1211.89SpookaRUMP_KTRACE?=yes 1221.89Spooka.if ${RUMP_KTRACE} == "yes" 1231.89SpookaCPPFLAGS+= -DKTRACE 1241.89Spooka.endif 1251.89Spooka 1261.42Spooka# kernel libs should not get linked against libc 1271.43Spooka# XXX: actually, we would like to enable this but cannot, since it 1281.43Spooka# also leaves out libgcc, it causes problems on some platforms. 1291.43Spooka# revisit some day. 1301.43Spooka#LDFLAGS+= -nodefaultlibs 1311.42Spooka 1321.39Spooka# make sure __NetBSD__ gets defined (for builds on non-NetBSD) 1331.67Spooka# also, give those builds a way to undef the local compiler's macros 1341.114SpookaCPPFLAGS+= ${RUMPKERN_UNDEF} 1351.39Spooka 1361.11SpookaRUMPKERNEL= This is NetBSD and I am the rump. Good evening. 1371.11Spooka 1381.13Spooka# workaround: evbppc is not a well-defined arch 1391.130Srin.if ${MACHINE} == "evbppc" 1401.130Srin. if ${MACHINE_ARCH} == "powerpc" 1411.16SpookaCPPFLAGS+= -DPPC_OEA 1421.130Srin. else 1431.130SrinCPPFLAGS+= -DPPC_OEA64 1441.130Srin. endif 1451.13Spooka.endif 1461.13Spooka 1471.114Spooka# If any of these files change, we need a full rebuild 1481.25SpookaDPSRCS+= ${RUMPTOP}/Makefile.rump 1491.24Spooka 1501.24Spooka# 1511.69Spooka# Support for component-specific hypercalls 1521.69Spooka# 1531.69Spooka 1541.101Spooka# no easy way to get WARNS out of bsd.sys.mk 1551.102SpookaRUMPCOMP_USER_WARNFLAGS= -Wall -Wextra -Wno-unused-parameter 1561.102SpookaRUMPCOMP_USER_WARNFLAGS+= -Wstrict-prototypes -Wmissing-prototypes 1571.75Schristos 1581.91Spooka.ifdef RUMPCOMP_USER_SRCS && !defined(RUMPKERN_ONLY) 1591.75Schristos.if empty(DESTDIR) 1601.75SchristosDESTDIR=/ 1611.75Schristos.endif 1621.75SchristosBUILDRUMP_CPPFLAGS ?= -isysroot ${DESTDIR} 1631.82SpookaRUMPCOMP_USER_WERROR = ${${_NOWERROR} == "no" :?-Werror:} 1641.91Spooka.for rcusrc in ${RUMPCOMP_USER_SRCS:R} 1651.91Spooka${rcusrc}.d: ${rcusrc}.c 1661.69Spooka ${_MKTARGET_CREATE} 1671.122Sjoerg ${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} ${CPUFLAGS} ${REPROFLAGS} ${BUILDRUMP_CPPFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${.ALLSRC:O:u:M*${rcusrc}.c} 1681.69Spooka 1691.91Spooka${rcusrc}.o: ${rcusrc}.c 1701.69Spooka ${_MKTARGET_COMPILE} 1711.122Sjoerg ${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} 1721.69Spooka 1731.91Spooka${rcusrc}.pico: ${rcusrc}.c 1741.69Spooka ${_MKTARGET_COMPILE} 1751.122Sjoerg ${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} 1761.69Spooka 1771.91Spooka${rcusrc}.po: ${rcusrc}.c 1781.69Spooka ${_MKTARGET_COMPILE} 1791.122Sjoerg ${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} 1801.69Spooka 1811.91SpookaRUMPOBJ_NORENAME+=${rcusrc}.o ${rcusrc}.pico ${rcusrc}.po 1821.91SpookaSRCS+=${rcusrc}.c 1831.91Spooka.endfor 1841.69Spooka.endif 1851.69Spooka 1861.69Spooka# 1871.24Spooka# Rename library symbols before use. If a symbol does not already belong 1881.24Spooka# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns". This 1891.24Spooka# avoids accidentally linking any kernel symbol against host platform 1901.24Spooka# libraries. The only non-renamed symbols are linkset delimiters and 1911.24Spooka# the GOT, which are more a property of the compiler than the kernel. 1921.24Spooka# 1931.29Spooka# Some toolchains generate unresolved symbols which are supposed to be 1941.29Spooka# satisfied by the toolchain itself when the program is linked. 1951.29Spooka# Unfortunately, we do not know which of the symbols are generated by 1961.29Spooka# the toolchain. Worse, they vary from platform to platform and 1971.29Spooka# toolchain to toolchain. The good news, however, is that this will 1981.29Spooka# be detected by a compile-time failure, so we can fairly easily manage 1991.29Spooka# a quirktable here. 2001.46Spooka# 2011.46Spooka# We also allow calling ourselves externally with e.g.: 2021.46Spooka# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj 2031.46Spooka# 2041.29Spooka.if ${MACHINE_CPU} == "mips" 2051.29Spooka_SYMQUIRK='|_gp_disp' 2061.29Spooka.elif ${MACHINE_CPU} == "hppa" 2071.29Spooka_SYMQUIRK='|\$$\$$' 2081.54Smrg.elif ${MACHINE_ARCH} == "powerpc64" 2091.55Smrg_SYMQUIRK="|PF_funcs" 2101.55Smrg.endif 2111.55Smrg 2121.55Smrg# 2131.55Smrg# Prefix quirks. At least one toolchain generates global 2141.55Smrg# symbols with prefixes which really need to remain as prefixes 2151.55Smrg# (i.e. the '.' on the front of some ppc64 globals). The 2161.55Smrg# way to know if you have the problem is if you get later 2171.55Smrg# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH'; 2181.55Smrg# the 'X' part was added by the toolchain and will need to 2191.55Smrg# be mentioned here. 2201.55Smrg# 2211.55Smrg.if ${MACHINE_ARCH} == "powerpc64" 2221.55Smrg_PQ="\.?" 2231.55Smrg.else 2241.55Smrg_PQ= 2251.29Spooka.endif 2261.46Spooka 2271.46Spookarump_symren: __archivebuild 2281.46Spooka.if !defined(RUMP_SYMREN) 2291.46Spooka @echo "Must supply RUMP_SYMREN for target rump_symren" 2301.46Spooka @false 2311.46Spooka.endif 2321.46Spooka 2331.46Spooka# if we are called from lib build (RUMP_SYMREN is not specified), 2341.46Spooka# build the arrrrchive. otherwise just rename symbols. 2351.24Spooka__archivebuild: .USE 2361.46Spooka.if defined(RUMP_SYMREN) && defined(RUMPTOP) 2371.46Spooka @echo "ERROR: RUMP_SYMREN can only be used standalone" 2381.46Spooka @false 2391.46Spooka.endif 2401.46Spooka.if defined(RUMP_SYMREN) 2411.46Spooka ${_MKMSG} " symbol rename " ${RUMP_SYMREN} 2421.46Spooka.else 2431.24Spooka ${_MKTARGET_BUILD} 2441.24Spooka rm -f ${.TARGET} 2451.46Spooka.endif 2461.91Spooka for renameobj in ${RUMP_SYMREN:U${.ALLSRC:C/(${RUMPOBJ_NORENAME:ts|})//g}}; do \ 2471.91Spooka ${NM} -go $${renameobj} | ${TOOL_AWK} ' \ 2481.125Sjoerg $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE|\.TOC\.'${_SYMQUIRK}'${RUMP_SYM_NORENAME:D|${RUMP_SYM_NORENAME}})/ \ 2491.69Spooka {s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\ 2501.91Spooka | sort | uniq > renametab.$${renameobj}; \ 2511.69Spooka ${OBJCOPY} --preserve-dates --redefine-syms \ 2521.91Spooka renametab.$${renameobj} $${renameobj}; \ 2531.91Spooka rm -f renametab.$${renameobj}; \ 2541.69Spooka done 2551.46Spooka.if !defined(RUMP_SYMREN) 2561.69Spooka ${AR} ${_ARFL} ${.TARGET} \ 2571.69Spooka `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}` 2581.46Spooka.endif 2591.47Spooka 2601.119SpookaCOMMENT?= (no description) 2611.120Spookarumpdescribe: .PHONY 2621.119Spooka @printf '%-24s %s\n' '${LIB}' '${COMMENT}' 2631.119Spooka 2641.131SchristosCPPFLAGS+= ${CPPIFLAGS} 2651.131SchristosLINTFLAGS+= ${CPPIFLAGS:S/^/-Z /} 2661.131Schristos 2671.53Spooka_BSD_IOCONF_MK_USER_=1 2681.53Spooka.include <bsd.ioconf.mk> 2691.47Spooka 2701.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc" 2711.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc" 2721.95Spooka 2731.95Spooka.endif # _RUMP_MK 274