From: David van Moolenbroek Date: Fri, 13 Nov 2015 00:29:26 +0000 (+0100) Subject: Integrate magic instrumentation into build system X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=bcc17a8117948424aaf38a46f0a761e165407e79;p=minix.git Integrate magic instrumentation into build system Magic instrumentation is now performed on all system services if the system is built with MKMAGIC=yes, which implies MKBITCODE=yes. Change-Id: I9d1233650188b7532a9356b720fb68d5f8248939 --- diff --git a/minix/kernel/Makefile b/minix/kernel/Makefile index 514571e0c..41573f4cb 100644 --- a/minix/kernel/Makefile +++ b/minix/kernel/Makefile @@ -100,4 +100,7 @@ kernel: kernel.bcl.o -Wl,--allow-multiple-definition .endif +# Disable magic and ASR passes for the kernel. +USE_MAGIC=no + .include diff --git a/minix/llvm/configure.llvm b/minix/llvm/configure.llvm index 276b28626..ca4cf2c60 100755 --- a/minix/llvm/configure.llvm +++ b/minix/llvm/configure.llvm @@ -85,7 +85,7 @@ fi ######################## # Build Minix ######################## -export BUILDVARS=$(echo "${BUILDVARS} -V MKBITCODE=yes"| sed -e 's,-V MKMAGIC=yes,-V MKMAGIC=yes -V DBG=-g -V STRIPFLAG=-s -V CPPFLAGS=-D_MINIX_MAGIC=1,') +export BUILDVARS if [ "${REBUILD_MINIX}" == "yes" ]; then diff --git a/minix/servers/vm/Makefile b/minix/servers/vm/Makefile index 8cacb46c7..bd874a732 100644 --- a/minix/servers/vm/Makefile +++ b/minix/servers/vm/Makefile @@ -23,11 +23,7 @@ CPPFLAGS+= -I${NETBSDSRCDIR}/minix # data. For VM, we need to do the exact opposite, since for VM, the malloc # state is transferred as is. Thus, if the magic pass is enabled, tell it # to skip the regular malloc instrumentation features. -.if !empty(OPTFLAGS:M*-magic*) -OPTFLAGS.vm?= ${OPTFLAGS} \ - -magic-disable-mem-functions \ - -magic-disable-malloc-skip -.endif +MAGICFLAGS= -magic-disable-mem-functions -magic-disable-malloc-skip .include "arch/${MACHINE_ARCH}/Makefile.inc" .include diff --git a/share/mk/minix.service.mk b/share/mk/minix.service.mk index f09130b63..1ee481388 100644 --- a/share/mk/minix.service.mk +++ b/share/mk/minix.service.mk @@ -37,4 +37,20 @@ LDFLAGS+= ${${ACTIVE_CC} == "gcc":? -lgcc_eh:} # Get (more) internal minix definitions and declarations. CPPFLAGS += -D_MINIX_SYSTEM=1 +# For MKMAGIC builds, link services against libmagicrt and run the magic pass +# on them, unless they have specifically requested to be built without bitcode. +.if ${USE_BITCODE:Uno} == "yes" && ${USE_MAGIC:Uno} == "yes" +LIBMAGICST?= ${DESTDIR}${LIBDIR}/libmagicrt.bcc +MAGICPASS?= ${NETBSDSRCDIR}/minix/llvm/bin/magic.so + +DPADD+= ${LIBMAGICST} ${MAGICPASS} + +.for _P in ${PROGS:U${PROG}} +BITCODE_LD_FLAGS_1ST.${_P}?= ${LIBMAGICST} +.endfor + +MAGICFLAGS?= +OPTFLAGS+= -load ${MAGICPASS} -magic ${MAGICFLAGS} +.endif # ${USE_BITCODE:Uno} == "yes" && ${USE_MAGIC:Uno} == "yes" + .include diff --git a/share/mk/sys.mk b/share/mk/sys.mk index 76b0bd3d4..210c80958 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -22,6 +22,12 @@ CPPFLAGS+= -DNDEBUG DBG= -Os .endif +.if ${MKMAGIC:Uno} == "yes" +CPPFLAGS+= -D_MINIX_MAGIC=1 +STRIPFLAG= -s +DBG=-g +.endif + #LSC: Be a bit smarter about the default compiler .if exists(/usr/pkg/bin/clang) || exists(/usr/bin/clang) CC?= clang