summaryrefslogtreecommitdiff
path: root/jam-files/boost-build/tools/intel-win.jam
blob: 691b5dce98a305ece0cfbd120c79f224ccc23dbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# Copyright Vladimir Prus 2004.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)

# Importing common is needed because the rules we inherit here depend on it.
# That is nasty.
import common ;
import errors ;
import feature ;
import intel ;
import msvc ;
import os ;
import toolset ;
import generators ;
import type ;

feature.extend-subfeature toolset intel : platform : win ;

toolset.inherit-generators intel-win <toolset>intel <toolset-intel:platform>win : msvc ;
toolset.inherit-flags intel-win : msvc : : YLOPTION ;
toolset.inherit-rules intel-win : msvc ;

# Override default do-nothing generators.
generators.override intel-win.compile.c.pch   : pch.default-c-pch-generator   ;
generators.override intel-win.compile.c++.pch : pch.default-cpp-pch-generator ;
generators.override intel-win.compile.rc : rc.compile.resource ;
generators.override intel-win.compile.mc : mc.compile ;

toolset.flags intel-win.compile PCH_SOURCE <pch>on : <pch-source> ;

toolset.add-requirements <toolset>intel-win,<runtime-link>shared:<threading>multi ;

# Initializes the intel toolset for windows
rule init ( version ? :     # the compiler version
            command * :     # the command to invoke the compiler itself
            options *       # Additional option: <compatibility>
                            # either 'vc6', 'vc7', 'vc7.1'
                            # or 'native'(default).
          )
{
    local compatibility =
      [ feature.get-values <compatibility> : $(options) ] ;
    local condition = [  common.check-init-parameters intel-win
        : version $(version) : compatibility $(compatibility) ] ;

    command = [ common.get-invocation-command intel-win : icl.exe :
        $(command) ] ;

    common.handle-options intel-win : $(condition) : $(command) : $(options) ;

    local root ;
    if $(command)
    {
        root = [ common.get-absolute-tool-path $(command[-1]) ] ;
        root = $(root)/ ;
    }

    local setup ;
    setup = [ GLOB $(root) : iclvars_*.bat ] ;
    if ! $(setup)
    {
       setup = $(root)/iclvars.bat ;
    }
    setup = "call \""$(setup)"\" > nul " ;

    if [ os.name ] = NT
    {
        setup = $(setup)"
" ;
    }
    else
    {
        setup = "cmd /S /C "$(setup)" \"&&\" " ;
    }

    toolset.flags intel-win.compile .CC $(condition) : $(setup)icl ;
    toolset.flags intel-win.link .LD $(condition) : $(setup)xilink ;
    toolset.flags intel-win.archive .LD $(condition) : $(setup)xilink /lib ;
    toolset.flags intel-win.link .MT $(condition) : $(setup)mt -nologo ;
    toolset.flags intel-win.compile .MC $(condition) : $(setup)mc ;
    toolset.flags intel-win.compile .RC $(condition) : $(setup)rc ;

    local m = [ MATCH (.).* : $(version) ] ;
    local major = $(m[1]) ;

    local C++FLAGS ;

    C++FLAGS += /nologo ;

    # Reduce the number of spurious error messages
    C++FLAGS += /Qwn5 /Qwd985 ;

    # Enable ADL
    C++FLAGS += -Qoption,c,--arg_dep_lookup ; #"c" works for C++, too

    # Disable Microsoft "secure" overloads in Dinkumware libraries since they
    # cause compile errors with Intel versions 9 and 10.
    C++FLAGS += -D_SECURE_SCL=0 ;

    if $(major) > 5
    {
        C++FLAGS += /Zc:forScope ;  # Add support for correct for loop scoping.
    }

    # Add options recognized only by intel7 and above.
    if $(major) >= 7
    {
        C++FLAGS += /Qansi_alias ;
    }

    if $(compatibility) = vc6
    {
        C++FLAGS +=
          # Emulate VC6
          /Qvc6

          # No wchar_t support in vc6 dinkum library.  Furthermore, in vc6
          # compatibility-mode, wchar_t is not a distinct type from unsigned
          # short.
          -DBOOST_NO_INTRINSIC_WCHAR_T
          ;
    }
    else
    {
        if $(major) > 5
        {
            # Add support for wchar_t
            C++FLAGS += /Zc:wchar_t
              # Tell the dinkumware library about it.
              -D_NATIVE_WCHAR_T_DEFINED
              ;
        }
    }

    if $(compatibility) && $(compatibility) != native
    {
        C++FLAGS += /Q$(base-vc) ;
    }
    else
    {
        C++FLAGS +=
          -Qoption,cpp,--arg_dep_lookup
          # The following options were intended to disable the Intel compiler's
          # 'bug-emulation' mode, but were later reported to be causing ICE with
          # Intel-Win 9.0. It is not yet clear which options can be safely used.
          # -Qoption,cpp,--const_string_literals
          # -Qoption,cpp,--new_for_init
          # -Qoption,cpp,--no_implicit_typename
          # -Qoption,cpp,--no_friend_injection
          # -Qoption,cpp,--no_microsoft_bugs
          ;
    }

    toolset.flags intel-win CFLAGS $(condition) : $(C++FLAGS) ;
    # By default, when creating PCH, intel adds 'i' to the explicitly
    # specified name of the PCH file. Of course, Boost.Build is not
    # happy when compiler produces not the file it was asked for.
    # The option below stops this behaviour.
    toolset.flags intel-win CFLAGS : -Qpchi- ;

    if ! $(compatibility)
    {
        # If there's no backend version, assume 7.1.
        compatibility = vc7.1 ;
    }

    local extract-version = [ MATCH ^vc(.*) : $(compatibility) ] ;
    if ! $(extract-version)
    {
        errors.user-error "Invalid value for compatibility option:"
            $(compatibility) ;
    }

    # Depending on the settings, running of tests require some runtime DLLs.
    toolset.flags intel-win RUN_PATH $(condition) : $(root) ;

    msvc.configure-version-specific intel-win : $(extract-version[1]) : $(condition) ;
}

toolset.flags intel-win.link LIBRARY_OPTION <toolset>intel : "" ;

toolset.flags intel-win YLOPTION ;