8000 Mingw w64 building by carlkl · Pull Request #5587 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Mingw w64 building #5587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
mingw-w64 support for the mingw64static option
  • Loading branch information
carlkl committed Feb 20, 2015
commit a144c29f4ffbb1e6b609e819500e66df378d5bd2
9 changes: 0 additions & 9 deletions numpy/core/src/multiarray/multiarraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4316,15 +4316,6 @@ PyMODINIT_FUNC initmultiarray(void) {
goto err;
}

#if defined(MS_WIN64) && defined(__GNUC__)
PyErr_WarnEx(PyExc_Warning,
"Numpy built with MINGW-W64 on Windows 64 bits is experimental, " \
"and only available for \n" \
"testing. You are advised not to use it for production. \n\n" \
"CRASHES ARE TO BE EXPECTED - PLEASE REPORT THEM TO NUMPY DEVELOPERS",
1);
#endif

/* Initialize access to the PyDateTime API */
numpy_pydatetime_import();

Expand Down
31 changes: 21 additions & 10 deletions numpy/distutils/fcompiler/gnu.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
# XXX: handle cross compilation
def is_win64():
return sys.platform == "win32" and platform.architecture()[0] == "64bit"
def is_win32():
return sys.platform == "win32" and platform.architecture()[0] == "32bit"

if is_win64():
#_EXTRAFLAGS = ["-fno-leading-underscore"]
Expand Down Expand Up @@ -130,7 +132,7 @@ def get_flags_linker_so(self):

opt.extend(['-undefined', 'dynamic_lookup', '-bundle'])
else:
opt.append("-shared")
opt.append("-shared -Wl,-gc-sections -Wl,-s")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces after ,s.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM. It's a string ;)

if sys.platform.startswith('sunos'):
# SunOS often has dynamically loaded symbols defined in the
# static library libg2c.a The linker doesn't like this. To
Expand Down Expand Up @@ -200,9 +202,17 @@ def get_flags_opt(self):
# With this compiler version building Fortran BLAS/LAPACK
# with -O3 caused failures in lib.lapack heevr,syevr tests.
opt = ['-O2']
elif v and v>='4.6.0':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces around >=.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very old code, did -funroll-loops serve any purpose or is that now part of the general optimization?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if is_win32():
# use -mincoming-stack-boundary=2
# due to the change to 16 byte stack alignment since GCC 4.6
# but 32 bit Windows ABI defines 4 bytes stack alignment
opt = ['-O2 -march=core2 -mtune=generic -mfpmath=sse -msse2 -mincoming-stack-boundary=2']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can break this long line something like

opt = ['-O2 -march=core2 -mtune=generic -mfpmath=sse -msse2'
       '-mincoming-stack-boundary=2']

else:
opt = ['-O2 -march=x86-64 -DMS_WIN64 -mtune=generic -msse2']
else:
opt = ['-O3']
opt.append('-funroll-loops')
opt = ['-O2']
# opt.append()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just delete?

return opt

def _c_arch_flags(self):
Expand Down Expand Up @@ -349,10 +359,7 @@ def get_target(self):
return ""

def get_flags_opt(self):
if is_win64():
return ['-O0']
else:
return GnuFCompiler.get_flags_opt(self)
return GnuFCompiler.get_flags_opt(self)

