]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/clang/llvm.build.mk
cpuset: Adapt sched_affinity compat shims to the stable/13
[FreeBSD/FreeBSD.git] / lib / clang / llvm.build.mk
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 .PATH:          ${LLVM_BASE}/${SRCDIR}
18
19 CFLAGS+=        -I${SRCTOP}/lib/clang/include
20 CFLAGS+=        -I${LLVM_SRCS}/include
21 CFLAGS+=        -D__STDC_CONSTANT_MACROS
22 CFLAGS+=        -D__STDC_FORMAT_MACROS
23 CFLAGS+=        -D__STDC_LIMIT_MACROS
24 CFLAGS+=        -DHAVE_VCS_VERSION_INC
25 .if ${MK_LLVM_ASSERTIONS} == "no"
26 CFLAGS+=        -DNDEBUG
27 .endif
28
29 # Note that using TARGET_ARCH here is essential for a functional native-xtools
30 # build!  For native-xtools, we're building binaries that will work on the
31 # *host* machine (MACHINE_ARCH), but they should default to producing binaries
32 # for the *target* machine (TARGET_ARCH).
33 TARGET_ARCH?=   ${MACHINE_ARCH}
34 BUILD_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*} == "")
40 TARGET_ABI=     -gnueabihf
41 .elif ${TARGET_ARCH:Marm*}
42 TARGET_ABI=     -gnueabi
43 .else
44 TARGET_ABI=
45 .endif
46 VENDOR=         unknown
47 OS_VERSION=     freebsd13.2
48
49 LLVM_TARGET_TRIPLE?=    ${TARGET_ARCH:C/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${VENDOR}-${OS_VERSION}${TARGET_ABI}
50 LLVM_BUILD_TRIPLE?=     ${BUILD_ARCH:C/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${VENDOR}-${OS_VERSION}
51
52 CFLAGS+=        -DLLVM_DEFAULT_TARGET_TRIPLE=\"${LLVM_TARGET_TRIPLE}\"
53 CFLAGS+=        -DLLVM_HOST_TRIPLE=\"${LLVM_BUILD_TRIPLE}\"
54 CFLAGS+=        -DDEFAULT_SYSROOT=\"${TOOLS_PREFIX}\"
55
56 .if ${MK_LLVM_TARGET_AARCH64} != "no"
57 CFLAGS+=        -DLLVM_TARGET_ENABLE_AARCH64
58 . if ${MACHINE_CPUARCH} == "aarch64"
59 LLVM_NATIVE_ARCH=       AArch64
60 . endif
61 .endif
62 .if ${MK_LLVM_TARGET_ARM} != "no"
63 CFLAGS+=        -DLLVM_TARGET_ENABLE_ARM
64 . if ${MACHINE_CPUARCH} == "arm"
65 LLVM_NATIVE_ARCH=       ARM
66 . endif
67 .endif
68 .if ${MK_LLVM_TARGET_BPF} != "no"
69 CFLAGS+=        -DLLVM_TARGET_ENABLE_BPF
70 .endif
71 .if ${MK_LLVM_TARGET_MIPS} != "no"
72 CFLAGS+=        -DLLVM_TARGET_ENABLE_MIPS
73 . if ${MACHINE_CPUARCH} == "mips"
74 LLVM_NATIVE_ARCH=       Mips
75 . endif
76 .endif
77 .if ${MK_LLVM_TARGET_POWERPC} != "no"
78 CFLAGS+=        -DLLVM_TARGET_ENABLE_POWERPC
79 . if ${MACHINE_CPUARCH} == "powerpc"
80 LLVM_NATIVE_ARCH=       PowerPC
81 . endif
82 .endif
83 .if ${MK_LLVM_TARGET_RISCV} != "no"
84 CFLAGS+=        -DLLVM_TARGET_ENABLE_RISCV
85 . if ${MACHINE_CPUARCH} == "riscv"
86 LLVM_NATIVE_ARCH=       RISCV
87 . endif
88 .endif
89 .if ${MK_LLVM_TARGET_X86} != "no"
90 CFLAGS+=        -DLLVM_TARGET_ENABLE_X86
91 . if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
92 LLVM_NATIVE_ARCH=       X86
93 . endif
94 .endif
95
96 .ifdef LLVM_NATIVE_ARCH
97 CFLAGS+=        -DLLVM_NATIVE_ASMPARSER=LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser
98 CFLAGS+=        -DLLVM_NATIVE_ASMPRINTER=LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter
99 CFLAGS+=        -DLLVM_NATIVE_DISASSEMBLER=LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler
100 CFLAGS+=        -DLLVM_NATIVE_TARGET=LLVMInitialize${LLVM_NATIVE_ARCH}Target
101 CFLAGS+=        -DLLVM_NATIVE_TARGETINFO=LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo
102 CFLAGS+=        -DLLVM_NATIVE_TARGETMC=LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC
103 .endif
104
105 CFLAGS+=        -ffunction-sections
106 CFLAGS+=        -fdata-sections
107 .include "bsd.linker.mk"
108 .if ${LINKER_TYPE} == "mac"
109 LDFLAGS+=       -Wl,-dead_strip
110 .else
111 LDFLAGS+=       -Wl,--gc-sections
112 .endif
113
114 CXXSTD?=        c++14
115 CXXFLAGS+=      -fno-exceptions
116 CXXFLAGS+=      -fno-rtti
117 .if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
118 CXXFLAGS.clang+= -stdlib=libc++
119 .else
120 # Building on macOS/Linux needs the real sysctl() not the bootstrap tools stub.
121 CFLAGS+=        -DBOOTSTRAPPING_WANT_NATIVE_SYSCTL
122 .endif
123 .if defined(BOOTSTRAPPING) && ${.MAKE.OS} == "Linux"
124 LIBADD+=        dl
125 .endif
126
127 .if ${MACHINE_ARCH:Mmips64}
128 STATIC_CFLAGS+= -mxgot
129 STATIC_CXXFLAGS+= -mxgot
130 .endif