Index: Makefile.inc1 =================================================================== --- Makefile.inc1 +++ Makefile.inc1 @@ -63,7 +63,7 @@ CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX} .endif -XCOMPILERS= CC CXX CPP +XCOMPILERS= CC CXX CPP LLVM_LINK .for COMPILER in ${XCOMPILERS} .if defined(CROSS_COMPILER_PREFIX) X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}} Index: Makefile.libcompat =================================================================== --- Makefile.libcompat +++ Makefile.libcompat @@ -20,7 +20,7 @@ LIB32WMAKEFLAGS= \ AS="${XAS} --32" \ LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32" \ - OBJCOPY="${XOBJCOPY}" + LLVM_LINK="${XLLVM_LINK}" OBJCOPY="${XOBJCOPY}" .elif ${TARGET_ARCH} == "powerpc64" .if empty(TARGET_CPUTYPE) @@ -175,6 +175,7 @@ MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \ DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ + MK_LLVM_BITCODE=no \ build-tools .endfor ${_+_}cd ${.CURDIR}; \ Index: share/mk/bsd.lib.mk =================================================================== --- share/mk/bsd.lib.mk +++ share/mk/bsd.lib.mk @@ -183,6 +183,21 @@ ${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' \ ${LORDER} ${OBJS} ${STATICOBJS} | ${TSORT} ${TSORTFLAGS}` ${ARADD} ${RANLIB} ${RANLIBFLAGS} ${.TARGET} + +.if ${MK_LLVM_BITCODE} != "no" && !defined(BOOTSTRAPPING) +.if !defined(LLVM_LINK) +.error "Cannot build lib${LIB_PRIVATE}${LIB}.{bc,ll} without XLLVM_LINK" +.endif + +lib${LIB_PRIVATE}${LIB}.bc: ${BCOBJS} + ${LLVM_LINK} -o ${.TARGET} ${BCOBJS} + +lib${LIB_PRIVATE}${LIB}.ll: ${LLOBJS} + ${LLVM_LINK} -S -o ${.TARGET} ${LLOBJS} + +CLEANFILES+= lib${LIB_PRIVATE}${LIB}.bc lib${LIB_PRIVATE}${LIB}.ll +_LIBS+= lib${LIB_PRIVATE}${LIB}.${LLVM_IR_TYPE} +.endif # ${MK_LLVM_BITCODE} != "no" && !defined(BOOTSTRAPPING) .endif .if !defined(INTERNALLIB) @@ -201,16 +216,6 @@ ${RANLIB} ${RANLIBFLAGS} ${.TARGET} .endif -.if defined(LLVM_LINK) -lib${LIB_PRIVATE}${LIB}.bc: ${BCOBJS} - ${LLVM_LINK} -o ${.TARGET} ${BCOBJS} - -lib${LIB_PRIVATE}${LIB}.ll: ${LLOBJS} - ${LLVM_LINK} -S -o ${.TARGET} ${LLOBJS} - -CLEANFILES+= lib${LIB_PRIVATE}${LIB}.bc lib${LIB_PRIVATE}${LIB}.ll -.endif - .if defined(SHLIB_NAME) || \ defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) SOBJS+= ${OBJS:.o=.pico} @@ -350,6 +355,10 @@ .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no" ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}.a ${DESTDIR}${_LIBDIR}/ +.if ${MK_LLVM_BITCODE} != "no" && !defined(BOOTSTRAPPING) + ${INSTALL} ${TAG_ARGS} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}.bc ${DESTDIR}${_LIBDIR}/ +.endif .endif .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB) ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},profile} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ Index: share/mk/bsd.opts.mk =================================================================== --- share/mk/bsd.opts.mk +++ share/mk/bsd.opts.mk @@ -72,6 +72,7 @@ CCACHE_BUILD \ CTF \ INSTALL_AS_USER \ + LLVM_BITCODE \ STALE_STAGED __DEFAULT_DEPENDENT_OPTIONS = \ Index: share/mk/bsd.prog.mk =================================================================== --- share/mk/bsd.prog.mk +++ share/mk/bsd.prog.mk @@ -154,7 +154,10 @@ ${OBJCOPY} --only-keep-debug ${PROG_FULL} ${.TARGET} .endif -.if defined(LLVM_LINK) +.if ${MK_LLVM_BITCODE} != "no" && !defined(BOOTSTRAPPING) +.if !defined(LLVM_LINK) +.error "Cannot build ${PROG_FULL}.{bc,ll} without XLLVM_LINK" +.endif ${PROG_FULL}.bc: ${BCOBJS} ${LLVM_LINK} -o ${.TARGET} ${BCOBJS} Index: share/mk/src.opts.mk =================================================================== --- share/mk/src.opts.mk +++ share/mk/src.opts.mk @@ -180,6 +180,7 @@ GNU_GREP_COMPAT \ HESIOD \ LIBSOFT \ + LLVM_BITCODE \ LOADER_FORCE_LE \ NAND \ OFED \ Index: share/mk/sys.mk =================================================================== --- share/mk/sys.mk +++ share/mk/sys.mk @@ -244,7 +244,7 @@ MAKE ?= make .if !defined(%POSIX) -LLVM_LINK ?= llvm-link +LLVM_IR_TYPE ?= bc LORDER ?= lorder Index: tools/build/options/WITH_LLVM_BITCODE =================================================================== --- /dev/null +++ tools/build/options/WITH_LLVM_BITCODE @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +When set, LLVM bitcode versions of libraries and programs will be built and +installed alongside conventional, binary (i.e., ELF) files.