1# $FreeBSD$ 2 3.include <src.opts.mk> 4 5.ifndef LLVM_BASE 6.error Please define LLVM_BASE before including this file 7.endif 8 9.ifndef LLVM_SRCS 10.error Please define LLVM_SRCS before including this file 11.endif 12 13.ifndef SRCDIR 14.error Please define SRCDIR before including this file 15.endif 16 17.ifndef OS_REVISION 18.error Please define OS_REVISION before including this file 19.endif 20 21.PATH: ${LLVM_BASE}/${SRCDIR} 22 23CFLAGS+= -I${SRCTOP}/lib/clang/include 24CFLAGS+= -I${LLVM_SRCS}/include 25CFLAGS+= -D__STDC_CONSTANT_MACROS 26CFLAGS+= -D__STDC_FORMAT_MACROS 27CFLAGS+= -D__STDC_LIMIT_MACROS 28CFLAGS+= -DHAVE_VCS_VERSION_INC 29.if ${MK_LLVM_ASSERTIONS} == "no" 30CFLAGS+= -DNDEBUG 31.endif 32 33TARGET_ARCH?= ${MACHINE_ARCH} 34BUILD_ARCH?= ${MACHINE_ARCH} 35 36# Armv6 and armv7 uses hard float abi, unless the CPUTYPE has soft in it. 37# arm (for armv4 and armv5 CPUs) always uses the soft float ABI. 38# For all other targets, we stick with 'unknown'. 39.if ${TARGET_ARCH:Marmv[67]*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") 40TARGET_ABI= -gnueabihf 41.elif ${TARGET_ARCH:Marm*} 42TARGET_ABI= -gnueabi 43.else 44TARGET_ABI= 45.endif 46VENDOR= unknown 47 48LLVM_TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${VENDOR}-freebsd${OS_REVISION}${TARGET_ABI} 49LLVM_BUILD_TRIPLE?= ${BUILD_ARCH:C/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${VENDOR}-freebsd${OS_REVISION} 50 51CFLAGS+= -DLLVM_DEFAULT_TARGET_TRIPLE=\"${LLVM_TARGET_TRIPLE}\" 52CFLAGS+= -DLLVM_HOST_TRIPLE=\"${LLVM_BUILD_TRIPLE}\" 53CFLAGS+= -DDEFAULT_SYSROOT=\"${TOOLS_PREFIX}\" 54 55.if ${MK_LLVM_TARGET_AARCH64} != "no" 56CFLAGS+= -DLLVM_TARGET_ENABLE_AARCH64 57. if ${MACHINE_CPUARCH} == "aarch64" 58LLVM_NATIVE_ARCH= AArch64 59. endif 60.endif 61.if ${MK_LLVM_TARGET_ARM} != "no" 62CFLAGS+= -DLLVM_TARGET_ENABLE_ARM 63. if ${MACHINE_CPUARCH} == "arm" 64LLVM_NATIVE_ARCH= ARM 65. endif 66.endif 67.if ${MK_LLVM_TARGET_BPF} != "no" 68CFLAGS+= -DLLVM_TARGET_ENABLE_BPF 69.endif 70.if ${MK_LLVM_TARGET_MIPS} != "no" 71CFLAGS+= -DLLVM_TARGET_ENABLE_MIPS 72. if ${MACHINE_CPUARCH} == "mips" 73LLVM_NATIVE_ARCH= Mips 74. endif 75.endif 76.if ${MK_LLVM_TARGET_POWERPC} != "no" 77CFLAGS+= -DLLVM_TARGET_ENABLE_POWERPC 78. if ${MACHINE_CPUARCH} == "powerpc" 79LLVM_NATIVE_ARCH= PowerPC 80. endif 81.endif 82.if ${MK_LLVM_TARGET_RISCV} != "no" 83CFLAGS+= -DLLVM_TARGET_ENABLE_RISCV 84. if ${MACHINE_CPUARCH} == "riscv" 85LLVM_NATIVE_ARCH= RISCV 86. endif 87.endif 88.if ${MK_LLVM_TARGET_X86} != "no" 89CFLAGS+= -DLLVM_TARGET_ENABLE_X86 90. if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 91LLVM_NATIVE_ARCH= X86 92. endif 93.endif 94 95.ifdef LLVM_NATIVE_ARCH 96CFLAGS+= -DLLVM_NATIVE_ASMPARSER=LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser 97CFLAGS+= -DLLVM_NATIVE_ASMPRINTER=LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter 98CFLAGS+= -DLLVM_NATIVE_DISASSEMBLER=LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler 99CFLAGS+= -DLLVM_NATIVE_TARGET=LLVMInitialize${LLVM_NATIVE_ARCH}Target 100CFLAGS+= -DLLVM_NATIVE_TARGETINFO=LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo 101CFLAGS+= -DLLVM_NATIVE_TARGETMC=LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC 102.endif 103 104CFLAGS+= -ffunction-sections 105CFLAGS+= -fdata-sections 106.include "bsd.linker.mk" 107.if ${LINKER_TYPE} == "mac" 108LDFLAGS+= -Wl,-dead_strip 109.else 110LDFLAGS+= -Wl,--gc-sections 111.endif 112 113CXXSTD?= c++14 114CXXFLAGS+= -fno-exceptions 115CXXFLAGS+= -fno-rtti 116.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING) 117CXXFLAGS.clang+= -stdlib=libc++ 118.else 119# Building on macOS/Linux needs the real sysctl() not the bootstrap tools stub. 120CFLAGS+= -DBOOTSTRAPPING_WANT_NATIVE_SYSCTL 121.endif 122.if defined(BOOTSTRAPPING) && ${.MAKE.OS} == "Linux" 123LIBADD+= dl 124.endif 125 126.if ${MACHINE_ARCH:Mmips64} 127STATIC_CFLAGS+= -mxgot 128STATIC_CXXFLAGS+= -mxgot 129.endif 130