]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | |
11fdf7f2 | 79 | local vc_in_version = [ MATCH "(vc[0-9]+(\\.[0-9]+)?)$" : $(version) ] ; |
7c673cae FG |
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 | { | |
11fdf7f2 | 106 | ECHO notice\: no msvc versions detected. trying auto detect ; |
7c673cae FG |
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 | |
11fdf7f2 | 120 | local m = [ MATCH "([0-9]+).0$" : $(v) ] ; |
7c673cae FG |
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 | ||
11fdf7f2 | 148 | local m = [ MATCH "([0-9]+).*" : $(version) ] ; |
7c673cae FG |
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 | { | |
7c673cae | 237 | cpu-conditions = $(condition)/$(.cpu-arch-$(c)) ; |
11fdf7f2 TL |
238 | |
239 | if ! $(setup) | |
240 | { | |
241 | # No setup script | |
242 | } | |
243 | else if $(rewrite-setupscript) = off || [ os.name ] != NT | |
244 | { | |
245 | setup-call = "call \"$(setup)\" $(c) $(iclvars_vs_arg)" ; | |
246 | } | |
247 | else | |
248 | { | |
249 | toolset.flags intel-win .SETUP-SCRIPT $(cpu-conditions) : $(setup) ; | |
250 | toolset.flags intel-win .SETUP-OPTIONS $(cpu-conditions) : "$(c) $(iclvars_vs_arg)" ; | |
251 | } | |
7c673cae FG |
252 | } |
253 | else | |
254 | { | |
255 | setup-call = "call \""$(setup)"\" $(compatibility) > nul " ; | |
256 | cpu-conditions = $(condition) ; | |
257 | } | |
258 | ||
11fdf7f2 | 259 | if $(setup-call) |
7c673cae | 260 | { |
11fdf7f2 TL |
261 | if [ os.name ] = NT |
262 | { | |
263 | setup-call = $(setup-call)"\n " ; | |
264 | } | |
265 | else | |
266 | { | |
267 | setup-call = "cmd /S /C "$(setup-call)" \"&&\" " ; | |
268 | } | |
269 | toolset.flags intel-win .SETUP $(cpu-conditions) : $(setup-call) ; | |
7c673cae FG |
270 | } |
271 | ||
272 | if $(.debug-configuration) | |
273 | { | |
274 | for local cond in $(cpu-conditions) | |
275 | { | |
276 | ECHO "notice: [intel-cfg] condition: '$(cond)', setup: '$(setup-call)'" ; | |
277 | } | |
278 | } | |
279 | ||
280 | local cpu-assembler = $(assembler) ; | |
281 | cpu-assembler ?= $(default-assembler-$(c)) ; | |
282 | ||
11fdf7f2 TL |
283 | toolset.flags intel-win.compile .CC $(cpu-conditions) : icl ; |
284 | toolset.flags intel-win.link .LD $(cpu-conditions) : xilink /nologo ; | |
285 | toolset.flags intel-win.archive .LD $(cpu-conditions) : xilink /lib /nologo ; | |
286 | toolset.flags intel-win.link .MT $(cpu-conditions) : mt -nologo ; | |
287 | toolset.flags intel-win.compile .ASM $(cpu-conditions) : $(cpu-assembler) -nologo ; | |
288 | toolset.flags intel-win.compile .MC $(cpu-conditions) : mc ; | |
289 | toolset.flags intel-win.compile .RC $(cpu-conditions) : rc ; | |
7c673cae FG |
290 | } |
291 | ||
292 | # Depending on the settings, running of tests require some runtime DLLs. | |
293 | toolset.flags intel-win RUN_PATH $(condition) : $(root) ; | |
294 | ||
295 | ||
296 | local C++FLAGS ; | |
297 | ||
298 | C++FLAGS += /nologo ; | |
299 | ||
300 | # Reduce the number of spurious error messages | |
301 | C++FLAGS += /Qwn5 /Qwd985 ; | |
302 | ||
303 | # Enable ADL | |
304 | C++FLAGS += -Qoption,c,--arg_dep_lookup ; #"c" works for C++, too | |
305 | ||
306 | # Disable Microsoft "secure" overloads in Dinkumware libraries since they | |
307 | # cause compile errors with Intel versions 9 and 10. | |
308 | if $(major) < 12 | |
309 | { | |
310 | C++FLAGS += -D_SECURE_SCL=0 ; | |
311 | } | |
312 | ||
313 | if $(major) > 5 | |
314 | { | |
11fdf7f2 | 315 | C++FLAGS += "/Zc:forScope" ; # Add support for correct for loop scoping. |
7c673cae FG |
316 | } |
317 | ||
318 | # Add options recognized only by intel7 and above. | |
319 | if $(major) >= 7 | |
320 | { | |
321 | C++FLAGS += /Qansi_alias ; | |
322 | } | |
323 | ||
324 | if $(compatibility) = vc6 | |
325 | { | |
326 | C++FLAGS += | |
327 | # Emulate VC6 | |
328 | /Qvc6 | |
329 | ||
330 | # No wchar_t support in vc6 dinkum library. Furthermore, in vc6 | |
331 | # compatibility-mode, wchar_t is not a distinct type from unsigned | |
332 | # short. | |
333 | -DBOOST_NO_INTRINSIC_WCHAR_T | |
334 | ; | |
335 | } | |
336 | else | |
337 | { | |
338 | if $(major) > 5 | |
339 | { | |
340 | # Add support for wchar_t | |
11fdf7f2 | 341 | C++FLAGS += "/Zc:wchar_t" |
7c673cae FG |
342 | # Tell the dinkumware library about it. |
343 | -D_NATIVE_WCHAR_T_DEFINED | |
344 | ; | |
345 | } | |
346 | } | |
347 | ||
348 | if $(compatibility) && $(compatibility) != native | |
349 | { | |
350 | C++FLAGS += /Q$(compatibility) ; | |
351 | } | |
352 | else | |
353 | { | |
354 | C++FLAGS += | |
355 | -Qoption,cpp,--arg_dep_lookup | |
356 | # The following options were intended to disable the Intel compiler's | |
357 | # 'bug-emulation' mode, but were later reported to be causing ICE with | |
358 | # Intel-Win 9.0. It is not yet clear which options can be safely used. | |
359 | # -Qoption,cpp,--const_string_literals | |
360 | # -Qoption,cpp,--new_for_init | |
361 | # -Qoption,cpp,--no_implicit_typename | |
362 | # -Qoption,cpp,--no_friend_injection | |
363 | # -Qoption,cpp,--no_microsoft_bugs | |
364 | ; | |
365 | } | |
366 | ||
367 | toolset.flags intel-win CFLAGS $(condition) : $(C++FLAGS) ; | |
368 | # By default, when creating PCH, intel adds 'i' to the explicitly | |
369 | # specified name of the PCH file. Of course, Boost.Build is not | |
370 | # happy when compiler produces not the file it was asked for. | |
371 | # The option below stops this behaviour. | |
372 | toolset.flags intel-win CFLAGS : -Qpchi- ; | |
373 | ||
374 | if ! $(compatibility) | |
375 | { | |
376 | # If there's no backend version, assume 7.1. | |
377 | compatibility = vc7.1 ; | |
378 | } | |
379 | ||
380 | msvc-version = [ msvc.resolve-possible-msvc-version-alias $(msvc-version) ] ; | |
381 | msvc.configure-version-specific intel-win : $(msvc-version) : $(condition) ; | |
382 | } | |
383 | ||
384 | local rule get-autodetect-versions | |
385 | { | |
386 | local result ; | |
387 | for local v in $(.intel-autodetect-versions) | |
388 | { | |
11fdf7f2 | 389 | local major = [ MATCH "([0-9]+).*" : $(v) ] ; # Use only major version |
7c673cae FG |
390 | if [ get-icl-path-from-environment $(major) ] |
391 | { | |
392 | result += $(v) ; | |
393 | } | |
394 | } | |
395 | return $(result) ; | |
396 | } | |
397 | ||
398 | local rule get-icl-path-from-environment ( major_version ) | |
399 | { | |
400 | local path = [ os.environ ICPP_COMPILER$(major_version) ] ; | |
401 | if $(path) | |
402 | { | |
403 | path = [ path.make $(path) ] ; | |
404 | local cmdpath ; | |
405 | local subdirs = $(.icl-target-subdirectories) ; | |
406 | while $(subdirs) | |
407 | { | |
408 | cmdpath = [ path.join $(path) "bin/$(subdirs[0])/icl.exe" ] ; | |
409 | cmdpath = [ path.native $(cmdpath) ] ; | |
410 | if [ path.exists $(cmdpath) ] | |
411 | { | |
412 | subdirs = ; | |
413 | } else { | |
414 | cmdpath = ; | |
415 | subdirs = $(subdirs[2-]) ; | |
416 | } | |
417 | } | |
418 | path = $(cmdpath) ; | |
419 | } | |
420 | return $(path) ; | |
421 | } | |
422 | ||
423 | local rule get-compiler-invocation-cmd ( major_version : command * ) | |
424 | { | |
425 | if $(command) | |
426 | { | |
427 | return [ common.get-invocation-command intel-win : icl.exe : $(command) ] ; | |
428 | } | |
429 | else | |
430 | { | |
431 | local path = [ get-icl-path-from-environment $(major_version) ] ; | |
432 | return [ common.get-invocation-command intel-win : icl.exe : $(path) ] ; | |
433 | } | |
434 | } | |
435 | ||
436 | local rule is-msvc-supported ( intel-version : msvc-version ) | |
437 | { | |
438 | if ! $(msvc-version) | |
439 | { | |
440 | return true ; | |
441 | } | |
442 | else | |
443 | { | |
444 | if $(.iclvars-$(intel-version)-supported-vcs) | |
445 | { | |
446 | if [ MATCH "($(msvc-version))" : $(.iclvars-$(intel-version)-supported-vcs) ] | |
447 | { | |
448 | return true ; | |
449 | } | |
450 | } | |
451 | else | |
452 | { | |
453 | return true ; | |
454 | } | |
455 | } | |
456 | } | |
457 | ||
458 | local rule get-msvc-version-from-vc-string ( vc-string ) | |
459 | { | |
460 | local r = [ MATCH "^vc([0-9]+(\\.[0-9]+)?)$" : $(vc-string) ] ; | |
461 | return $(r[1]) ; | |
462 | } | |
463 | ||
464 | if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] | |
465 | { | |
466 | .debug-configuration = true ; | |
467 | } | |
468 | ||
469 | # Copied from msvc.jam | |
470 | # Supported CPU architectures. | |
471 | .cpu-arch-ia32 = | |
472 | <architecture>/<address-model> | |
473 | <architecture>/<address-model>32 | |
474 | <architecture>x86/<address-model> | |
475 | <architecture>x86/<address-model>32 ; | |
476 | ||
477 | .cpu-arch-intel64 = | |
478 | <architecture>/<address-model>64 | |
479 | <architecture>x86/<address-model>64 ; | |
480 | ||
481 | .cpu-arch-ia32_intel64 = | |
482 | <architecture>/<address-model>64 | |
483 | <architecture>x86/<address-model>64 ; | |
484 | ||
485 | .intel-autodetect-versions = 14.0 13.0 12.0 ; | |
486 | .iclvars-12.0-supported-vcs = "10.0 9.0 8.0" ; | |
487 | .iclvars-12.1-supported-vcs = "10.0 9.0 8.0" ; | |
488 | .iclvars-13.0-supported-vcs = "11.0 10.0 9.0" ; | |
489 | .iclvars-14.0-supported-vcs = "12.0 11.0 10.0 9.0" ; | |
490 | .iclvars-15.0-supported-vcs = "12.0 11.0 10.0 9.0" ; | |
491 | .iclvars-16.0-supported-vcs = "14.0 12.0 11.0 10.0 9.0" ; | |
492 | .iclvars-17.0-supported-vcs = "14.0 12.0 11.0 10.0" ; | |
b32b8144 FG |
493 | .iclvars-18.0-supported-vcs = "14.1 14.0 12.0 11.0 10.0" ; |
494 | .iclvars-version-alias-vc14.1 = vs2017 ; | |
7c673cae FG |
495 | .iclvars-version-alias-vc14 = vs2015 ; |
496 | .iclvars-version-alias-vc12 = vs2013 ; | |
497 | .iclvars-version-alias-vc11 = vs2012 ; | |
498 | .iclvars-version-alias-vc10 = vs2010 ; | |
499 | .iclvars-version-alias-vc9 = vs2008 ; | |
500 | .iclvars-version-alias-vc8 = vs2005 ; | |
501 | .icl-target-subdirectories = ia32 ia32_intel64 intel64 ; | |
502 | ||
503 | toolset.flags intel-win.link LIBRARY_OPTION <toolset>intel : "" ; | |
504 | ||
505 | toolset.flags intel-win YLOPTION ; | |
506 |