]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/intel-win.jam
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / src / tools / intel-win.jam
1 # Copyright Vladimir Prus 2004.
2 # Distributed under the Boost Software License, Version 1.0.
3 # (See accompanying file LICENSE_1_0.txt
4 # or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 # Importing common is needed because the rules we inherit here depend on it.
7 # That is nasty.
8 import common ;
9 import errors ;
10 import feature ;
11 import intel ;
12 import msvc ;
13 import os ;
14 import set ;
15 import toolset ;
16 import generators ;
17 import type ;
18 import path ;
19
20 feature.extend-subfeature toolset intel : platform : win ;
21
22 toolset.inherit-generators intel-win <toolset>intel <toolset-intel:platform>win : msvc ;
23 toolset.inherit-flags intel-win : msvc : : YLOPTION ;
24 toolset.inherit-rules intel-win : msvc ;
25
26 # Override default do-nothing generators.
27 generators.override intel-win.compile.c.pch : pch.default-c-pch-generator ;
28 generators.override intel-win.compile.c++.pch : pch.default-cpp-pch-generator ;
29 generators.override intel-win.compile.rc : rc.compile.resource ;
30 generators.override intel-win.compile.mc : mc.compile ;
31
32 toolset.flags intel-win.compile PCH_SOURCE <pch>on : <pch-source> ;
33
34 toolset.add-requirements <toolset>intel-win,<runtime-link>shared:<threading>multi ;
35
36 # Initializes the intel toolset for windows
37 rule init ( version ? : # the compiler version
38 command * : # the command to invoke the compiler itself
39 options * # Additional option: <compatibility>
40 # either 'vc6', 'vc7', 'vc7.1'
41 # or 'native'(default).
42 )
43 {
44 if $(version)
45 {
46 configure $(version) : $(command) : $(options) ;
47 }
48 else
49 {
50 if $(command)
51 {
52 errors.error "Autodetect of version from command not implemented!" ;
53 }
54 local intel_versions = [ get-autodetect-versions () ] ;
55 if ! $(intel_versions)
56 {
57 errors.error "No intel compiler version found!" ;
58 }
59 else
60 {
61 local msvc-version = [ feature.get-values <compatibility> : $(options) ] ; # On auto config mode the user can still request a msvc backend. If some intel compiler doesn't support it, don't try to configure it!
62 msvc-version = [ get-msvc-version-from-vc-string $(msvc-version) ] ;
63 for local v in $(intel_versions)
64 {
65 if [ is-msvc-supported $(v) : $(msvc-version) ]
66 {
67 configure $(v) : : $(options) ;
68 }
69 }
70 }
71 }
72 }
73
74 local rule configure ( version ? : command * : options * )
75 {
76 local compatibility =
77 [ feature.get-values <compatibility> : $(options) ] ;
78 # Allow to specify toolset and visual studio backend from commandline .e.g --toolset=intel-14.0-vc10
79 local vc_in_version = [ MATCH (vc[0-9]+(\\.[0-9]+)?)$ : $(version) ] ;
80 vc_in_version = $(vc_in_version[1]) ;
81 if $(compatibility) && $(vc_in_version)
82 {
83 if $(compatibility) != $(vc_in_version)
84 {
85 errors.error "feature compatibility and vc version in toolset present!" ;
86 }
87 }
88
89 if $(vc_in_version) && ! $(compatibility)
90 {
91 # vc Version must be stripped before check-init-parameters is called!
92 version = [ MATCH (.+)-vc.+$ : $(version) ] ;
93
94 compatibility = $(vc_in_version) ;
95 options += <compatibility>$(vc_in_version) ;
96 }
97 if $(compatibility)
98 {
99 configure-really $(version) : $(command) : $(options) : $(compatibility) ;
100 }
101 else
102 {
103 local msvc_versions = [ feature.values <toolset-msvc:version> ] ;
104 if ! $(msvc_versions)
105 {
106 ECHO notice: no msvc versions detected. trying auto detect ;
107 toolset.using msvc : all ;
108 msvc_versions = [ feature.values <toolset-msvc:version> ] ;
109 }
110 if ! $(.iclvars-$(version)-supported-vcs)
111 {
112 errors.error "Supported msvc versions not known for intel $(version)" ;
113 }
114
115 for local v in $(msvc_versions)
116 {
117 if [ MATCH "($(v))" : $(.iclvars-$(version)-supported-vcs) ]
118 {
119 # Strip trailing .0 from msvc version as intel compiler uses atm only major version for Qvc
120 local m = [ MATCH ([0-9]+).0$ : $(v) ] ;
121 if $(m)
122 {
123 v = $(m) ;
124 }
125 v = "vc$(v)" ;
126 local options_really = $(options) ;
127 options_really += <compatibility>$(v) ;
128 if $(.debug-configuration)
129 {
130 ECHO "configure: intel version: $(version) msvc version: $(v)" ;
131 }
132 configure-really $(version) : $(command) : $(options) : $(v) ;
133 }
134 }
135 if ! [ feature.values <toolset-intel:version> ]
136 {
137 errors.error "Failed to register an intel toolset!" ;
138 }
139 }
140 }
141
142 local rule configure-really ( version ? : command * : options * : compatibility )
143 {
144 local rewrite-setupscript = [ feature.get-values <rewrite-setup-scripts> : $(options) ] ;
145 local condition = [ common.check-init-parameters intel-win
146 : version $(version) : compatibility $(compatibility) ] ;
147
148 local m = [ MATCH ([0-9]+).* : $(version) ] ;
149 local major = $(m[1]) ;
150 if ! $(major)
151 {
152 errors.error "Major version not found: $(version)" ;
153 }
154
155 local msvc-version = [ get-msvc-version-from-vc-string $(compatibility) ] ;
156 if ! $(msvc-version)
157 {
158 errors.user-error "Invalid value for compatibility option:"
159 $(compatibility) ;
160 }
161
162 command = [ get-compiler-invocation-cmd $(major) : $(command) ] ;
163
164 common.handle-options intel-win : $(condition) : $(command) : $(options) ;
165
166 local root ;
167 if $(command)
168 {
169 root = [ common.get-absolute-tool-path $(command[-1]) ] ;
170 if $(major) >= 12
171 {
172 root = [ path.make $(root) ] ;
173 root = [ path.parent $(root) ] ;
174 }
175 root = $(root)/ ;
176 }
177
178 local setup ;
179 setup = [ path.glob $(root) : iclvars_*.bat ] ;
180 if ! $(setup)
181 {
182 setup = [ path.join $(root) "iclvars.bat" ] ;
183 setup = [ path.native $(setup) ] ;
184 }
185
186 local target_types ;
187 local iclvars_vs_arg ;
188 if $(major) >= 12
189 {
190 # if we have a known intel toolset check for visual studio compatibility
191 # if not trust parameters
192 if ! [ is-msvc-supported $(version) : $(msvc-version) ]
193 {
194 errors.error "msvc $(msvc-version) not supported for intel toolset version $(version)" ;
195 }
196 if $(.iclvars-version-alias-$(compatibility))
197 {
198 iclvars_vs_arg = $(.iclvars-version-alias-$(compatibility)) ;
199 }
200 else
201 {
202 errors.error "Don't know what parameter to pass for vc version ( $(compatibility) )" ;
203 }
204 # There are two possible paths for the 64-bit intel compiler,
205 # one for the IA32-Intel64 cross compiler, and one for the native
206 # 64 bit compiler. We prefer the latter one if it's installed,
207 # and don't rely on whether the OS reports whether we're 64 or 32 bit
208 # as that really only tells us which subsystem bjam is running in:
209 #
210 local intel64_path = [ path.join $(root) intel64 ] ;
211 if [ path.glob $(intel64_path) : icl.exe ]
212 {
213 target_types = ia32 intel64 ;
214 }
215 else
216 {
217 target_types = ia32 ia32_intel64 ;
218 }
219 }
220 else
221 {
222 target_types = default ;
223 iclvars_vs_arg = $(compatibility) ;
224 }
225
226 local default-assembler-intel64 = ml64 ;
227 local default-assembler-ia32_intel64 = ml64 ;
228 local default-assembler-ia32 = "ml -coff" ;
229 assembler = [ feature.get-values <assembler> : $(options) ] ;
230
231 for local c in $(target_types)
232 {
233 local cpu-conditions ;
234 local setup-call ;
235 if $(major) >= 12
236 {
237 local t = [ msvc.maybe-rewrite-setup intel-win : "\"$(setup)\"" : "$(c) $(iclvars_vs_arg)" : $(version) : $(rewrite-setupscript) ] ;
238 setup-call = "call $(t) > nul " ;
239 cpu-conditions = $(condition)/$(.cpu-arch-$(c)) ;
240 }
241 else
242 {
243 setup-call = "call \""$(setup)"\" $(compatibility) > nul " ;
244 cpu-conditions = $(condition) ;
245 }
246
247
248 if [ os.name ] = NT
249 {
250 setup-call = $(setup-call)"
251 " ;
252 }
253 else
254 {
255 setup-call = "cmd /S /C "$(setup-call)" \"&&\" " ;
256 }
257
258 if $(.debug-configuration)
259 {
260 for local cond in $(cpu-conditions)
261 {
262 ECHO "notice: [intel-cfg] condition: '$(cond)', setup: '$(setup-call)'" ;
263 }
264 }
265
266 local cpu-assembler = $(assembler) ;
267 cpu-assembler ?= $(default-assembler-$(c)) ;
268
269 toolset.flags intel-win.compile .CC $(cpu-conditions) : $(setup-call)icl ;
270 toolset.flags intel-win.link .LD $(cpu-conditions) : $(setup-call)xilink /nologo ;
271 toolset.flags intel-win.archive .LD $(cpu-conditions) : $(setup-call)xilink /lib /nologo ;
272 toolset.flags intel-win.link .MT $(cpu-conditions) : $(setup-call)mt -nologo ;
273 toolset.flags intel-win.compile .ASM $(cpu-conditions) : $(setup-call)$(cpu-assembler) -nologo ;
274 toolset.flags intel-win.compile .MC $(cpu-conditions) : $(setup-call)mc ;
275 toolset.flags intel-win.compile .RC $(cpu-conditions) : $(setup-call)rc ;
276 }
277
278 # Depending on the settings, running of tests require some runtime DLLs.
279 toolset.flags intel-win RUN_PATH $(condition) : $(root) ;
280
281
282 local C++FLAGS ;
283
284 C++FLAGS += /nologo ;
285
286 # Reduce the number of spurious error messages
287 C++FLAGS += /Qwn5 /Qwd985 ;
288
289 # Enable ADL
290 C++FLAGS += -Qoption,c,--arg_dep_lookup ; #"c" works for C++, too
291
292 # Disable Microsoft "secure" overloads in Dinkumware libraries since they
293 # cause compile errors with Intel versions 9 and 10.
294 if $(major) < 12
295 {
296 C++FLAGS += -D_SECURE_SCL=0 ;
297 }
298
299 if $(major) > 5
300 {
301 C++FLAGS += /Zc:forScope ; # Add support for correct for loop scoping.
302 }
303
304 # Add options recognized only by intel7 and above.
305 if $(major) >= 7
306 {
307 C++FLAGS += /Qansi_alias ;
308 }
309
310 if $(compatibility) = vc6
311 {
312 C++FLAGS +=
313 # Emulate VC6
314 /Qvc6
315
316 # No wchar_t support in vc6 dinkum library. Furthermore, in vc6
317 # compatibility-mode, wchar_t is not a distinct type from unsigned
318 # short.
319 -DBOOST_NO_INTRINSIC_WCHAR_T
320 ;
321 }
322 else
323 {
324 if $(major) > 5
325 {
326 # Add support for wchar_t
327 C++FLAGS += /Zc:wchar_t
328 # Tell the dinkumware library about it.
329 -D_NATIVE_WCHAR_T_DEFINED
330 ;
331 }
332 }
333
334 if $(compatibility) && $(compatibility) != native
335 {
336 C++FLAGS += /Q$(compatibility) ;
337 }
338 else
339 {
340 C++FLAGS +=
341 -Qoption,cpp,--arg_dep_lookup
342 # The following options were intended to disable the Intel compiler's
343 # 'bug-emulation' mode, but were later reported to be causing ICE with
344 # Intel-Win 9.0. It is not yet clear which options can be safely used.
345 # -Qoption,cpp,--const_string_literals
346 # -Qoption,cpp,--new_for_init
347 # -Qoption,cpp,--no_implicit_typename
348 # -Qoption,cpp,--no_friend_injection
349 # -Qoption,cpp,--no_microsoft_bugs
350 ;
351 }
352
353 toolset.flags intel-win CFLAGS $(condition) : $(C++FLAGS) ;
354 # By default, when creating PCH, intel adds 'i' to the explicitly
355 # specified name of the PCH file. Of course, Boost.Build is not
356 # happy when compiler produces not the file it was asked for.
357 # The option below stops this behaviour.
358 toolset.flags intel-win CFLAGS : -Qpchi- ;
359
360 if ! $(compatibility)
361 {
362 # If there's no backend version, assume 7.1.
363 compatibility = vc7.1 ;
364 }
365
366 msvc-version = [ msvc.resolve-possible-msvc-version-alias $(msvc-version) ] ;
367 msvc.configure-version-specific intel-win : $(msvc-version) : $(condition) ;
368 }
369
370 local rule get-autodetect-versions
371 {
372 local result ;
373 for local v in $(.intel-autodetect-versions)
374 {
375 local major = [ MATCH ([0-9]+).* : $(v) ] ; # Use only major version
376 if [ get-icl-path-from-environment $(major) ]
377 {
378 result += $(v) ;
379 }
380 }
381 return $(result) ;
382 }
383
384 local rule get-icl-path-from-environment ( major_version )
385 {
386 local path = [ os.environ ICPP_COMPILER$(major_version) ] ;
387 if $(path)
388 {
389 path = [ path.make $(path) ] ;
390 local cmdpath ;
391 local subdirs = $(.icl-target-subdirectories) ;
392 while $(subdirs)
393 {
394 cmdpath = [ path.join $(path) "bin/$(subdirs[0])/icl.exe" ] ;
395 cmdpath = [ path.native $(cmdpath) ] ;
396 if [ path.exists $(cmdpath) ]
397 {
398 subdirs = ;
399 } else {
400 cmdpath = ;
401 subdirs = $(subdirs[2-]) ;
402 }
403 }
404 path = $(cmdpath) ;
405 }
406 return $(path) ;
407 }
408
409 local rule get-compiler-invocation-cmd ( major_version : command * )
410 {
411 if $(command)
412 {
413 return [ common.get-invocation-command intel-win : icl.exe : $(command) ] ;
414 }
415 else
416 {
417 local path = [ get-icl-path-from-environment $(major_version) ] ;
418 return [ common.get-invocation-command intel-win : icl.exe : $(path) ] ;
419 }
420 }
421
422 local rule is-msvc-supported ( intel-version : msvc-version )
423 {
424 if ! $(msvc-version)
425 {
426 return true ;
427 }
428 else
429 {
430 if $(.iclvars-$(intel-version)-supported-vcs)
431 {
432 if [ MATCH "($(msvc-version))" : $(.iclvars-$(intel-version)-supported-vcs) ]
433 {
434 return true ;
435 }
436 }
437 else
438 {
439 return true ;
440 }
441 }
442 }
443
444 local rule get-msvc-version-from-vc-string ( vc-string )
445 {
446 local r = [ MATCH "^vc([0-9]+(\\.[0-9]+)?)$" : $(vc-string) ] ;
447 return $(r[1]) ;
448 }
449
450 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
451 {
452 .debug-configuration = true ;
453 }
454
455 # Copied from msvc.jam
456 # Supported CPU architectures.
457 .cpu-arch-ia32 =
458 <architecture>/<address-model>
459 <architecture>/<address-model>32
460 <architecture>x86/<address-model>
461 <architecture>x86/<address-model>32 ;
462
463 .cpu-arch-intel64 =
464 <architecture>/<address-model>64
465 <architecture>x86/<address-model>64 ;
466
467 .cpu-arch-ia32_intel64 =
468 <architecture>/<address-model>64
469 <architecture>x86/<address-model>64 ;
470
471 .intel-autodetect-versions = 14.0 13.0 12.0 ;
472 .iclvars-12.0-supported-vcs = "10.0 9.0 8.0" ;
473 .iclvars-12.1-supported-vcs = "10.0 9.0 8.0" ;
474 .iclvars-13.0-supported-vcs = "11.0 10.0 9.0" ;
475 .iclvars-14.0-supported-vcs = "12.0 11.0 10.0 9.0" ;
476 .iclvars-15.0-supported-vcs = "12.0 11.0 10.0 9.0" ;
477 .iclvars-16.0-supported-vcs = "14.0 12.0 11.0 10.0 9.0" ;
478 .iclvars-17.0-supported-vcs = "14.0 12.0 11.0 10.0" ;
479 .iclvars-version-alias-vc14 = vs2015 ;
480 .iclvars-version-alias-vc12 = vs2013 ;
481 .iclvars-version-alias-vc11 = vs2012 ;
482 .iclvars-version-alias-vc10 = vs2010 ;
483 .iclvars-version-alias-vc9 = vs2008 ;
484 .iclvars-version-alias-vc8 = vs2005 ;
485 .icl-target-subdirectories = ia32 ia32_intel64 intel64 ;
486
487 toolset.flags intel-win.link LIBRARY_OPTION <toolset>intel : "" ;
488
489 toolset.flags intel-win YLOPTION ;
490