8000 MSVCCompiler overwrite 'lib' and 'include' environment variables. This · numpy/numpy@7cba81b · GitHub
[go: up one dir, main page]

Skip to content

Commit 7cba81b

Browse files
dmitrii-zagornyicharris
authored andcommitted
MSVCCompiler overwrite 'lib' and 'include' environment variables. This
behavior affect at least python 3.5 and SciPy build and build failed. During initialization <python>.distutils.MSVCCompiler replace Intel environment('include' and 'lib' paths). This fix decorate 'initialize' function in MSVCCompiler and extend 'lib' and 'include' environment variables. Changed compilation keys: generate optimized code specialized for Intel processors with SSE4.2 support.
1 parent 8bf83c4 commit 7cba81b

File tree

6 files changed

+71
-35
lines changed

6 files changed

+71
-35
lines changed

numpy/distutils/fcompiler/compaq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class CompaqVisualFCompiler(FCompiler):
7474
fc_exe = 'DF'
7575

7676
if sys.platform=='win32':
77-
from distutils.msvccompiler import MSVCCompiler
77+
from numpy.distutils.msvccompiler import MSVCCompiler
7878

7979
try:
8080
m = MSVCCompiler()

numpy/distutils/fcompiler/intel.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
'IntelItaniumFCompiler', 'IntelItaniumVisualFCompiler',
1111
'IntelEM64VisualFCompiler', 'IntelEM64TFCompiler']
1212

13+
1314
def intel_version_match(type):
1415
# Match against the important stuff in the version string
1516
return simple_version_match(start=r'Intel.*?Fortran.*?(?:%s).*?Version' % (type,))
@@ -45,17 +46,16 @@ class IntelFCompiler(BaseIntelFCompiler):
4546
}
4647

4748
pic_flags = ['-fPIC']
48-
module_dir_switch = '-module ' # Don't remove ending space!
49+
module_dir_switch = '-module ' # Don't remove ending space!
4950
module_include_switch = '-I'
5051

5152
def get_flags_free(self):
52-
return ["-FR"]
53+
return ['-FR']
5354

5455
def get_flags(self):
5556
return ['-fPIC']
5657

5758
def get_flags_opt(self):
58-
#return ['-i8 -xhost -openmp -fp-model strict']
5959
return ['-xhost -openmp -fp-model strict']
6060

6161
def get_flags_arch(self):
@@ -120,11 +120,10 @@ def get_flags(self):
120120
return ['-fPIC']
121121

122122
def get_flags_opt(self):
123-
#return ['-i8 -xhost -openmp -fp-model strict']
124-
return ['-xhost -openmp -fp-model strict']
123+
return ['-openmp -fp-model strict']
125124

126125
def get_flags_arch(self):
127-
return []
126+
return ['-xSSE4.2']
128127

129128
# Is there no difference in the version string between the above compilers
130129
# and the Visual compilers?
@@ -145,26 +144,26 @@ def update_executables(self):
145144

146145
executables = {
147146
'version_cmd' : None,
148-
'compiler_f77' : [None, "-FI", "-w90", "-w95"],
149-
'compiler_fix' : [None, "-FI", "-4L72", "-w"],
147+
'compiler_f77' : [None],
148+
'compiler_fix' : [None],
150149
'compiler_f90' : [None],
151-
'linker_so' : ['<F90>', "-shared"],
150+
'linker_so' : [None],
152151
'archiver' : [ar_exe, "/verbose", "/OUT:"],
153152
'ranlib' : None
154153
}
155154

156155
compile_switch = '/c '
157-
object_switch = '/Fo' #No space after /Fo!
158-
library_switch = '/OUT:' #No space after /OUT:!
159-
module_dir_switch = '/module:' #No space after /module:
156+
object_switch = '/Fo' # No space after /Fo!
157+
library_switch = '/OUT:' # No space after /OUT:!
158+
module_dir_switch = '/module:' # No space after /module:
160159
module_include_switch = '/I'
161160

162161
def get_flags(self):
163162
opt = ['/nologo', '/MD', '/nbs', '/names:lowercase', '/assume:underscore']
164163
return opt
165164

166165
def get_flags_free(self):
167-
return ["-FR"]
166+
return []
168167

169168
def get_flags_debug(self):
170169
return ['/4Yb', '/d2']
@@ -185,7 +184,7 @@ class IntelItaniumVisualFCompiler(IntelVisualFCompiler):
185184

186185
version_match = intel_version_match('Itanium')
187186

188-
possible_executables = ['efl'] # XXX this is a wild guess
187+
possible_executables = ['efl'] # XXX this is a wild guess
189188
ar_exe = IntelVisualFCompiler.ar_exe
190189

191190
executables = {
@@ -206,7 +205,7 @@ class IntelEM64VisualFCompiler(IntelVisualFCompiler):
206205
version_match = simple_version_match(start='Intel\(R\).*?64,')
207206

208207
def get_flags_arch(self):
209-
return ["/arch:SSE2"]
208+
return ['/QxSSE4.2']
210209

211210

212211
if __name__ == '__main__':

numpy/distutils/intelccompiler.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from __future__ import division, absolute_import, print_function
22

3-
import sys
3+
import platform
44

55
from distutils.unixccompiler import UnixCCompiler
6+
if platform.system() == 'Windows':
7+
from numpy.distutils.msvc9compiler import MSVCCompiler
68
from numpy.distutils.exec_command import find_executable
79
from numpy.distutils.ccompiler import simple_version_match
810

@@ -15,14 +17,14 @@ class IntelCCompiler(UnixCCompiler):
1517

1618
def __init__(self, verbose=0, dry_run=0, force=0):
1719
UnixCCompiler.__init__(self, verbose, dry_run, force)
18-
self.cc_exe = 'icc -fPIC'
20+
self.cc_exe = 'icc -fPIC -fp-model strict -O3 -fomit-frame-pointer -openmp'
1921
compiler = self.cc_exe
2022
self.set_executables(compiler=compiler,
2123
compiler_so=compiler,
2224
compiler_cxx=compiler,
2325
archiver='xiar' + ' cru',
24-
linker_exe=compiler,
25-
linker_so=compiler + ' -shared')
26+
linker_exe=compiler + ' -shared-intel',
27+
linker_so=compiler + ' -shared -shared-intel')
2628

