Skip to content

Commit

Permalink
Use -O1 when compiling internal C-Blosc sources. Fixes #110.
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescAlted committed Apr 6, 2016
1 parent 20968fe commit c757812
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
5 changes: 4 additions & 1 deletion RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
Changes from 1.3.0 to 1.3.1
===========================

- Added a protection to avoid using BITSHUFLE with C-Blosc < 1.8.0.
- Use the -O1 flag for compiling the included C-Blosc sources. This
represents slower performance, but fixes the nasty issue #110. Also,
it prints a warning for using an external C-Blosc library.

- Added a protection to avoid using BITSHUFLE with C-Blosc < 1.8.0.

- Restored old symbols for backward compatibility with pre 1.3.0:
BLOSC_VERSION_STRING
Expand Down
31 changes: 22 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

# flake8: noqa

from __future__ import print_function

import os
import platform
import re
Expand Down Expand Up @@ -78,8 +80,13 @@ def exit_with_error(message):
inc_dirs += [os.path.join(BLOSC_DIR, 'include')]
libs += ['blosc']
else:
# Compiling everything from sources
# Blosc + BloscLZ sources
# Compiling everything from included C-Blosc sources
print("*******************************************************\n"
"**Warning:** Compiling with included C-Blosc sources. \n"
"For performance reasons, consider to use the --blosc \n"
"flag for passing an external C-Blosc library location. \n"
"*******************************************************\n")
# Warn about the convenience to use the shared library
# We still have to figure out how to detect AVX2 in Python,
# so no AVX2 support for the time being
sources += [f for f in glob.glob('c-blosc/blosc/*.c') if 'avx2' not in f]
Expand All @@ -94,19 +101,25 @@ def exit_with_error(message):
inc_dirs += glob.glob('c-blosc/internal-complibs/*')
# ...and the macros for all the compressors supported
def_macros += [('HAVE_LZ4', 1), ('HAVE_SNAPPY', 1), ('HAVE_ZLIB', 1)]
if os.name == 'nt':

if platform.system() == "Linux":
# Compiling with more than -O2 can cause segfaults; see:
# https://github.com/Blosc/python-blosc/issues/110
CFLAGS.append('-O1')

if os.name == 'posix':
if re.match("i.86", platform.machine()) is not None:
# Add -msse2 flag for optimizing shuffle in Blosc
# (only necessary for 32-bit Intel architectures)
CFLAGS.append("-msse2")
elif os.name == 'nt':
# Windows always should have support for SSE2
# (present in all x86/amd64 architectures since 2003)
def_macros += [('__SSE2__', 1)]

if os.name == 'posix':
if re.match("i.86|x86", platform.machine()) is not None:
# Always enable SSE2 for AMD/Intel machines
CFLAGS.append('-DSHUFFLE_SSE2_ENABLED')
if re.match("i.86", platform.machine()) is not None:
# Add -msse2 flag for optimizing shuffle in Blosc
# (only necessary for 32-bit Intel architectures)
CFLAGS.append("-msse2")
def_macros += [('SHUFFLE_SSE2_ENABLED', 1)]

classifiers = """\
Development Status :: 5 - Production/Stable
Expand Down

0 comments on commit c757812

Please sign in to comment.