From 8139f03981a1fea88e75239d6cd46f593128c788 Mon Sep 17 00:00:00 2001 From: Eduardo Suarez-Santana Date: Thu, 21 Dec 2017 16:58:33 +0000 Subject: [PATCH 1/2] Remove OSX c++ linking workaround in distutils. When compiling GDAL with python support, before the removed code we have ``` self.compiler_cxx = ['/bin/sh', '/usr/x86_64-pc-linux-gnu/bin/libtool', '--mode=compile', '--tag=CXX', 'x86_64-pc-linux-gnu-c++'] linker = ['x86_64-pc-linux-gnu-cc', '-pthread', '-shared', '-march=native', '-pipe', '-O2', '-Wall', '-Wdeclaration-after-statement', '-Wextra', '-Winit-self', '-Wunused-parameter', '-Wmissing-prototypes', '-Wmissing-declarations', '-Wformat', '-Werror=format-security', '-Wno-format-nonliteral', '-Wlogical-op', '-Wshadow', '-Werror=vla', '-Wdeclaration-after-statement', '-Wnull-dereference', '-Wduplicated-cond', '-DOGR_ENABLED', '-march=native', '-pipe', '-O2', '-I/var/tmp/paludis/build/sci-libs-gdal-2.1.1/work/gdal-2.1.1/port', '-DGDAL_COMPILATION'] ``` and after the removed code ``` linker = ['/bin/sh', '-pthread', '-shared', '-march=native', '-pipe', '-O2', '-Wall', '-Wdeclaration-after-statement', '-Wextra', '-Winit-self', '-Wunused-parameter', '-Wmissing-prototypes', '-Wmissing-declarations', '-Wformat', '-Werror=format-security', '-Wno-format-nonliteral', '-Wlogical-op', '-Wshadow', '-Werror=vla', '-Wdeclaration-after-statement', '-Wnull-dereference', '-Wduplicated-cond', '-DOGR_ENABLED', '-march=native', '-pipe', '-O2', '-I/var/tmp/paludis/build/sci-libs-gdal-2.1.1/work/gdal-2.1.1/port', '-DGDAL_COMPILATION'] ``` which leads to next [error](https://www.mail-archive.com/freebsd-ports@freebsd.org/msg41030.html): ``` /bin/sh: -d: invalid option ``` Some [workarounds](https://www.michael-joost.de/gdal_install.html) have been found, but anyway the code removed: 1. ...is a hack about OSX but there is no platform checking, 2. ...assumes linker and compiler commands have similar structure and environment settings (no documentation reference found about that), and 3. ...assumes `env`, if used, does not come with any modifier. --- Lib/distutils/unixccompiler.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py index ab4d4de1566198..0caea64d2977bd 100644 --- a/Lib/distutils/unixccompiler.py +++ b/Lib/distutils/unixccompiler.py @@ -177,18 +177,6 @@ def link(self, target_desc, objects, linker = self.linker_exe[:] else: linker = self.linker_so[:] - if target_lang == "c++" and self.compiler_cxx: - # skip over environment variable settings if /usr/bin/env - # is used to set up the linker's environment. - # This is needed on OSX. Note: this assumes that the - # normal and C++ compiler have the same environment - # settings. - i = 0 - if os.path.basename(linker[0]) == "env": - i = 1 - while '=' in linker[i]: - i += 1 - linker[i] = self.compiler_cxx[i] if sys.platform == 'darwin': linker = _osx_support.compiler_fixup(linker, ld_args) From 7bf6383316bd29f89e6a2a5fda6ddf8cc06bc0ed Mon Sep 17 00:00:00 2001 From: Eduardo Suarez-Santana Date: Thu, 21 Dec 2017 17:35:15 +0000 Subject: [PATCH 2/2] Fixed news for previous commit. --- .../Core and Builtins/2017-12-21-17-34-40.bpo-32398.XxESJr.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2017-12-21-17-34-40.bpo-32398.XxESJr.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-12-21-17-34-40.bpo-32398.XxESJr.rst b/Misc/NEWS.d/next/Core and Builtins/2017-12-21-17-34-40.bpo-32398.XxESJr.rst new file mode 100644 index 00000000000000..dd4b41d449b117 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2017-12-21-17-34-40.bpo-32398.XxESJr.rst @@ -0,0 +1 @@ +Remove ancient OSX C++ linking workaround in distutils.