2729

2830
class IntelItaniumCCompiler(IntelCCompiler):
@@ -40,24 +42,22 @@ class IntelEM64TCCompiler(UnixCCompiler):
4042
A modified Intel x86_64 compiler compatible with a 64bit GCC-built Python.
4143
"""
4244
compiler_type = 'intelem'
43-
cc_exe = 'icc -m64 -fPIC'
44-
cc_args = "-fPIC"
45+
cc_exe = 'icc -m64'
46+
cc_args = '-fPIC'
4547

4648
def __init__(self, verbose=0, dry_run=0, force=0):
4749
UnixCCompiler.__init__(self, verbose, dry_run, force)
48-
self.cc_exe = 'icc -m64 -fPIC'
50+
self.cc_exe = 'icc -m64 -fPIC -fp-model strict -O3 -fomit-frame-pointer -openmp -xSSE4.2'
4951
compiler = self.cc_exe
5052
self.set_executables(compiler=compiler,
5153
compiler_so=compiler,
5254
compiler_cxx=compiler,
5355
archiver='xiar' + ' cru',
54-
linker_exe=compiler,
55-
linker_so=compiler + ' -shared')
56+
linker_exe=compiler + ' -shared-intel',
57+
linker_so=compiler + ' -shared -shared-intel')
5658

5759

58-
if sys.platform == 'win32':
59-
from distutils.msvc9compiler import MSVCCompiler
60-
60+
if platform.system() == 'Windows':
6161
class IntelCCompilerW(MSVCCompiler):
6262
"""
6363
A modified Intel compiler compatible with an MSVC-built Python.
@@ -72,11 +72,11 @@ def __init__(self, verbose=0, dry_run=0, force=0):
7272

7373
def initialize(self, plat_name=None):
7474
MSVCCompiler.initialize(self, plat_name)
75-
self.cc = self.find_exe("icl.exe")
76-
self.lib = self.find_exe("xilib")
77-
self.linker = self.find_exe("xilink")
75+
self.cc = self.find_exe('icl.exe')
76+
self.lib = self.find_exe('xilib')
77+
self.linker = self.find_exe('xilink')
7878
self.compile_options = ['/nologo', '/O3', '/MD', '/W3',
79-
'/Qstd=c99']
79+
'/Qstd=c99', '/QxSSE4.2']
8080
self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3',
8181
'/Qstd=c99', '/Z7', '/D_DEBUG']
8282

@@ -91,4 +91,3 @@ def __init__(self, verbose=0, dry_run=0, force=0):
9191
MSVCCompiler.__init__(self, verbose, dry_run, force)
9292
version_match = simple_version_match(start='Intel\(R\).*?64,')
9393
self.__version = version_match
94-

numpy/distutils/msvc9compiler.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
from distutils.msvccompiler import *
3+
from distutils.msvc9compiler import MSVCCompiler as distutils_MSVCCompiler
4+
5+
6+
class MSVCCompiler(distutils_MSVCCompiler):
7+
def __init__(self, verbose=0, dry_run=0, force=0):
8+
distutils_MSVCCompiler.__init__(self, verbose, dry_run, force)
9+
10+
def initialize(self, plat_name=None):
11+
environ_lib = os.getenv('lib')
12+
environ_include = os.getenv('include')
13+
distutils_MSVCCompiler.initialize(self, plat_name)
14+
if environ_lib is not None:
15+
os.environ['lib'] = environ_lib + os.environ['lib']
16+
if environ_include is not None:
17+
os.environ['include'] = environ_include + os.environ['include']
18+
19+
def manifest_setup_ldargs(self, output_filename, build_temp, ld_args):
20+
ld_args.append('/MANIFEST')
21+
distutils_MSVCCompiler.manifest_setup_ldargs(self, output_filename, build_temp, ld_args)

numpy/distutils/msvccompiler.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
from distutils.msvccompiler import *
3+
from distutils.msvccompiler import MSVCCompiler as distutils_MSVCCompiler
4+
5+
6+
class MSVCCompiler(distutils_MSVCCompiler):
7+
def __init__(self, verbose=0, dry_run=0, force=0):
8+
distutils_MSVCCompiler.__init__(self, verbose, dry_run, force)
9+
10+
def initialize(self, plat_name=None):
11+
environ_lib = os.getenv('lib')
12+
environ_include = os.getenv('include')
13+
distutils_MSVCCompiler.initialize(self, plat_name)
14+
if environ_lib is not None:
15+
os.environ['lib'] = environ_lib + os.environ['lib']
16+
if environ_include is not None:
17+
os.environ['include'] = environ_include + os.environ['include']

numpy/distutils/system_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,8 +999,8 @@ def __init__(self):
999999
plt = '64'
10001000
#l = 'mkl_ipf'
10011001
elif cpu.is_Xeon():
1002-
plt = 'em64t'
1003-
#l = 'mkl_em64t'
1002+
plt = 'intel64'
1003+
#l = 'mkl_intel64'
10041004
else:
10051005
plt = '32'
10061006
#l = 'mkl_ia32'

0 commit comments

Comments
 (0)
0