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