This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: OSX C++ linking workaround in distutils breaks other packages
Type: behavior Stage: resolved
Components: Distutils, macOS Versions: Python 3.6
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: cheryl.sabella, dstufft, eric.araujo, esuarezsantana, ned.deily, r.david.murray, ronaldoussoren
Priority: normal Keywords:

Created on 2017-12-21 17:22 by esuarezsantana, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4965 closed esuarezsantana, 2017-12-21 17:22
Messages (6)
msg308887 - (view) Author: Eduardo Suarez-Santana (esuarezsantana) * Date: 2017-12-21 17:22
When compiling GDAL with python support, under certain build chain environment variables, next error may appear when building and linking python extensions (

/bin/sh: -d: invalid option

See the Github PR for proposed solution.
msg308889 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-12-21 17:31
Please describe the problem and your proposed solution in more detail and in terms of CPython, so that it can be discussed by the relevant experts.  GDAL is a third party product and only relevant as an example, so it would also be good to come up with a better title for the issues ;)
msg308891 - (view) Author: Eduardo Suarez-Santana (esuarezsantana) * Date: 2017-12-21 17:45
When compiling GDAL with python support, before Lib/distutils/,

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 workaround 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:

/bin/sh: -d: invalid option

Some fixes to compilation ( have been found, but anyway the existing workaround:

1. 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.

My proposal is to remove the workaround and delegate right environmental variables to packagers.
msg308892 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-12-21 17:48
I doubt we can make the change this way for backward compatibility reasons.  That doesn't mean the situation can't be improved, though.
msg308991 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2017-12-24 09:55
As I mentioned on the pull request it is not clear to me what the actual issue is.

What are the settings for building that cause problems?  In particular, what are the compiler/linker related variables in Python's Makefile (and

With the currently available information I'm -1 w.r.t accepting the attached pull request.
msg369676 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2020-05-23 00:32
I'm going to close this as the OP hasn't responded in over 2 years and Ronald was -1 on the solution.  If the OP or someone else experiences this same problem, either this issue or a new one can be opened to address it.  Thank you!
Date User Action Args
2022-04-11 14:58:55adminsetgithub: 76579
2020-05-23 00:32:10cheryl.sabellasetstatus: open -> closed

nosy: + cheryl.sabella
messages: + msg369676

resolution: out of date
stage: resolved
2017-12-24 09:55:21ronaldoussorensetmessages: + msg308991
2017-12-21 17:48:19r.david.murraysetnosy: + ned.deily, ronaldoussoren
messages: + msg308892
components: + macOS
2017-12-21 17:45:02esuarezsantanasetmessages: + msg308891
2017-12-21 17:39:32esuarezsantanasettitle: GDAL compilation error -> OSX C++ linking workaround in distutils breaks other packages
2017-12-21 17:31:13r.david.murraysetnosy: + r.david.murray
messages: + msg308889
2017-12-21 17:22:59esuarezsantanacreate