]> Zhao Yanbai Git Server - minix.git/commitdiff
kernel: Add bitcode support.
authorCristiano Giuffrida <giuffrida@cs.vu.nl>
Wed, 16 Jul 2014 12:14:05 +0000 (14:14 +0200)
committerLionel Sambuc <lionel@minix3.org>
Mon, 28 Jul 2014 15:06:13 +0000 (17:06 +0200)
kernel/Makefile
kernel/arch/i386/Makefile.inc

index aa9f066e245f0c771001eb626cf4c03349d1da22..546658b66baa69c2a077a24c5ce49a5bcee78ce8 100644 (file)
@@ -4,7 +4,6 @@
 PROG=          kernel
 BINDIR=                /usr/sbin
 MAN=
-USE_BITCODE=   no
 
 .include "arch/${MACHINE_ARCH}/Makefile.inc"
 
@@ -77,4 +76,16 @@ extracted-mtype.h: extract-mtype.sh ../include/minix/com.h
        ${_MKTARGET_CREATE}
        cd ${.CURDIR} ; ${HOST_SH} extract-mtype.sh > ${.OBJDIR}/extracted-mtype.h
 
+.if ${USE_BITCODE:Uno} == "yes"
+kernel: kernel.bcl.o
+       ${_MKTARGET_LINK}
+       ${_CCLINK.kernel} \
+               ${_LDFLAGS.kernel} \
+               -L${DESTDIR}/usr/lib \
+               ${_LDSTATIC.kernel} -o ${.TARGET} \
+               ${.TARGET}.bcl.o ${OBJS} ${_PROGLDOPTS} ${_LDADD.kernel} \
+               ${BITCODE_LD_FLAGS_2ND.kernel} \
+               -Wl,--allow-multiple-definition
+.endif
+
 .include <minix.service.mk>
index b9149f34b02915ee18ba284d4e624b9e437ee65e..2fc957a22c05156d20cc9a7d0778df5da5d32b97 100644 (file)
@@ -52,8 +52,20 @@ CPPFLAGS.subr_prf.c+= -DLIBSA_PRINTF_LONGLONG_SUPPORT -DLIBSA_PRINTF_WIDTH_SUPPO
        pg_utils.o klib.o utility.o arch_reset.o \
        io_inb.o io_outb.o \
        ${MINLIB_OBJS_UNPAGED} ${MINC_OBJS_UNPAGED} ${SYS_OBJS_UNPAGED}
+
+CLEANFILES+=${unpaged_obj}.bin
+.if ${USE_BITCODE:Uno} == "yes"
+unpaged_${unpaged_obj}: ${unpaged_obj}
+       if file -b ${.OBJDIR}/${unpaged_obj} | grep -q '^LLVM'; then \
+               ${LLC} -O1 -march=x86 -mcpu=i586 -filetype=obj -o ${.OBJDIR}/${unpaged_obj}.bin ${.OBJDIR}/${unpaged_obj}; \
+       else \
+               cp ${.OBJDIR}/${unpaged_obj} ${.OBJDIR}/${unpaged_obj}.bin; \
+       fi
+       ${OBJCOPY} --prefix-symbols=__k_unpaged_ ${.OBJDIR}/${unpaged_obj}.bin $@
+.else
 unpaged_${unpaged_obj}: ${unpaged_obj}
        ${OBJCOPY} --prefix-symbols=__k_unpaged_ ${.OBJDIR}/${unpaged_obj} $@
+.endif
 UNPAGED_OBJS += unpaged_${unpaged_obj}
 ORIG_UNPAGED_OBJS += ${unpaged_obj}
 .endfor
@@ -104,7 +116,7 @@ PROCOFFSETSCF=procoffsets.cf
 procoffsets.h: ${PROCOFFSETSCF} kernel.h proc.h stackframe.h archtypes.h
        ${_MKTARGET_CREATE}
        ${TOOL_CAT} ${HERE}/${PROCOFFSETSCF} | \
-         ${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} >$@.tmp && \
+         ${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${${USE_BITCODE:Uno} == "yes":? -fno-lto:} >$@.tmp && \
          mv -f $@.tmp $@ 
 
 sconst.h: procoffsets.h