def _can_target(cmd, arch):
"""Return true is the command supports the -arch flag for the given
Expand All @@ -378,9 +385,13 @@ def _can_target(cmd, arch):
from distutils import log
log.set_verbosity(2)

compiler = GnuFCompiler()
compiler.customize()
print(compiler.get_version())
try:
compiler = GnuFCompiler()
compiler.customize()
print(compiler.get_version())
except Exception:
msg = get_exception()
print(msg)

try:
compiler = Gnu95FCompiler()
Expand Down
48 changes: 30 additions & 18 deletions numpy/distutils/mingw32ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,28 @@ def __init__ (self,
elif self.linker_dll == 'gcc':
self.linker = 'g++'

# **changes: eric jones 4/11/01
# 1. Check for import library on Windows. Build if it doesn't exist.

build_import_library()

# Check for custom msvc runtime library on Windows. Build if it doesn't exist.
msvcr_success = build_msvcr_library()
msvcr_dbg_success = build_msvcr_library(debug=True)
if msvcr_success or msvcr_dbg_success:
# add preprocessor statement for using customized msvcr lib
self.define_macro('NPY_MINGW_USE_CUSTOM_MSVCR')
p = subprocess.Popen(['gcc', '--version'], shell=True,
stdout=subprocess.PIPE)
out_string = p.stdout.read()
p.stdout.close()

# Before build with MinGW-W64 generate the python import library
# with gendef and dlltool according to the MingW-W64 FAQ.
# Use the MinGW-W64 provided msvc runtime import libraries.
# Don't call build_import_library() and build_msvcr_library.

if 'MinGW-W64' not in str(out_string):

# **changes: eric jones 4/11/01
# 1. Check for import library on Windows. Build if it doesn't exist.
build_import_library()

# Check for custom msvc runtime library on Windows. Build if it doesn't exist.
msvcr_success = build_msvcr_library()
msvcr_dbg_success = build_msvcr_library(debug=True)
if msvcr_success or msvcr_dbg_success:
# add preprocessor statement for using customized msvcr lib
self.define_macro('NPY_MINGW_USE_CUSTOM_MSVCR')

# Define the MSVC version as hint for MinGW
msvcr_version = '0x%03i0' % int(msvc_runtime_library().lstrip('msvcr'))
Expand Down Expand Up @@ -124,10 +135,10 @@ def __init__ (self,
else:
# gcc-4 series releases do not support -mno-cygwin option
self.set_executables(
compiler='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall',
compiler_so='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes',
linker_exe='gcc -g',
linker_so='gcc -g -shared')
compiler='gcc -march=x86-64 -mtune=generic -DMS_WIN64 -O2 -msse2 -Wall',
compiler_so='gcc -march=x86-64 -mtune=generic -DMS_WIN64 -O2 -msse2 -Wall -Wstrict-prototypes',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be good to break long line here. Might even need to use \ :(.

linker_exe='gcc',
linker_so='gcc -shared -Wl,-gc-sections -Wl,-s')
else:
if self.gcc_version <= "3.0.0":
self.set_executables(compiler='gcc -mno-cygwin -O2 -w',
Expand All @@ -142,10 +153,11 @@ def __init__ (self,
linker_so='g++ -mno-cygwin -shared')
else:
# gcc-4 series releases do not support -mno-cygwin option
self.set_executables(compiler='gcc -O2 -Wall',
compiler_so='gcc -O2 -Wall -Wstrict-prototypes',
# i686 build needs '-mincoming-stack-boundary=2' due to ABI incompatibility to Win32 ABI
self.set_executables(compiler='gcc -O2 -march=core2 -mtune=generic -mfpmath=sse -msse2 -mincoming-stack-boundary=2 -Wall',
compiler_so='gcc -O2 -march=core2 -mtune=generic -mfpmath=sse -msse2 -mincoming-stack-boundary=2 -Wall -Wstrict-prototypes',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to break these long lines as the are inclosed in (...).

linker_exe='g++ ',
linker_so='g++ -shared')
linker_so='g++ -shared -Wl,-gc-sections -Wl,-s')
# added for python2.3 support
# we can't pass it through set_executables because pre 2.2 would fail
self.compiler_cxx = ['g++']
Expand Down
2 changes: 1 addition & 1 deletion numpy/lib/tests/test_function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def test_ufunc(self):
args = np.array([0, 0.5*np.pi, np.pi, 1.5*np.pi, 2*np.pi])
r1 = f(args)
r2 = np.cos(args)
assert_array_equal(r1, r2)
assert_array_almost_equal(r1, r2)

def test_keywords(self):
import math
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def setup_package():
platforms = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
test_suite='nose.collector',
cmdclass={"sdist": sdist_checked},
package_data={'numpy.core': ['libopenblaspy.dll']},
)

# Run build
Expand Down
0