]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/clang-linux.jam
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / tools / build / src / tools / clang-linux.jam
1 # Copyright 2020 Rene Rivera
2 # Copyright (c) 2003 Michael Stevens
3 # Copyright (c) 2010-2011 Bryce Lelbach (blelbach@cct.lsu.edu, maintainer)
4 #
5 # Use, modification and distribution is subject to the Boost Software
6 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
7 # http://www.boost.org/LICENSE_1_0.txt)
8
9 import common ;
10 import toolset ;
11 import feature ;
12 import toolset : flags ;
13
14 import clang ;
15 import gcc ;
16 import common ;
17 import errors ;
18 import generators ;
19 import type ;
20 import numbers ;
21 import os ;
22 import property ;
23
24 feature.extend-subfeature toolset clang : platform : linux ;
25
26 toolset.inherit-generators clang-linux
27 <toolset>clang <toolset-clang:platform>linux : gcc
28 : gcc.mingw.link gcc.mingw.link.dll gcc.cygwin.link gcc.cygwin.link.dll ;
29 generators.override clang-linux.prebuilt : builtin.lib-generator ;
30 generators.override clang-linux.prebuilt : builtin.prebuilt ;
31 generators.override clang-linux.searched-lib-generator : searched-lib-generator ;
32
33 # Override default do-nothing generators.
34 generators.override clang-linux.compile.c.pch : pch.default-c-pch-generator ;
35 generators.override clang-linux.compile.c++.pch : pch.default-cpp-pch-generator ;
36
37 type.set-generated-target-suffix PCH
38 : <toolset>clang <toolset-clang:platform>linux : pth ;
39
40 toolset.inherit-rules clang-linux : gcc ;
41 toolset.inherit-flags clang-linux : gcc
42 : <inlining>full
43 <threading>multi/<target-os>windows
44 <lto>on/<lto-mode>full
45 <lto>on/<lto-mode>fat
46 ;
47
48 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] {
49 .debug-configuration = true ;
50 }
51
52 rule init ( version ? : command * : options * ) {
53 command = [ common.get-invocation-command clang-linux : clang++
54 : $(command) ] ;
55
56 # Determine the version
57 if $(command) {
58 local command-string = \"$(command)\" ;
59 command-string = $(command-string:J=" ") ;
60 version ?= [ MATCH "version ([0-9.]+)"
61 : [ SHELL "$(command-string) --version" ] ] ;
62 }
63
64 local condition = [ common.check-init-parameters clang-linux
65 : version $(version) ] ;
66
67 common.handle-options clang-linux : $(condition) : $(command) : $(options) ;
68 clang.init-cxxstd-flags clang-linux : $(condition) : $(version) ;
69
70 # Support for gcc root as the backend, this is mainly useful for clang/gcc on Windows
71 # since on Linux gcc will be the default compiler already located on the PATH.
72 # On Windows it is possible to have multiple versions of mingw(-64)/gcc installed
73 # in different directories. The <root>option can be given so that the gcc backend
74 # can be found at runtime, while the $(command) can be a script that sets the
75 # PATH for both the clang directory and the backende gcc directory
76 # before calling clang++ when compiling/linking.
77
78 local root = [ feature.get-values <root> : $(options) ] ;
79
80 if $(root)
81 {
82 # On multilib 64-bit boxes, there are both 32-bit and 64-bit libraries
83 # and all must be added to LD_LIBRARY_PATH. The linker will pick the
84 # right onces. Note that we do not provide a clean way to build a 32-bit
85 # binary using a 64-bit compiler, but user can always pass -m32
86 # manually.
87 local lib_path = $(root)/bin $(root)/lib $(root)/lib32 $(root)/lib64 ;
88 if $(.debug-configuration)
89 {
90 ECHO "notice:" using gcc libraries with clang"::" $(condition) "::" $(lib_path) ;
91 }
92 toolset.flags clang-linux.link RUN_PATH $(condition) : $(lib_path) ;
93 }
94
95 # - Ranlib.
96 local ranlib = [ feature.get-values <ranlib> : $(options) ] ;
97 if ( ! $(ranlib) ) && $(root)
98 {
99 ranlib = $(root)/bin/ranlib ;
100 }
101 toolset.flags clang-linux.archive .RANLIB $(condition) : $(ranlib[1]) ;
102
103 # - Archive builder.
104 local archiver = [ feature.get-values <archiver> : $(options) ] ;
105 if ( ! $(archiver) ) && $(root)
106 {
107 archiver = $(root)/bin/ar ;
108 }
109 toolset.flags clang-linux.archive .AR $(condition) : $(archiver[1]) ;
110 }
111
112 ###############################################################################
113 # Flags
114
115 # note: clang silently ignores some of these inlining options
116 # For clang, 'on' and 'full' are identical.
117 toolset.flags clang-linux.compile OPTIONS <inlining>full : -Wno-inline ;
118
119 toolset.flags clang-linux.compile OPTIONS <threading>multi/<target-os>windows : -pthread ;
120 toolset.flags clang-linux.link OPTIONS <threading>multi/<target-os>windows : -pthread ;
121
122 # LTO
123 toolset.flags clang-linux.compile OPTIONS <lto>on/<lto-mode>thin : -flto=thin ;
124 toolset.flags clang-linux.link OPTIONS <lto>on/<lto-mode>thin : -flto=thin ;
125
126 toolset.flags clang-linux.compile OPTIONS <lto>on/<lto-mode>full : -flto=full ;
127 toolset.flags clang-linux.link OPTIONS <lto>on/<lto-mode>full : -flto=full ;
128
129 # stdlib selection
130 toolset.flags clang-linux.compile OPTIONS <stdlib>gnu <stdlib>gnu11 : -stdlib=libstdc++ ;
131 toolset.flags clang-linux.link OPTIONS <stdlib>gnu <stdlib>gnu11 : -stdlib=libstdc++ ;
132
133 toolset.flags clang-linux.compile OPTIONS <stdlib>libc++ : -stdlib=libc++ ;
134 toolset.flags clang-linux.link OPTIONS <stdlib>libc++ : -stdlib=libc++ ;
135
136 ###############################################################################
137 # C and C++ compilation
138
139 rule compile.c++ ( targets * : sources * : properties * ) {
140 local pch-file = [ on $(<) return $(PCH_FILE) ] ;
141
142 if $(pch-file) {
143 DEPENDS $(<) : $(pch-file) ;
144 clang-linux.compile.c++.with-pch $(targets) : $(sources) ;
145 }
146 else {
147 clang-linux.compile.c++.without-pch $(targets) : $(sources) ;
148 }
149 }
150
151 actions compile.c++.without-pch {
152 "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" -o "$(<)" "$(>)"
153 }
154
155 actions compile.c++.with-pch bind PCH_FILE
156 {
157 "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pch -Xclang "$(PCH_FILE)" -include"$(FORCE_INCLUDES)" -o "$(<)" "$(>)"
158 }
159
160 rule compile.c ( targets * : sources * : properties * )
161 {
162 local pch-file = [ on $(<) return $(PCH_FILE) ] ;
163
164 if $(pch-file) {
165 DEPENDS $(<) : $(pch-file) ;
166 clang-linux.compile.c.with-pch $(targets) : $(sources) ;
167 }
168 else {
169 clang-linux.compile.c.without-pch $(targets) : $(sources) ;
170 }
171 }
172
173 actions compile.c.without-pch
174 {
175 "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" -c -o "$(<)" "$(>)"
176 }
177
178 actions compile.c.with-pch bind PCH_FILE
179 {
180 "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pch -Xclang "$(PCH_FILE)" -include"$(FORCE_INCLUDES)" -c -o "$(<)" "$(>)"
181 }
182
183 ###############################################################################
184 # PCH emission
185
186 RM = [ common.rm-command ] ;
187
188 rule compile.c++.pch ( targets * : sources * : properties * ) {
189 }
190
191 actions compile.c++.pch {
192 $(RM) -f "$(<)" && "$(CONFIG_COMMAND)" -c -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" -Xclang -emit-pch -o "$(<)" "$(>)"
193 }
194
195 rule compile.c.pch ( targets * : sources * : properties * ) {
196 }
197
198 actions compile.c.pch
199 {
200 $(RM) -f "$(<)" && "$(CONFIG_COMMAND)" -c -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" -Xclang -emit-pch -o "$(<)" "$(>)"
201 }
202
203 ###############################################################################
204 # Linking
205
206 SPACE = " " ;
207
208 rule link ( targets * : sources * : properties * ) {
209 SPACE on $(targets) = " " ;
210 JAM_SEMAPHORE on $(targets) = <s>clang-linux-link-semaphore ;
211
212 local tosw ;
213 local pselect = [ property.select <target-os> : $(properties) ] ;
214
215 if $(pselect)
216 {
217
218 local tosv = [ feature.get-values <target-os> : $(pselect) ] ;
219
220 if $(tosv) = windows
221 {
222 tosw = 1 ;
223 }
224 }
225 else if [ os.name ] in NT
226 {
227 tosw = 1 ;
228 }
229 if $(tosw)
230 {
231 link-w $(targets) : $(sources) ;
232 }
233 else
234 {
235 link-o $(targets) : $(sources) ;
236 }
237 }
238
239 rule link.dll ( targets * : sources * : properties * ) {
240 SPACE on $(targets) = " " ;
241 JAM_SEMAPHORE on $(targets) = <s>clang-linux-link-semaphore ;
242
243 local tosw ;
244 local pselect = [ property.select <target-os> : $(properties) ] ;
245
246 if $(pselect)
247 {
248
249 local tosv = [ feature.get-values <target-os> : $(pselect) ] ;
250
251 if $(tosv) = windows
252 {
253 tosw = 1 ;
254 }
255 }
256 else if [ os.name ] in NT
257 {
258 tosw = 1 ;
259 }
260 if $(tosw)
261 {
262 link.dll-w $(targets) : $(sources) ;
263 }
264 else
265 {
266 link.dll-o $(targets) : $(sources) ;
267 }
268 }
269
270 # Target OS is not Windows, needs the RPATH stuff
271 actions link-o bind LIBRARIES {
272 "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -o "$(<)" @"@($(<[1]:T).rsp:E=-Wl,-R$(SPACE)-Wl,"$(RPATH)" -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" $(START-GROUP) "$(>:T)" "$(LIBRARIES:T)" $(FINDLIBS-ST-PFX:T) -l$(FINDLIBS-ST:T) $(FINDLIBS-SA-PFX:T) -l$(FINDLIBS-SA:T) $(END-GROUP))" $(OPTIONS) $(USER_OPTIONS)
273 }
274
275 # Target OS is not Windows, needs the RPATH and SONAME stuff
276 actions link.dll-o bind LIBRARIES {
277 "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -o "$(<)" @"@($(<[1]:T).rsp:E=-Wl,-R$(SPACE)-Wl,"$(RPATH)" -Wl,-soname$(SPACE)-Wl,$(<[1]:D=) -shared $(START-GROUP) "$(>:T)" "$(LIBRARIES:T)" $(FINDLIBS-ST-PFX:T) -l$(FINDLIBS-ST:T) $(FINDLIBS-SA-PFX:T) -l$(FINDLIBS-SA:T) $(END-GROUP))" $(OPTIONS) $(USER_OPTIONS)
278 }
279
280 # Target OS is Windows, does not need the RPATH stuff
281 actions link-w bind LIBRARIES {
282 "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -o "$(<)" @"@($(<[1]:T).rsp:E=$(START-GROUP) "$(>:T)" "$(LIBRARIES:T)" $(FINDLIBS-ST-PFX:T) -l$(FINDLIBS-ST:T) $(FINDLIBS-SA-PFX:T) -l$(FINDLIBS-SA:T) $(END-GROUP))" $(OPTIONS) $(USER_OPTIONS)
283 }
284
285 # Target OS is Windows, does not need the RPATH and SONAME stuff
286 actions link.dll-w bind LIBRARIES {
287 "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -o "$(<)" -shared @"@($(<[1]:T).rsp:E=$(START-GROUP) "$(>:T)" "$(LIBRARIES:T)" $(FINDLIBS-ST-PFX:T) -l$(FINDLIBS-ST:T) $(FINDLIBS-SA-PFX:T) -l$(FINDLIBS-SA:T) $(END-GROUP))" $(OPTIONS) $(USER_OPTIONS)
288
289 }