./usr/include/zconf.h minix-sys
./usr/include/zlib.h minix-sys
./usr/lib minix-sys
+./usr/lib/bc minix-sys
./usr/lib/cawf minix-sys
./usr/lib/cawf/common minix-sys
./usr/lib/cawf/device.cf minix-sys
.include <bsd.own.mk>
+USE_BITCODE:=no
+
PROG= memory
SRCS= memory.c imgrd.mfs
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
.include <bsd.own.mk>
+USE_BITCODE:=no
+
install:
all:
./usr/include/ufs/mfs
./usr/include/ufs/ufs
./usr/lib
+./usr/lib/bc
./usr/lib/cawf
./usr/lib/dict
./usr/lib/flex
# Makefile for kernel
.include <bsd.own.mk>
+USE_BITCODE:=no
+
BINDIR= /usr/sbin
MAN=
PROG= kernel
.include "${.CURDIR}/net/Makefile.inc"
.include "${.CURDIR}/nameser/Makefile.inc"
.include "${.CURDIR}/nls/Makefile.inc"
-.if (${MACHINE_ARCH} != "alpha") && (${ARCHSUBDIR} != "sparc64")
+.if (${MACHINE_ARCH} != "alpha") && (${ARCHSUBDIR} != "sparc64") && ${USE_BITCODE:Uno} != "yes"
.include "${.CURDIR}/quad/Makefile.inc"
.endif
.if (${USE_LIBTRE} == "yes")
# NOTE: when changing ld.so, ensure that ldd still compiles.
#
+USE_BITCODE=no
+
WARNS?=4
# Minix Clang binaries references /libexec/ld.elf_so
__DPSRCS.d= ${__DPSRCS.all:O:u:M*.d}
__DPSRCS.notd= ${__DPSRCS.all:O:u:N*.d}
+.if defined(__MINIX)
+__DPSRCS.bcd= ${"${USE_BITCODE:Uno}" == "yes":? ${SRCS:M*.c:O:u:.c=.bcd}:}
+__DPSRCS.d+= ${__DPSRCS.bcd}
+.endif # defined(__MINIX)
+
.NOPATH: .depend ${__DPSRCS.d}
.if !empty(__DPSRCS.d) # {
rm -f .depend
${MKDEP} -d -f ${.TARGET} -s ${MKDEP_SUFFIXES:Q} ${__DPSRCS.d}
-.SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m
+.SUFFIXES: .bcd .d .s .S .c .C .cc .cpp .cxx .m
+
+.if ${USE_BITCODE:Uno} == "yes"
+.c.bcd:
+ ${_MKTARGET_CREATE}
+ ${MKDEP} -f ${.TARGET} -s .bc -- ${MKDEPFLAGS} \
+ ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \
+ ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
+.endif
.c.d:
${_MKTARGET_CREATE}
.endif
.endif
+.if ${USE_BITCODE:Uno} == "yes"
+.S.bc: ${.TARGET:.bc=.o}
+ rm -f ${.TARGET}
+ ln ${.TARGET:.bc=.o} ${.TARGET}
+.c.bc:
+ ${_MKTARGET_COMPILE}
+ ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o - -Qunused-arguments -E -D"__weak_alias(X, Y)=__weak_alias2( __WEAK__ ## X, __WEAK__ ## Y)" \
+ | sed 's/__WEAK__//g' \
+ | ${COMPILE.c} -flto ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -x c - -o ${.TARGET} -D"STRINGIFY(a)=#a" -D"__weak_alias2(X, Y)=_Pragma(STRINGIFY(weak X = Y))"
+.endif # ${USE_BITCODE:Uno} == "yes"
.c.o:
${_MKTARGET_COMPILE}
${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET}
_YLSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
+.if ${USE_BITCODE:Uno} == "yes"
+_LIBS+=lib${LIB}_bc.a
+.endif
+
.NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS}
realall: ${SRCS} ${ALLOBJS:O} ${_LIBS} ${_LIB.debug}
${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
+.if ${USE_BITCODE:Uno} == "yes"
+BCOBJS+=${OBJS:.o=.bc}
+lib${LIB}_bc.a:: ${BCOBJS}
+ ${_MKTARGET_BUILD}
+ rm -f ${.TARGET}
+ ${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*bc} | ${TSORT}`
+.endif
+
lib${LIB}.a:: ${STOBJS} __archivebuild
lib${LIB}_p.a:: ${POBJS} __archivebuild
rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${_LDFLAGS.lib${LIB}} \
-o ${.TARGET} ${_LIBLDOPTS} \
- -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${_LDADD.lib${LIB}}
+ -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${_LDADD.lib${LIB}} \
+ ${${USE_BITCODE:Uno} == "yes":? -Wl,-plugin=/usr/pkg/lib/bfd-plugins/LLVMgold.so -Wl,-plugin-opt=-disable-opt:}
# We don't use INSTALL_SYMLINK here because this is just
# happening inside the build directory/objdir. XXX Why does
# this spend so much effort on libraries that aren't live??? XXX
# use it here mimics the way it's used by the clean target in
# bsd.clean.mk.
#
-clean: libclean1 libclean2 libclean3 libclean4 libclean5
+clean: libclean1 libclean2 libclean3 libclean4 libclean5 libclean6
libclean1: .PHONY .MADE __cleanuse LIBCLEANFILES1
libclean2: .PHONY .MADE __cleanuse LIBCLEANFILES2
libclean3: .PHONY .MADE __cleanuse LIBCLEANFILES3
libclean4: .PHONY .MADE __cleanuse LIBCLEANFILES4
libclean5: .PHONY .MADE __cleanuse LIBCLEANFILES5
+libclean6: .PHONY .MADE __cleanuse LIBCLEANFILES6
CLEANFILES+= a.out [Ee]rrs mklog *.core
# core conflicts with core/ in lib/liblwip
.if !defined(__MINIX)
CLEANFILES+=core
+LIBCLEANFILES6+= lib${LIB}_bc.a ${BCOBJS} ${BCOBJS:=.tmp}
.endif
LIBCLEANFILES1+= lib${LIB}.a ${STOBJS} ${STOBJS:=.tmp}
LIBCLEANFILES2+= lib${LIB}_p.a ${POBJS} ${POBJS:=.tmp}
# Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
libinstall::
+.if ${USE_BITCODE:Uno} == "yes"
+libinstall:: ${DESTDIR}${LIBDIR}/bc/lib${LIB}.a
+.PRECIOUS: ${DESTDIR}${LIBDIR}/bc/lib${LIB}.a
+
+.if ${MKUPDATE} == "no"
+.if !defined(BUILD) && !make(all) && !make(lib${LIB}_bc.a)
+${DESTDIR}${LIBDIR}/bc/lib${LIB}.a! .MADE
+.endif
+${DESTDIR}${LIBDIR}/bc/lib${LIB}.a! lib${LIB}_bc.a __archiveinstall
+.else
+.if !defined(BUILD) && !make(all) && !make(lib${LIB}_bc.a)
+${DESTDIR}${LIBDIR}/bc/lib${LIB}.a: .MADE
+.endif
+${DESTDIR}${LIBDIR}/bc/lib${LIB}.a: lib${LIB}_bc.a __archiveinstall
+.endif
+.endif # ${USE_BITCODE:Uno} == "yes"
+
.if ${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
HAVE_GOLD?= ${_HAVE_GOLD}
CFLAGS+= -DHAVE_GOLD=${_HAVE_GOLD}
AFLAGS+= -DHAVE_GOLD=${_HAVE_GOLD}
+. else
+ MKBITCODE:=no
. endif
. endif # ${_HAVE_GOLD:U} == ""
. endif # ${USETOOLS:Uno} != "yes"
#MINIX-specific vars
_MKVARS.no+= \
- MKIMAGEONLY MKSMALL
+ MKIMAGEONLY MKSMALL MKBITCODE
.if (${MACHINE_ARCH} == "earm")
_MKVARS.no+= \
MKWATCHDOG MKACPI MKAPIC MKDEBUGREG MKINSTALLBOOT MKPCI
#MINIX-specific vars
.for var in \
USE_WATCHDOG USE_ACPI USE_APIC USE_MCONTEXT USE_DEBUGREG USE_SYSDEBUG \
- USE_LIVEUPDATE USE_STATECTL USE_TRACE USE_PCI
+ USE_LIVEUPDATE USE_STATECTL USE_TRACE USE_PCI USE_BITCODE
.if (${${var:S/USE_/MK/}} == "no")
${var}:= no
.else
.endfor
# Language-independent definitions.
+.if defined(__MINIX) && ${USE_BITCODE:Uno} == "yes"
+CFLAGS+= -flto
+.endif
+
.for _P in ${PROGS} ${PROGS_CXX} # {
.if defined(__MINIX) && ${HAVE_GOLD:U} != ""
+
+
. if ${LD_STATIC:U} != "-static"
GOLDLINKERSCRIPT?= ${LDS_DYNAMIC_BIN}
. else
${OBJS.${_P}} ${LOBJS.${_P}}: ${DPSRCS}
-${_P}: .gdbinit ${LIBCRT0} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${_DPADD.${_P}}
+.if defined(__MINIX)
+CLEANFILES+= ${_P}.opt.bcl ${_P}.bcl ${_P}.bcl.o
+.endif # defined(__MINIX)
+
.if !commands(${_P})
+.if ${USE_BITCODE:Uno} == "yes"
+
+.if ${LLVM_PASS:UNO_PASS} != "NO_PASS"
+_LLVM_PASS_ARGS= -load ${LLVM_PASS} ${LLVM_PASS_ARGS}
+_TARGET_BCL= ${_P}.opt.bcl
+.else
+_TARGET_BCL= ${_P}.bcl
+.endif # ${LLVM_PASS:UNO_PASS} != "NO_PASS"
+
+${_P}.bcl: .gdbinit ${LIBCRT0} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${_DPADD.${_P}}
+ ${_MKTARGET_LINK}
+ ${_CCLINK.${_P}} \
+ -o ${.TARGET} \
+ -nostartfiles \
+ -L/usr/lib/bc \
+ ${OBJS.${_P}} ${LLVM_LINK_ARGS} ${_LDADD.${_P}:N-shared} \
+ ${_LDSTATIC.${_P}} \
+ -Wl,-r \
+ -Wl,-plugin=/usr/pkg/lib/bfd-plugins/LLVMgold.so,-plugin-opt=-disable-opt,-plugin-opt=-disable-inlining,-plugin-opt=emit-llvm
+
+${_P}.opt.bcl: ${_P}.bcl ${LLVM_PASS}
+ ${_MKTARGET_LINK}
+ opt -disable-opt ${_LLVM_PASS_ARGS} -o ${.TARGET} ${_P}.bcl
+
+${_P}.bcl.o: ${_TARGET_BCL}
+ ${_MKTARGET_LINK}
+ llc -O1 -filetype=obj -o ${.TARGET} ${.ALLSRC}
+
+${_P}: ${_P}.bcl.o
+ ${_MKTARGET_LINK}
+ ${_CCLINK.${_P}} \
+ -o ${.TARGET} \
+ -L/usr/lib/bc \
+ ${.TARGET}.bcl.o ${_LDADD.${_P}} \
+ ${_LDSTATIC.${_P}} \
+ -Wl,--script,${GOLDLINKERSCRIPT.${_P}} \
+ -Wl,-plugin=/usr/pkg/lib/bfd-plugins/LLVMgold.so,-plugin-opt=-disable-opt,-plugin-opt=-disable-inlining
+
+.else
+${_P}: .gdbinit ${LIBCRT0} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${_DPADD.${_P}}
${_MKTARGET_LINK}
${_CCLINK.${_P}} \
${_LDFLAGS.${_P}} ${_LDSTATIC.${_P}} -o ${.TARGET} \
${OBJS.${_P}} ${_LDADD.${_P}} \
${_PROGLDOPTS}
+.endif # ${USE_BITCODE:Uno} == "yes"
.if defined(CTFMERGE)
${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${OBJS.${_P}}
.endif
.if ${MKSTRIPIDENT} != "no"
${OBJCOPY} -R .ident ${.TARGET}
.endif
+.else
+${_P}: .gdbinit ${LIBCRT0} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${_DPADD.${_P}}
.endif # !commands(${_P})
.endif # USE_COMBINE
.endif # defined(__MINIX)
unix?= We run NetBSD.
-.SUFFIXES: .a .o .ln .s .S .c .cc .cpp .cxx .C .f .F .r .p .l .y .sh
+.SUFFIXES: .a .o .bc .ln .s .S .c .cc .cpp .cxx .C .f .F .r .p .l .y .sh
.LIBS: .a
# When using gold linker, specify the linker script
GOLDLINKERSCRIPT?= ${LDS_N}
+USE_BITCODE=no
# use MINIX minc
LIBKERN= ${DESTDIR}/usr/lib/libminc.a
# When using gold linker, specify the linker script
GOLDLINKERSCRIPT?= ${LDS_N}
+USE_BITCODE=no
# use MINIX minc
LIBKERN= ${DESTDIR}/usr/lib/libminc.a
# building. See library's Makefile for more details about
# supported flags and their default values.
+USE_BITCODE=no
+
# Default values:
I386DST?= ${.OBJDIR}/lib/i386
__asm(".global " _C_LABEL_STRING(#alias) "\n" \
_C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
+#if defined(__minix) && !defined(__weak_alias) /* For bitcode support */
#define __weak_alias(alias,sym) \
__asm(".weak " _C_LABEL_STRING(#alias) "\n" \
_C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
+#endif
/* Do not use __weak_extern, use __weak_reference instead */
#define __weak_extern(sym) \
PROGS += testvm
OBJS.testvm+= testcache.o
-LDADD.testvm+= -lsys -ltimers -lminlib -static
+LDFLAGS.testvm+= -static
+LDADD.testvm+= -lsys -ltimers -lminlib
FILES += testvm.conf
# use the shared linkerscript for mod when using the gold linker
GOLDLINKERSCRIPT.mod?= ${${HAVE_GOLD:Uno} != "no":? ${LDS_SHARED_LIB} :}
-GOLDLINKERSCRIPT=
+LDADD.mod+= ${${USE_BITCODE:Uno} != "no":? -shared:}
+# test57loop.S is not linked into the .bcl file.
+# This way, we can link it in when linking the final binary
+LDADD.test57+= ${${USE_BITCODE:Uno} != "no":? test57loop.o -Wl,-allow-multiple-definition:}
# Add test that must be linked dynamically, and its dynamically loaded
# module