Date: Mon, 25 Feb 2013 18:46:07 GMT From: Brooks Davis <brooks@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 222354 for review Message-ID: <201302251846.r1PIk7Or056841@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@222354?ac=10 Change 222354 by brooks@brooks_zenith on 2013/02/25 18:46:05 Checkpoint a set of rules to build llvm bitcode files for programs and libraries. Affected files ... .. //depot/projects/ctsrd/tesla/src/share/mk/bsd.lib.mk#2 edit .. //depot/projects/ctsrd/tesla/src/share/mk/bsd.prog.mk#2 edit .. //depot/projects/ctsrd/tesla/src/share/mk/sys.mk#2 edit Differences ... ==== //depot/projects/ctsrd/tesla/src/share/mk/bsd.lib.mk#2 (text+ko) ==== @@ -48,7 +48,7 @@ # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries # .So used for PIC object files .SUFFIXES: -.SUFFIXES: .out .o .po .So .S .asm .s .c .cc .cpp .cxx .C .f .y .l .ln +.SUFFIXES: .out .o .po .So .S .asm .s .c .cc .cpp .cxx .C .f .y .l .obc .ln .if !defined(PICFLAG) .if ${MACHINE_CPUARCH} == "sparc64" @@ -60,6 +60,9 @@ PO_FLAG=-pg +.c.obc: + ${CC} -c -g -emit-llvm ${CFLAGS} ${.IMPSRC} -o ${.TARGET} + .c.o: ${CC} ${STATIC_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} @@ -138,6 +141,29 @@ @${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD} .endif ${RANLIB} ${.TARGET} + +.if defined(LLVM_IR) && !defined(NO_LLVM_IR) +_LIBS+= lib${LIB}.bc lib${LIB}.bc-opt +# XXX: force expantion now to avoid picking up generated C code. +# Ideally we do want it, but there is an undiagnosed dependency issue that +# causes the .obc file to not be built. +LOBJS:= ${SRCS:M*.[Cc]:R:S/$/.obc/:N.obc} \ + ${SRCS:M*.cc:R:S/$/.obc/:N.obc} \ + ${SRCS:M*.cpp:R:S/$/.obc/:N.obc} \ + ${SRCS:M*.cxx:R:S/$/.obc/:N.obc} +LLVM_LINK?= llvm-link + +lib${LIB}.bc: ${LOBJS} + ${LLVM_LINK} -o ${.TARGET} ${LOBJS} + +lib${LIB}.bc-opt: lib${LIB}.bc +.if empty(OPT_PASSES) + cp lib${LIB}.bc ${.TARGET} +.else + ${OPT} -o ${.TARGET} ${OPT_PASSES} ${.ALLSRC} +.endif + +.endif .endif .if !defined(INTERNALLIB) @@ -380,6 +406,9 @@ .endif .if defined(LIB) && !empty(LIB) rm -f a.out ${OBJS} ${OBJS:S/$/.tmp/} ${STATICOBJS} +.if defined(LLVM_IR) + rm -f ${LOBJS} +.endif .endif .if !defined(INTERNALLIB) .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB) ==== //depot/projects/ctsrd/tesla/src/share/mk/bsd.prog.mk#2 (text+ko) ==== @@ -1,4 +1,4 @@ -# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 +# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 # $FreeBSD: head/share/mk/bsd.prog.mk 245515 2013-01-16 23:21:04Z brooks $ .include <bsd.init.mk> @@ -92,6 +92,28 @@ .endif # !defined(SRCS) +.if defined(LLVM_IR) && !defined(NO_LLVM_IR) +LOBJS:= ${SRCS:M*.[Cc]:R:S/$/.obc/:N.obc} \ + ${SRCS:M*.cc:R:S/$/.obc/:N.obc} \ + ${SRCS:M*.cpp:R:S/$/.obc/:N.obc} \ + ${SRCS:M*.cxx:R:S/$/.obc/:N.obc} +CLEANFILES+= ${PROG}.bc ${LOBJS} + +.if !empty(LOBJS) +all: ${PROG}.bc +${PROG}.bc: ${LOBJS} + ${LLVM_LINK} -o ${.TARGET} ${LOBJS} + +all: ${PROG}.bc-opt +${PROG}.bc-opt: ${PROG}.bc +.if empty(OPT_PASSES) + cp ${PROG}.bc ${.TARGET} +.else + ${OPT} -o ${.TARGET} ${OPT_PASSES} ${.IMPSRC} +.endif +.endif +.endif + .if ${MK_MAN} != "no" && !defined(MAN) && \ !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ ==== //depot/projects/ctsrd/tesla/src/share/mk/sys.mk#2 (text+ko) ==== @@ -32,7 +32,7 @@ .if defined(%POSIX) .SUFFIXES: .o .c .y .l .a .sh .f .else -.SUFFIXES: .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh +.SUFFIXES: .out .a .obc .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh .endif AR ?= ar @@ -125,6 +125,10 @@ LINTOBJKERNFLAGS?= ${LINTOBJFLAGS} LINTLIBFLAGS ?= -cghapbxu -C ${LIB} +LLC ?= llc + +LLVM_LINK ?= llvm-link + MAKE ?= make .if !defined(%POSIX) @@ -135,6 +139,8 @@ OBJCOPY ?= objcopy +OPT ?= opt + PC ?= pc PFLAGS ?= @@ -222,6 +228,9 @@ cp -fp ${.IMPSRC} ${.TARGET} chmod a+x ${.TARGET} +.c.obc: + ${CC} ${CFLAGS} -cc1 -emit-llvm -c ${.IMPSRC} -o ${.TARGET} + .c.ln: ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \ touch ${.TARGET} @@ -241,6 +250,9 @@ .cc .cpp .cxx .C: ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} +.cc.obc .C.obc .cpp.obc .cxx.obc: + ${CXX} ${CXXFLAGS} -cc1 -emit-llvm -c ${.IMPSRC} -o ${.TARGET} + .cc.o .cpp.o .cxx.o .C.o: ${CXX} ${CXXFLAGS} -c ${.IMPSRC}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302251846.r1PIk7Or056841>