From 1b6e5850c016a63d0cbdc5e30d6858b0c2b8bcc9 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Thu, 3 Nov 2022 12:20:03 -0400 Subject: [PATCH] Patch compilation options for Python. --- src/mlpack/bindings/python/setup.py.in | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/mlpack/bindings/python/setup.py.in b/src/mlpack/bindings/python/setup.py.in index aabd85a6fb..8cac63b458 100644 --- a/src/mlpack/bindings/python/setup.py.in +++ b/src/mlpack/bindings/python/setup.py.in @@ -49,16 +49,29 @@ else: extra_cxx_flags = re.sub(' +', ' ', cxx_flags) cxx_flags += ' ' cxx_flags += extra_cxx_flags - extra_args = ['-DBINDING_TYPE=BINDING_TYPE_PYX', '-std=c++14'] + + extra_args = [] + if platform.system() == 'Windows': + # Argument specification is different on MSVC, and also use C++17. + extra_args.extend(['/DBINDING_TYPE=BINDING_TYPE_PYX', '/std:c++17', '/MD', + '/O2', '/Ob2', '/DNDEBUG']) + elif platform.system() == 'Darwin': + extra_args.append('-DBINDING_TYPE=BINDING_TYPE_PYX') + extra_args.append('-std=c++17') + # On OS X and Linux, we try to reduce the size of the generated libraries + # by removing debugging symbols and stripping. + extra_args.append('-g0') + else: + extra_args.append('-DBINDING_TYPE=BINDING_TYPE_PYX') + extra_args.append('-std=c++17') + extra_args.append('-g0') + extra_link_args.append('-Wl,--strip-all') + if '${OpenMP_CXX_FLAGS}' != '': extra_args.append('${OpenMP_CXX_FLAGS}') if cxx_flags: extra_args.extend(cxx_flags.split(' ')) - # Extra options for MSVC compiler. - if platform.system() == 'Windows': - extra_args.extend(['/MD', '/O2', '/Ob2', '/DNDEBUG']) - # This is used for parallel builds; CMake will set PYX_TO_BUILD accordingly. if module is not None: modules=[\