libmagicrt: integrate into build system

The magic runtime library is now built as part of the regular build, if
the MKMAGIC=yes flag is passed to the build system.  The library has
been renamed from "magic" to "magicrt" to resolve a name clash with BSD
file(1)'s libmagic.  All its level-5 LLVM warnings have been resolved.
 The final library, "libmagicrt.bcc", is now stored in the destination
library directory rather than in the source tree.

Change-Id: Iebd4b93a2cafbb59f95d938ad1edb8b4f6e729f6
This commit is contained in:
David van Moolenbroek
2015-11-11 13:43:01 +01:00
committed by Lionel Sambuc
parent 23199f6205
commit b2ed49a5d8
50 changed files with 388 additions and 480 deletions

View File

@@ -213,6 +213,17 @@ SHLIB_SHFLAGS+= -Wl,-plugin=${GOLD_PLUGIN} \
-Wl,-plugin-opt=-disable-opt
SECTIONIFYPASS?=${NETBSDSRCDIR}/minix/llvm/bin/sectionify.so
# dcvmoole: the following construction is a hack for libmagicrt. For reasons
# not entirely under our control, clang refuses to take .bc objects even when
# using the gold linker, saying that LLVM IR code cannot be linked. In order
# to sidestep this, libmagicrt uses the name "foo.bc.o" instead of "foo.bc" to
# link the its LLVM IR objects. As all libmagicrt modules use the sectionify
# pass below, and this step needs temporary files, we give the temporary files
# the .o suffix (while anything would do!), and allow the libmagicrt makefile
# to override the rename to the real file name to perform a copy instead. As
# a result, libmagicrt ends up with both the .bc and .bc.o objects, and it can
# pass the latter set to clang, bypassing clang's overly strict checks.
SECTIONIFYMV?=mv -f
.S.bc: ${.TARGET:.bc=.o}
rm -f ${.TARGET}
@@ -220,8 +231,8 @@ SECTIONIFYPASS?=${NETBSDSRCDIR}/minix/llvm/bin/sectionify.so
.c.bc:
${_MKTARGET_COMPILE}
${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} -flto
if [ -n '${SECTIONIFY.${.IMPSRC:T}}' ]; then \
${OPT} -load ${SECTIONIFYPASS} -sectionify ${SECTIONIFY.${.IMPSRC:T}} -o ${.TARGET}.tmp ${.TARGET} && mv -f ${.TARGET}.tmp ${.TARGET}; \
if [ -n '${SECTIONIFY.${.IMPSRC:T}:U${SECTIONIFY}}' ]; then \
${OPT} -load ${SECTIONIFYPASS} -sectionify ${SECTIONIFY.${.IMPSRC:T}:U${SECTIONIFY}} -o ${.TARGET}.o ${.TARGET} && ${SECTIONIFYMV} ${.TARGET}.o ${.TARGET}; \
fi
.cc.bc .cxx.bc .cpp.bc:
@@ -545,7 +556,9 @@ SOBJS=
_YLSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
.if ${USE_BITCODE:Uno} == "yes"
.if defined(LIB)
_LIBS+=${_LIB_bc.a}
.endif
.endif # ${USE_BITCODE:Uno} == "yes"
.NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS}

View File

@@ -1305,7 +1305,7 @@ _MKVARS.no= \
#MINIX-specific vars
_MKVARS.no+= \
MKIMAGEONLY MKSMALL MKBITCODE MKSRC
MKIMAGEONLY MKSMALL MKBITCODE MKMAGIC MKSRC
.if !empty(MACHINE_ARCH:Mearm*)
_MKVARS.no+= \
MKWATCHDOG MKACPI MKAPIC MKDEBUGREG MKINSTALLBOOT MKPCI
@@ -1411,6 +1411,11 @@ MKSYSDEBUG:= no
MKLIVEUPDATE:= no
.endif
# MINIX: MKMAGIC implies MKBITCODE
.if ${MKMAGIC} == "yes"
MKBITCODE:= yes
.endif
.if !empty(MACHINE_ARCH:Mearm*)
_NEEDS_LIBCXX.${MACHINE_ARCH}= yes
.endif
@@ -1487,7 +1492,7 @@ ${var}?= yes
#MINIX-specific vars
.for var in \
USE_WATCHDOG USE_ACPI USE_APIC USE_DEBUGREG USE_SYSDEBUG \
USE_LIVEUPDATE USE_PCI USE_BITCODE
USE_LIVEUPDATE USE_PCI USE_BITCODE USE_MAGIC
.if (${${var:S/USE_/MK/}} == "no")
${var}:= no
.else