From 4f2fac37593702eae572eecb2ce6aafeee09eb18 Mon Sep 17 00:00:00 2001 From: Jonathan Anderson Date: Wed, 18 Oct 2017 00:33:20 +0000 Subject: [PATCH] Improve computation of {BC,LL}OBJS. Now that OBJS has grown an OBJS_SRCS_FILTER variable, use this variable in the computation of BCOBJS and LLOBJS too. Also move BCOBJS and LLOBJS computation to be next to the OBJS computation: this should both make the parallel structure clearer and serve to remind people changing OBJS that parallel changes are required in BCOBJS and LLOBJS. A side effect of this change is that BCOBJS and LLOBJS will be available even when LLVM_LINK has not been defined, but that seems like a positive change: there's no reason we can't ask "what bitcode files would you generate" just because we can't link those files together into a complete bitcode representation of a binary or library. Reviewed by: sjg Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D12701 --- share/mk/bsd.lib.mk | 8 +++----- share/mk/bsd.prog.mk | 13 ++++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index dc282ac2a27..d3e4d7839cf 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -169,7 +169,9 @@ LDFLAGS+= -Wl,--version-script=${VERSION_MAP} .if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME) OBJS+= ${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.o/} -CLEANFILES+= ${OBJS} ${STATICOBJS} +BCOBJS+= ${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.bco/g} +LLOBJS+= ${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.llo/g} +CLEANFILES+= ${OBJS} ${BCOBJS} ${LLOBJS} ${STATICOBJS} .endif .if defined(LIB) && !empty(LIB) @@ -200,10 +202,6 @@ lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS} .endif .if defined(LLVM_LINK) -BCOBJS= ${OBJS:.o=.bco} ${STATICOBJS:.o=.bco} -LLOBJS= ${OBJS:.o=.llo} ${STATICOBJS:.o=.llo} -CLEANFILES+= ${BCOBJS} ${LLOBJS} - lib${LIB_PRIVATE}${LIB}.bc: ${BCOBJS} ${LLVM_LINK} -o ${.TARGET} ${BCOBJS} diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 6c5b771176f..a3129a8cdca 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -87,6 +87,10 @@ PROGNAME?= ${PROG} OBJS+= ${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.o/g} +# LLVM bitcode / textual IR representations of the program +BCOBJS+=${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.bco/g} +LLOBJS+=${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.llo/g} + .if target(beforelinking) beforelinking: ${OBJS} ${PROG_FULL}: beforelinking @@ -117,7 +121,10 @@ SRCS= ${PROG}.c # - the name of the object gets put into the executable symbol table instead of # the name of a variable temporary object. # - it's useful to keep objects around for crunching. -OBJS+= ${PROG}.o +OBJS+= ${PROG}.o +BCOBJS+= ${PROG}.bc +LLOBJS+= ${PROG}.ll +CLEANFILES+= ${PROG}.o ${PROG}.bc ${PROG}.ll .if target(beforelinking) beforelinking: ${OBJS} @@ -148,10 +155,6 @@ ${PROGNAME}.debug: ${PROG_FULL} .endif .if defined(LLVM_LINK) -# LLVM bitcode / textual IR representations of the program -BCOBJS= ${OBJS:.o=.bco} -LLOBJS= ${OBJS:.o=.llo} - ${PROG_FULL}.bc: ${BCOBJS} ${LLVM_LINK} -o ${.TARGET} ${BCOBJS}