summaryrefslogtreecommitdiff
path: root/jam-files/boost-build/tools/intel-linux.jam
blob: d9164add80705135853f2253b6bbc5ae0ffcd362 (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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#  Copyright (c) 2003 Michael Stevens
#  Copyright (c) 2011 Bryce Lelbach
#
#  Use, modification and distribution is subject to the Boost Software
#  License Version 1.0. (See accompanying file LICENSE_1_0.txt or
#  http://www.boost.org/LICENSE_1_0.txt)

import toolset ;
import feature ;
import toolset : flags ;

import intel ;
import gcc ;
import common ;
import errors ;
import generators ;
import type ;
import numbers ;

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

toolset.inherit-generators intel-linux 
     <toolset>intel <toolset-intel:platform>linux : gcc : gcc.mingw.link gcc.mingw.link.dll ;
generators.override intel-linux.prebuilt : builtin.lib-generator ;
generators.override intel-linux.prebuilt : builtin.prebuilt ;
generators.override intel-linux.searched-lib-generator : searched-lib-generator ;

# Override default do-nothing generators.
generators.override intel-linux.compile.c.pch   : pch.default-c-pch-generator   ;
generators.override intel-linux.compile.c++.pch : pch.default-cpp-pch-generator ;
 
type.set-generated-target-suffix PCH : <toolset>intel <toolset-intel:platform>linux : pchi ;

toolset.inherit-rules intel-linux : gcc ;
toolset.inherit-flags intel-linux : gcc 
        : <inlining>off <inlining>on <inlining>full
          <optimization>space <optimization>speed
          <warnings>off <warnings>all <warnings>on
        ;
        
if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
{
    .debug-configuration = true ;
}
                       
# Initializes the intel-linux toolset
#   version in mandatory
#   name (default icpc) is used to invoke the specified intel-linux complier
#   compile and link options allow you to specify addition command line options for each version
rule init ( version ? :  command * : options * )
{
    local condition = [ common.check-init-parameters intel-linux
        : version $(version) ] ;
    
    if $(.debug-configuration)
    {
        ECHO "notice: intel-linux version is" $(version) ;
    }

    local default_path ;

    # Intel C++ Composer XE 2011 for Linux, aka Intel C++ Compiler XE 12.0,
    # aka intel-linux-12.0. In this version, Intel thankfully decides to install
    # to a sane 'intel' folder in /opt.
    if [ MATCH "(12[.]0|12)" : $(version) ]
        { default_path = /opt/intel/bin ; }
    # Intel C++ Compiler 11.1. 
    else if [ MATCH "(11[.]1)" : $(version) ]
        { default_path = /opt/intel_cce_11.1.064.x86_64/bin ; }
    # Intel C++ Compiler 11.0. 
    else if [ MATCH "(11[.]0|11)" : $(version) ]
        { default_path = /opt/intel_cce_11.0.074.x86_64/bin ; }
    # Intel C++ Compiler 10.1. 
    else if [ MATCH "(10[.]1)" : $(version) ]
        { default_path = /opt/intel_cce_10.1.013_x64/bin ; }
    # Intel C++ Compiler 9.1. 
    else if [ MATCH "(9[.]1)" : $(version) ]
        { default_path = /opt/intel_cc_91/bin ; }
    # Intel C++ Compiler 9.0. 
    else if [ MATCH "(9[.]0|9)" : $(version) ]
        { default_path = /opt/intel_cc_90/bin ; }
    # Intel C++ Compiler 8.1. 
    else if [ MATCH "(8[.]1)" : $(version) ]
        { default_path = /opt/intel_cc_81/bin ; }
    # Intel C++ Compiler 8.0 - this used to be the default, so now it's the
    # fallback. 
    else 
        { default_path = /opt/intel_cc_80/bin ; }
            
    if $(.debug-configuration)
    {
        ECHO "notice: default search path for intel-linux is" $(default_path) ;
    }

    command = [ common.get-invocation-command intel-linux : icpc 
        : $(command) : $(default_path) ] ;
                
    common.handle-options intel-linux : $(condition) : $(command) : $(options) ;

    gcc.init-link-flags intel-linux gnu $(condition) ;
    
    local root = [ feature.get-values <root> : $(options) ] ;
    local bin ;
    if $(command) || $(root)
    {
        bin ?= [ common.get-absolute-tool-path $(command[-1]) ] ;
        root ?= $(bin:D) ;
        
        local command-string = $(command:J=" ") ;
        local version-output = [ SHELL "$(command-string) --version" ] ;
        local real-version = [ MATCH "([0-9.]+)" : $(version-output) ] ;
        local major = [ MATCH "([0-9]+).*" : $(real-version) ] ;
        
        # If we failed to determine major version, use the behaviour for
        # the current compiler.
        if $(major) && [ numbers.less $(major) 10 ]
        {
            flags intel-linux.compile OPTIONS $(condition)/<inlining>off : "-Ob0" ;
            flags intel-linux.compile OPTIONS $(condition)/<inlining>on : "-Ob1" ;
            flags intel-linux.compile OPTIONS $(condition)/<inlining>full : "-Ob2" ;            
            flags intel-linux.compile OPTIONS $(condition)/<optimization>space : "-O1" ;
            flags intel-linux.compile OPTIONS $(condition)/<optimization>speed : "-O3 -ip" ;
        }
        else if $(major) && [ numbers.less $(major) 11 ]
        {
            flags intel-linux.compile OPTIONS $(condition)/<inlining>off : "-inline-level=0" ; 
            flags intel-linux.compile OPTIONS $(condition)/<inlining>on : "-inline-level=1" ; 
            flags intel-linux.compile OPTIONS $(condition)/<inlining>full : "-inline-level=2" ;                
            flags intel-linux.compile OPTIONS $(condition)/<optimization>space : "-O1" ;
            flags intel-linux.compile OPTIONS $(condition)/<optimization>speed : "-O3 -ip" ;
        }
        else # newer version of intel do have -Os (at least 11+, don't know about 10)
        {                        
            flags intel-linux.compile OPTIONS $(condition)/<inlining>off : "-inline-level=0" ; 
            flags intel-linux.compile OPTIONS $(condition)/<inlining>on : "-inline-level=1" ; 
            flags intel-linux.compile OPTIONS $(condition)/<inlining>full : "-inline-level=2" ;                
            flags intel-linux.compile OPTIONS $(condition)/<optimization>space : "-Os" ;
            flags intel-linux.compile OPTIONS $(condition)/<optimization>speed : "-O3 -ip" ;
        }        
           
        if $(root)
        {
            # Libraries required to run the executable may be in either
            # $(root)/lib (10.1 and earlier) 
            #     or 
            # $(root)/lib/architecture-name (11.0 and later:
            local lib_path = $(root)/lib $(root:P)/lib/$(bin:B) ;
            if $(.debug-configuration)
            {
                ECHO notice: using intel libraries :: $(condition) :: $(lib_path) ;
            }
            flags intel-linux.link RUN_PATH $(condition) : $(lib_path) ;
        }   
    }
}

SPACE = " " ;

flags intel-linux.compile OPTIONS <warnings>off : -w0 ;
flags intel-linux.compile OPTIONS <warnings>on : -w1 ;
flags intel-linux.compile OPTIONS <warnings>all : -w2 ;

rule compile.c++ ( targets * : sources * : properties * )
{
    gcc.setup-threading $(targets) : $(sources) : $(properties) ;
    gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
    gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
    DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
}

actions compile.c++ bind PCH_FILE
{
    "$(CONFIG_COMMAND)" -c -xc++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)"  -use-pch"$(PCH_FILE)" -c -o "$(<)" "$(>)"
}

