]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/clang-linux.jam
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / src / tools / clang-linux.jam
1 # Copyright (c) 2003 Michael Stevens
2 # Copyright (c) 2010-2011 Bryce Lelbach (blelbach@cct.lsu.edu, maintainer)
3 #
4 # Use, modification and distribution is subject to the Boost Software
5 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
6 # http://www.boost.org/LICENSE_1_0.txt)
7
8 import toolset ;
9 import feature ;
10 import toolset : flags ;
11
12 import clang ;
13 import gcc ;
14 import common ;
15 import errors ;
16 import generators ;
17 import type ;
18 import numbers ;
19
20 feature.extend-subfeature toolset clang : platform : linux ;
21
22 toolset.inherit-generators clang-linux
23 <toolset>clang <toolset-clang:platform>linux : gcc
24 : gcc.mingw.link gcc.mingw.link.dll gcc.cygwin.link gcc.cygwin.link.dll ;
25 generators.override clang-linux.prebuilt : builtin.lib-generator ;
26 generators.override clang-linux.prebuilt : builtin.prebuilt ;
27 generators.override clang-linux.searched-lib-generator : searched-lib-generator ;
28
29 # Override default do-nothing generators.
30 generators.override clang-linux.compile.c.pch : pch.default-c-pch-generator ;
31 generators.override clang-linux.compile.c++.pch : pch.default-cpp-pch-generator ;
32
33 type.set-generated-target-suffix PCH
34 : <toolset>clang <toolset-clang:platform>linux : pth ;
35
36 toolset.inherit-rules clang-linux : gcc ;
37 toolset.inherit-flags clang-linux : gcc
38 : <inlining>off <inlining>on <inlining>full
39 <optimization>space <optimization>speed
40 <warnings>off <warnings>all <warnings>on ;
41
42 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] {
43 .debug-configuration = true ;
44 }
45
46 rule init ( version ? : command * : options * ) {
47 command = [ common.get-invocation-command clang-linux : clang++
48 : $(command) ] ;
49
50 # Determine the version
51 local command-string = $(command:J=" ") ;
52
53 if $(command) {
54 version ?= [ MATCH "version ([0-9.]+)"
55 : [ SHELL "$(command-string) --version" ] ] ;
56 }
57
58 local condition = [ common.check-init-parameters clang-linux
59 : version $(version) ] ;
60
61 common.handle-options clang-linux : $(condition) : $(command) : $(options) ;
62
63 gcc.init-link-flags clang-linux gnu $(condition) ;
64 }
65
66 ###############################################################################
67 # Flags
68
69 toolset.flags clang-linux.compile OPTIONS <cflags> ;
70 toolset.flags clang-linux.compile.c++ OPTIONS <cxxflags> ;
71
72 toolset.flags clang-linux.compile OPTIONS <optimization>off : ;
73 toolset.flags clang-linux.compile OPTIONS <optimization>speed : -O3 ;
74 toolset.flags clang-linux.compile OPTIONS <optimization>space : -Os ;
75
76 # note: clang silently ignores some of these inlining options
77 toolset.flags clang-linux.compile OPTIONS <inlining>off : -fno-inline ;
78 # For clang, 'on' and 'full' are identical.
79 toolset.flags clang-linux.compile OPTIONS <inlining>on : -Wno-inline ;
80 toolset.flags clang-linux.compile OPTIONS <inlining>full : -Wno-inline ;
81
82 toolset.flags clang-linux.compile OPTIONS <warnings>off : -w ;
83 toolset.flags clang-linux.compile OPTIONS <warnings>on : -Wall ;
84 toolset.flags clang-linux.compile OPTIONS <warnings>all : -Wall -pedantic ;
85 toolset.flags clang-linux.compile OPTIONS <warnings-as-errors>on : -Werror ;
86
87 toolset.flags clang-linux.compile OPTIONS <debug-symbols>on : -g ;
88 toolset.flags clang-linux.compile OPTIONS <profiling>on : -pg ;
89 toolset.flags clang-linux.compile OPTIONS <rtti>off : -fno-rtti ;
90
91 ###############################################################################
92 # C and C++ compilation
93
94 rule compile.c++ ( targets * : sources * : properties * ) {
95 setup-threading $(targets) : $(sources) : $(properties) ;
96 gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
97 gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
98
99 local pth-file = [ on $(<) return $(PCH_FILE) ] ;
100
101 if $(pth-file) {
102 DEPENDS $(<) : $(pth-file) ;
103 clang-linux.compile.c++.with-pch $(targets) : $(sources) ;
104 }
105 else {
106 clang-linux.compile.c++.without-pth $(targets) : $(sources) ;
107 }
108 }
109
110 actions compile.c++.without-pth {
111 "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
112 }
113
114 actions compile.c++.with-pch bind PCH_FILE
115 {
116 "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pth -Xclang "$(PCH_FILE)" -o "$(<)" "$(>)"
117 }
118
119 rule compile.c ( targets * : sources * : properties * )
120 {
121 setup-threading $(targets) : $(sources) : $(properties) ;
122 gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
123 gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
124
125 local pth-file = [ on $(<) return $(PCH_FILE) ] ;
126
127 if $(pth-file) {
128 DEPENDS $(<) : $(pth-file) ;
129 clang-linux.compile.c.with-pch $(targets) : $(sources) ;
130 }
131 else {
132 clang-linux.compile.c.without-pth $(targets) : $(sources) ;
133 }
134 }
135
136 actions compile.c.without-pth
137 {
138 "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
139 }
140
141 actions compile.c.with-pch bind PCH_FILE
142 {
143 "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pth -Xclang "$(PCH_FILE)" -c -o "$(<)" "$(>)"
144 }
145
146 ###############################################################################
147 # PCH emission
148
149 rule compile.c++.pch ( targets * : sources * : properties * ) {
150 setup-threading $(targets) : $(sources) : $(properties) ;
151 gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
152 gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
153 }
154
155 actions compile.c++.pch {
156 rm -f "$(<)" && "$(CONFIG_COMMAND)" -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pth -o "$(<)" "$(>)"
157 }
158
159 rule compile.c.pch ( targets * : sources * : properties * ) {
160 setup-threading $(targets) : $(sources) : $(properties) ;
161 gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
162 gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
163 }
164
165 actions compile.c.pch
166 {
167 rm -f "$(<)" && "$(CONFIG_COMMAND)" -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pth -o "$(<)" "$(>)"
168 }
169
170 ###############################################################################
171 # Linking
172
173 SPACE = " " ;
174
175 rule link ( targets * : sources * : properties * ) {
176 setup-threading $(targets) : $(sources) : $(properties) ;
177 gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
178 SPACE on $(targets) = " " ;
179 JAM_SEMAPHORE on $(targets) = <s>clang-linux-link-semaphore ;
180 }
181
182 actions link bind LIBRARIES {
183 "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
184 }
185
186 rule link.dll ( targets * : sources * : properties * ) {
187 setup-threading $(targets) : $(sources) : $(properties) ;
188 gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
189 SPACE on $(targets) = " " ;
190 JAM_SEMAPHORE on $(targets) = <s>clang-linux-link-semaphore ;
191 }
192
193 rule setup-threading ( targets * : sources * : properties * )
194 {
195
196 local target = [ feature.get-values target-os : $(properties) ] ;
197
198 switch $(target)
199 {
200 case windows :
201 local threading = [ feature.get-values threading : $(properties) ] ;
202 if $(threading) = multi
203 {
204 OPTIONS on $(targets) += -pthread ;
205 }
206 case * : gcc.setup-threading $(targets) : $(sources) : $(properties) ;
207 }
208 }
209
210 # Differ from 'link' above only by -shared.
211 actions link.dll bind LIBRARIES {
212 "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o "$(<)" -Wl,-soname$(SPACE)-Wl,$(<[1]:D=) -shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
213 }
214