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)
6 # Importing common is needed because the rules we inherit here depend on it.
20 feature.extend-subfeature toolset intel : platform : win ;
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 ;
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 ;
32 toolset.flags intel-win.compile PCH_SOURCE <pch>on : <pch-source> ;
34 toolset.add-requirements <toolset>intel-win,<runtime-link>shared:<threading>multi ;
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).
46 configure $(version) : $(command) : $(options) ;
52 errors.error "Autodetect of version from command not implemented!" ;
54 local intel_versions = [ get-autodetect-versions () ] ;
55 if ! $(intel_versions)
57 errors.error "No intel compiler version found!" ;
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)
65 if [ is-msvc-supported $(v) : $(msvc-version) ]
67 configure $(v) : : $(options) ;
74 local rule configure ( version ? : command * : options * )
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)
83 if $(compatibility) != $(vc_in_version)
85 errors.error "feature compatibility and vc version in toolset present!" ;
89 if $(vc_in_version) && ! $(compatibility)
91 # vc Version must be stripped before check-init-parameters is called!
92 version = [ MATCH (.+)-vc.+$ : $(version) ] ;
94 compatibility = $(vc_in_version) ;
95 options += <compatibility>$(vc_in_version) ;
99 configure-really $(version) : $(command) : $(options) : $(compatibility) ;
103 local msvc_versions = [ feature.values <toolset-msvc:version> ] ;
104 if ! $(msvc_versions)
106 ECHO notice: no msvc versions detected. trying auto detect ;
107 toolset.using msvc : all ;
108 msvc_versions = [ feature.values <toolset-msvc:version> ] ;
110 if ! $(.iclvars-$(version)-supported-vcs)
112 errors.error "Supported msvc versions not known for intel $(version)" ;
115 for local v in $(msvc_versions)
117 if [ MATCH "($(v))" : $(.iclvars-$(version)-supported-vcs) ]
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) ] ;
126 local options_really = $(options) ;
127 options_really += <compatibility>$(v) ;
128 if $(.debug-configuration)
130 ECHO "configure: intel version: $(version) msvc version: $(v)" ;
132 configure-really $(version) : $(command) : $(options) : $(v) ;
135 if ! [ feature.values <toolset-intel:version> ]
137 errors.error "Failed to register an intel toolset!" ;
142 local rule configure-really ( version ? : command * : options * : compatibility )
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) ] ;
148 local m = [ MATCH ([0-9]+).* : $(version) ] ;
149 local major = $(m[1]) ;
152 errors.error "Major version not found: $(version)" ;
155 local msvc-version = [ get-msvc-version-from-vc-string $(compatibility) ] ;
158 errors.user-error "Invalid value for compatibility option:"
162 command = [ get-compiler-invocation-cmd $(major) : $(command) ] ;
164 common.handle-options intel-win : $(condition) : $(command) : $(options) ;
169 root = [ common.get-absolute-tool-path $(command[-1]) ] ;
172 root = [ path.make $(root) ] ;
173 root = [ path.parent $(root) ] ;
179 setup = [ path.glob $(root) : iclvars_*.bat ] ;
182 setup = [ path.join $(root) "iclvars.bat" ] ;
183 setup = [ path.native $(setup) ] ;
187 local iclvars_vs_arg ;
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) ]
194 errors.error "msvc $(msvc-version) not supported for intel toolset version $(version)" ;
196 if $(.iclvars-version-alias-$(compatibility))
198 iclvars_vs_arg = $(.iclvars-version-alias-$(compatibility)) ;
202 errors.error "Don't know what parameter to pass for vc version ( $(compatibility) )" ;
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:
210 local intel64_path = [ path.join $(root) intel64 ] ;
211 if [ path.glob $(intel64_path) : icl.exe ]
213 target_types = ia32 intel64 ;
217 target_types = ia32 ia32_intel64 ;
222 target_types = default ;
223 iclvars_vs_arg = $(compatibility) ;
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) ] ;
231 for local c in $(target_types)
233 local cpu-conditions ;
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)) ;
243 setup-call = "call \""$(setup)"\" $(compatibility) > nul " ;
244 cpu-conditions = $(condition) ;
250 setup-call = $(setup-call)"
255 setup-call = "cmd /S /C "$(setup-call)" \"&&\" " ;
258 if $(.debug-configuration)
260 for local cond in $(cpu-conditions)
262 ECHO "notice: [intel-cfg] condition: '$(cond)', setup: '$(setup-call)'" ;
266 local cpu-assembler = $(assembler) ;
267 cpu-assembler ?= $(default-assembler-$(c)) ;
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 ;
278 # Depending on the settings, running of tests require some runtime DLLs.
279 toolset.flags intel-win RUN_PATH $(condition) : $(root) ;
284 C++FLAGS += /nologo ;
286 # Reduce the number of spurious error messages
287 C++FLAGS += /Qwn5 /Qwd985 ;
290 C++FLAGS += -Qoption,c,--arg_dep_lookup ; #"c" works for C++, too
292 # Disable Microsoft "secure" overloads in Dinkumware libraries since they
293 # cause compile errors with Intel versions 9 and 10.
296 C++FLAGS += -D_SECURE_SCL=0 ;
301 C++FLAGS += /Zc:forScope ; # Add support for correct for loop scoping.
304 # Add options recognized only by intel7 and above.
307 C++FLAGS += /Qansi_alias ;
310 if $(compatibility) = vc6
316 # No wchar_t support in vc6 dinkum library. Furthermore, in vc6
317 # compatibility-mode, wchar_t is not a distinct type from unsigned
319 -DBOOST_NO_INTRINSIC_WCHAR_T
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
334 if $(compatibility) && $(compatibility) != native
336 C++FLAGS += /Q$(compatibility) ;
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
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- ;
360 if ! $(compatibility)
362 # If there's no backend version, assume 7.1.
363 compatibility = vc7.1 ;
366 msvc-version = [ msvc.resolve-possible-msvc-version-alias $(msvc-version) ] ;
367 msvc.configure-version-specific intel-win : $(msvc-version) : $(condition) ;
370 local rule get-autodetect-versions
373 for local v in $(.intel-autodetect-versions)
375 local major = [ MATCH ([0-9]+).* : $(v) ] ; # Use only major version
376 if [ get-icl-path-from-environment $(major) ]
384 local rule get-icl-path-from-environment ( major_version )
386 local path = [ os.environ ICPP_COMPILER$(major_version) ] ;
389 path = [ path.make $(path) ] ;
391 local subdirs = $(.icl-target-subdirectories) ;
394 cmdpath = [ path.join $(path) "bin/$(subdirs[0])/icl.exe" ] ;
395 cmdpath = [ path.native $(cmdpath) ] ;
396 if [ path.exists $(cmdpath) ]
401 subdirs = $(subdirs[2-]) ;
409 local rule get-compiler-invocation-cmd ( major_version : command * )
413 return [ common.get-invocation-command intel-win : icl.exe : $(command) ] ;
417 local path = [ get-icl-path-from-environment $(major_version) ] ;
418 return [ common.get-invocation-command intel-win : icl.exe : $(path) ] ;
422 local rule is-msvc-supported ( intel-version : msvc-version )
430 if $(.iclvars-$(intel-version)-supported-vcs)
432 if [ MATCH "($(msvc-version))" : $(.iclvars-$(intel-version)-supported-vcs) ]
444 local rule get-msvc-version-from-vc-string ( vc-string )
446 local r = [ MATCH "^vc([0-9]+(\\.[0-9]+)?)$" : $(vc-string) ] ;
450 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
452 .debug-configuration = true ;
455 # Copied from msvc.jam
456 # Supported CPU architectures.
458 <architecture>/<address-model>
459 <architecture>/<address-model>32
460 <architecture>x86/<address-model>
461 <architecture>x86/<address-model>32 ;
464 <architecture>/<address-model>64
465 <architecture>x86/<address-model>64 ;
467 .cpu-arch-ia32_intel64 =
468 <architecture>/<address-model>64
469 <architecture>x86/<address-model>64 ;
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 ;
487 toolset.flags intel-win.link LIBRARY_OPTION <toolset>intel : "" ;
489 toolset.flags intel-win YLOPTION ;