rule compile.c ( targets * : sources * : properties * )
{
    gcc.setup-threading $(targets) : $(sources) : $(properties) ;
    gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
    gcc.setup-address-model $(targets) : $(sources) : $(properties) ;    
    DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
}

actions compile.c bind PCH_FILE
{
    "$(CONFIG_COMMAND)" -c -xc $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -use-pch"$(PCH_FILE)" -c -o "$(<)" "$(>)"
}

rule compile.c++.pch ( targets * : sources * : properties * )
{
    gcc.setup-threading $(targets) : $(sources) : $(properties) ;
    gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
    gcc.setup-address-model $(targets) : $(sources) : $(properties) ;    
}
#
# Compiling a pch first deletes any existing *.pchi file, as Intel's compiler
# won't over-write an existing pch: instead it creates filename$1.pchi, filename$2.pchi
# etc - which appear not to do anything except take up disk space :-(
#
actions compile.c++.pch
{
    rm -f "$(<)" && "$(CONFIG_COMMAND)" -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -pch-create "$(<)" "$(>)"
}

actions compile.fortran
{
    "ifort" -c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
}

rule compile.c.pch ( targets * : sources * : properties * )
{
    gcc.setup-threading $(targets) : $(sources) : $(properties) ;
    gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
    gcc.setup-address-model $(targets) : $(sources) : $(properties) ;    
}

actions compile.c.pch
{
    rm -f "$(<)" && "$(CONFIG_COMMAND)" -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -pch-create "$(<)" "$(>)"
}

rule link ( targets * : sources * : properties * )
{
    gcc.setup-threading $(targets) : $(sources) : $(properties) ;
    gcc.setup-address-model $(targets) : $(sources) : $(properties) ;    
    SPACE on $(targets) = " " ;
    JAM_SEMAPHORE on $(targets) = <s>intel-linux-link-semaphore ;
}

actions link bind LIBRARIES
{
    "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(OPTIONS) $(USER_OPTIONS)
}

rule link.dll ( targets * : sources * : properties * )
{
    gcc.setup-threading $(targets) : $(sources) : $(properties) ;
    gcc.setup-address-model $(targets) : $(sources) : $(properties) ;    
    SPACE on $(targets) = " " ;
    JAM_SEMAPHORE on $(targets) = <s>intel-linux-link-semaphore ;
}

# Differ from 'link' above only by -shared.
actions link.dll bind LIBRARIES
{
    "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o "$(<)" -Wl,-soname$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)"  "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(OPTIONS) $(USER_OPTIONS)
}