]> Zhao Yanbai Git Server - minix.git/commitdiff
Integrate magic instrumentation into build system 34/3234/2
authorDavid van Moolenbroek <david@minix3.org>
Fri, 13 Nov 2015 00:29:26 +0000 (01:29 +0100)
committerLionel Sambuc <lionel.sambuc@gmail.com>
Wed, 13 Jan 2016 19:32:33 +0000 (20:32 +0100)
Magic instrumentation is now performed on all system services if the
system is built with MKMAGIC=yes, which implies MKBITCODE=yes.

Change-Id: I9d1233650188b7532a9356b720fb68d5f8248939

minix/kernel/Makefile
minix/llvm/configure.llvm
minix/servers/vm/Makefile
share/mk/minix.service.mk
share/mk/sys.mk

index 514571e0c8764faf12262adb194373ff33313f01..41573f4cb5a499008da4dab8a203ee773a8110cd 100644 (file)
@@ -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 <minix.service.mk>
index 276b286265946e5bdd5cc723cef472c84843e1a8..ca4cf2c60816728abff6e63229e9fcf8aac9ba4a 100755 (executable)
@@ -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
 
index 8cacb46c7c007c64302583c262999b4835de049d..bd874a732188c4effdfed61906ce1415e34a0597 100644 (file)
@@ -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 <minix.service.mk>
index f09130b630b236400126c7d839ee9968451b8894..1ee48138829a7259139b6be17c3fa647b6baff35 100644 (file)
@@ -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 <bsd.prog.mk>
index 76b0bd3d4cdb4143ee4fb4b4c14b46b38be2bd1e..210c80958486835ae3ea025245ae886d1c272e5f 100644 (file)
@@ -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