1# Copyright (c) 2003 Michael Stevens 2# Copyright (c) 2011 Bryce Lelbach 3# 4# Use, modification and distribution is subject to the Boost Software 5# License Version 1.0. (See accompanying file LICENSE_1_0.txt or 6# http://www.boost.org/LICENSE_1_0.txt) 7 8import toolset ; 9import feature ; 10import toolset : flags ; 11 12import intel ; 13import gcc ; 14import common ; 15import errors ; 16import generators ; 17import type ; 18import numbers ; 19 20feature.extend-subfeature toolset intel : platform : linux ; 21 22toolset.inherit-generators intel-linux 23 <toolset>intel <toolset-intel:platform>linux : gcc : gcc.mingw.link gcc.mingw.link.dll ; 24generators.override intel-linux.prebuilt : builtin.lib-generator ; 25generators.override intel-linux.prebuilt : builtin.prebuilt ; 26generators.override intel-linux.searched-lib-generator : searched-lib-generator ; 27 28# Override default do-nothing generators. 29generators.override intel-linux.compile.c.pch : pch.default-c-pch-generator ; 30generators.override intel-linux.compile.c++.pch : pch.default-cpp-pch-generator ; 31 32type.set-generated-target-suffix PCH : <toolset>intel <toolset-intel:platform>linux : pchi ; 33 34toolset.inherit-rules intel-linux : gcc ; 35toolset.inherit-flags intel-linux : gcc 36 : <inlining>off <inlining>on <inlining>full 37 <optimization>space <optimization>speed 38 <warnings>off <warnings>all <warnings>on 39 ; 40 41if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] 42{ 43 .debug-configuration = true ; 44} 45 46# Initializes the intel-linux toolset 47# version in mandatory 48# name (default icpc) is used to invoke the specified intel-linux compiler 49# compile and link options allow you to specify addition command line options for each version 50rule init ( version ? : command * : options * ) 51{ 52 local condition = [ common.check-init-parameters intel-linux 53 : version $(version) ] ; 54 55 if $(.debug-configuration) 56 { 57 ECHO "notice: intel-linux version is" $(version) ; 58 } 59 60 local default_path ; 61 62 # Intel C++ Composer XE 2011 for Linux, aka Intel C++ Compiler XE 12.0, 63 # aka intel-linux-12.0. In this version, Intel thankfully decides to install 64 # to a sane 'intel' folder in /opt. 65 if [ MATCH "(12[.]0|12)" : $(version) ] 66 { default_path = /opt/intel/bin ; } 67 # Intel C++ Compiler 11.1. 68 else if [ MATCH "(11[.]1)" : $(version) ] 69 { default_path = /opt/intel_cce_11.1.064.x86_64/bin ; } 70 # Intel C++ Compiler 11.0. 71 else if [ MATCH "(11[.]0|11)" : $(version) ] 72 { default_path = /opt/intel_cce_11.0.074.x86_64/bin ; } 73 # Intel C++ Compiler 10.1. 74 else if [ MATCH "(10[.]1)" : $(version) ] 75 { default_path = /opt/intel_cce_10.1.013_x64/bin ; } 76 # Intel C++ Compiler 9.1. 77 else if [ MATCH "(9[.]1)" : $(version) ] 78 { default_path = /opt/intel_cc_91/bin ; } 79 # Intel C++ Compiler 9.0. 80 else if [ MATCH "(9[.]0|9)" : $(version) ] 81 { default_path = /opt/intel_cc_90/bin ; } 82 # Intel C++ Compiler 8.1. 83 else if [ MATCH "(8[.]1)" : $(version) ] 84 { default_path = /opt/intel_cc_81/bin ; } 85 # Intel C++ Compiler 8.0 - this used to be the default, so now it's the 86 # fallback. 87 else 88 { default_path = /opt/intel_cc_80/bin ; } 89 90 if $(.debug-configuration) 91 { 92 ECHO "notice: default search path for intel-linux is" $(default_path) ; 93 } 94 95 command = [ common.get-invocation-command intel-linux : icpc 96 : $(command) : $(default_path) ] ; 97 98 common.handle-options intel-linux : $(condition) : $(command) : $(options) ; 99 100 local root = [ feature.get-values <root> : $(options) ] ; 101 local bin ; 102 if $(command) || $(root) 103 { 104 bin ?= [ common.get-absolute-tool-path $(command[-1]) ] ; 105 root ?= $(bin:D) ; 106 107 local command-string = $(command:J=" ") ; 108 local version-output = [ SHELL "$(command-string) --version" ] ; 109 local real-version = [ MATCH "([0-9.]+)" : $(version-output) ] ; 110 local major = [ MATCH "([0-9]+).*" : $(real-version) ] ; 111 112 # If we failed to determine major version, use the behaviour for 113 # the current compiler. 114 if $(major) && [ numbers.less $(major) 10 ] 115 { 116 flags intel-linux.compile OPTIONS $(condition)/<inlining>off : "-Ob0" ; 117 flags intel-linux.compile OPTIONS $(condition)/<inlining>on : "-Ob1" ; 118 flags intel-linux.compile OPTIONS $(condition)/<inlining>full : "-Ob2" ; 119 flags intel-linux.compile OPTIONS $(condition)/<optimization>space : "-O1" ; 120 flags intel-linux.compile OPTIONS $(condition)/<optimization>speed : "-O3 -ip" ; 121 } 122 else if $(major) && [ numbers.less $(major) 11 ] 123 { 124 flags intel-linux.compile OPTIONS $(condition)/<inlining>off : "-inline-level=0" ; 125 flags intel-linux.compile OPTIONS $(condition)/<inlining>on : "-inline-level=1" ; 126 flags intel-linux.compile OPTIONS $(condition)/<inlining>full : "-inline-level=2" ; 127 flags intel-linux.compile OPTIONS $(condition)/<optimization>space : "-O1" ; 128 flags intel-linux.compile OPTIONS $(condition)/<optimization>speed : "-O3 -ip" ; 129 } 130 else # newer version of intel do have -Os (at least 11+, don't know about 10) 131 { 132 flags intel-linux.compile OPTIONS $(condition)/<inlining>off : "-inline-level=0" ; 133 flags intel-linux.compile OPTIONS $(condition)/<inlining>on : "-inline-level=1" ; 134 flags intel-linux.compile OPTIONS $(condition)/<inlining>full : "-inline-level=2" ; 135 flags intel-linux.compile OPTIONS $(condition)/<optimization>space : "-Os" ; 136 flags intel-linux.compile OPTIONS $(condition)/<optimization>speed : "-O3 -ip" ; 137 } 138 139 if $(root) 140 { 141 # Libraries required to run the executable may be in either 142 # $(root)/lib (10.1 and earlier) 143 # or 144 # $(root)/lib/architecture-name (11.0 and later: 145 local lib_path = $(root)/lib $(root:P)/lib/$(bin:B) ; 146 if $(.debug-configuration) 147 { 148 ECHO notice\: using intel libraries "::" $(condition) "::" $(lib_path) ; 149 } 150 flags intel-linux.link RUN_PATH $(condition) : $(lib_path) ; 151 } 152 } 153} 154 155SPACE = " " ; 156 157flags intel-linux.compile OPTIONS <warnings>off : -w0 ; 158flags intel-linux.compile OPTIONS <warnings>on : -w1 ; 159flags intel-linux.compile OPTIONS <warnings>all : -w2 ; 160 161rule compile.c++ ( targets * : sources * : properties * ) 162{ 163 DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ; 164} 165 166actions compile.c++ bind PCH_FILE 167{ 168 "$(CONFIG_COMMAND)" -c -xc++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -use-pch"$(PCH_FILE)" -c -o "$(<)" "$(>)" 169} 170 171rule compile.c ( targets * : sources * : properties * ) 172{ 173 DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ; 174} 175 176actions compile.c bind PCH_FILE 177{ 178 "$(CONFIG_COMMAND)" -c -xc $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -use-pch"$(PCH_FILE)" -c -o "$(<)" "$(>)" 179} 180 181rule compile.c++.pch ( targets * : sources * : properties * ) 182{ 183} 184# 185# Compiling a pch first deletes any existing *.pchi file, as Intel's compiler 186# won't over-write an existing pch: instead it creates filename$1.pchi, filename$2.pchi 187# etc - which appear not to do anything except take up disk space :-( 188# 189actions compile.c++.pch 190{ 191 rm -f "$(<)" && "$(CONFIG_COMMAND)" -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -pch-create "$(<)" "$(>)" 192} 193 194actions compile.fortran 195{ 196 "ifort" -c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" 197} 198 199rule compile.c.pch ( targets * : sources * : properties * ) 200{ 201} 202 203actions compile.c.pch 204{ 205 rm -f "$(<)" && "$(CONFIG_COMMAND)" -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -pch-create "$(<)" "$(>)" 206} 207 208rule link ( targets * : sources * : properties * ) 209{ 210 SPACE on $(targets) = " " ; 211 JAM_SEMAPHORE on $(targets) = <s>intel-linux-link-semaphore ; 212} 213 214actions link bind LIBRARIES 215{ 216 "$(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) 217} 218 219rule link.dll ( targets * : sources * : properties * ) 220{ 221 SPACE on $(targets) = " " ; 222 JAM_SEMAPHORE on $(targets) = <s>intel-linux-link-semaphore ; 223} 224 225# Differ from 'link' above only by -shared. 226actions link.dll bind LIBRARIES 227{ 228 "$(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) 229} 230 231 232 233