diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-06-22 15:00:00 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-06-22 15:00:00 +0000 |
commit | cbafd2630b811d90130261b97421f246d8ea2a50 (patch) | |
tree | c7023b0e92ac34a32f2af9ef17494c8d4808c3a5 /lib/clang/llvm.build.mk | |
parent | 7e8db78116c568e5282a1543318ec283c08fe5ba (diff) | |
download | src-cbafd2630b811d90130261b97421f246d8ea2a50.tar.gz src-cbafd2630b811d90130261b97421f246d8ea2a50.zip |
Add support for selectively enabling LLVM targets
This makes it possible, through src.conf(5) settings, to select which
LLVM targets you want to build during buildworld. The current list is:
* (WITH|WITHOUT)_LLVM_TARGET_AARCH64
* (WITH|WITHOUT)_LLVM_TARGET_ARM
* (WITH|WITHOUT)_LLVM_TARGET_MIPS
* (WITH|WITHOUT)_LLVM_TARGET_POWERPC
* (WITH|WITHOUT)_LLVM_TARGET_SPARC
* (WITH|WITHOUT)_LLVM_TARGET_X86
To not influence anything right now, all of these are on by default, in
situations where clang is enabled.
Selectively turning a few targets off manually should work. Turning on
only one target should work too, even if that target does not correspond
to the build architecture. (In that case, LLVM_NATIVE_ARCH will not be
defined, and you can only use the resulting clang executable for
cross-compiling.)
I performed a few measurements on one of the FreeBSD.org reference
machines, building clang from scratch, with all targets enabled, and
with only the x86 target enabled. The latter was ~12% faster in real
time (on a 32-core box), and ~14% faster in user time. For a full
buildworld the difference will probably be less pronounced, though.
Reviewed by: bdrewery
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D11077
Notes
Notes:
svn path=/head/; revision=335558
Diffstat (limited to 'lib/clang/llvm.build.mk')
-rw-r--r-- | lib/clang/llvm.build.mk | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/clang/llvm.build.mk b/lib/clang/llvm.build.mk index 861b97a37172..b8b4d9b0500e 100644 --- a/lib/clang/llvm.build.mk +++ b/lib/clang/llvm.build.mk @@ -1,5 +1,7 @@ # $FreeBSD$ +.include <src.opts.mk> + .ifndef LLVM_SRCS .error Please define LLVM_SRCS before including this file .endif @@ -40,6 +42,52 @@ CFLAGS+= -DLLVM_DEFAULT_TARGET_TRIPLE=\"${LLVM_TARGET_TRIPLE}\" CFLAGS+= -DLLVM_HOST_TRIPLE=\"${LLVM_BUILD_TRIPLE}\" CFLAGS+= -DDEFAULT_SYSROOT=\"${TOOLS_PREFIX}\" +.if ${MK_LLVM_TARGET_AARCH64} != "no" +CFLAGS+= -DLLVM_TARGET_ENABLE_AARCH64 +. if ${MACHINE_CPUARCH} == "aarch64" +LLVM_NATIVE_ARCH= AArch64 +. endif +.endif +.if ${MK_LLVM_TARGET_ARM} != "no" +CFLAGS+= -DLLVM_TARGET_ENABLE_ARM +. if ${MACHINE_CPUARCH} == "arm" +LLVM_NATIVE_ARCH= ARM +. endif +.endif +.if ${MK_LLVM_TARGET_MIPS} != "no" +CFLAGS+= -DLLVM_TARGET_ENABLE_MIPS +. if ${MACHINE_CPUARCH} == "mips" +LLVM_NATIVE_ARCH= Mips +. endif +.endif +.if ${MK_LLVM_TARGET_POWERPC} != "no" +CFLAGS+= -DLLVM_TARGET_ENABLE_POWERPC +. if ${MACHINE_CPUARCH} == "powerpc" +LLVM_NATIVE_ARCH= PowerPC +. endif +.endif +.if ${MK_LLVM_TARGET_SPARC} != "no" +CFLAGS+= -DLLVM_TARGET_ENABLE_SPARC +. if ${MACHINE_CPUARCH} == "sparc64" +LLVM_NATIVE_ARCH= Sparc +. endif +.endif +.if ${MK_LLVM_TARGET_X86} != "no" +CFLAGS+= -DLLVM_TARGET_ENABLE_X86 +. if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" +LLVM_NATIVE_ARCH= X86 +. endif +.endif + +.ifdef LLVM_NATIVE_ARCH +CFLAGS+= -DLLVM_NATIVE_ASMPARSER=LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser +CFLAGS+= -DLLVM_NATIVE_ASMPRINTER=LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter +CFLAGS+= -DLLVM_NATIVE_DISASSEMBLER=LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler +CFLAGS+= -DLLVM_NATIVE_TARGET=LLVMInitialize${LLVM_NATIVE_ARCH}Target +CFLAGS+= -DLLVM_NATIVE_TARGETINFO=LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo +CFLAGS+= -DLLVM_NATIVE_TARGETMC=LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC +.endif + CFLAGS+= -ffunction-sections CFLAGS+= -fdata-sections LDFLAGS+= -Wl,--gc-sections |