Skip to content
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

py shim: xcrun must bring all original args #522

Merged
merged 1 commit into from
May 6, 2020
Merged

Conversation

ferdonline
Copy link
Member

@ferdonline ferdonline commented May 6, 2020

The problem

nrnivmodl fails in new MAC OS

 -> Compiling mod_func.c
xcrun -O2   -I. -I..   -I/Users/joao/Library/Python/3.7/lib/python/site-packages/neuron/.data/include  -I/usr/local/Cellar/open-mpi/4.0.3/include -fPIC -c mod_func.c -o mod_func.o
xcrun: error: unrecognized option: -O2
Usage: xcrun [options] <tool name> ... arguments ...
[...]

The error is due to the way MAC shipped python was compiled:

>>> from distutils.sysconfig import get_config_var
>>> print (get_config_var('CC'))
xcrun -sdk macosx clang  -arch x86_64

>>> from distutils.ccompiler import new_compiler
>>> from distutils.sysconfig import customize_compiler
>>> ccompiler = new_compiler()
>>> customize_compiler(ccompiler)
>>> print("CC: ", ccompiler.compiler[0])
CC: xcrun

Investigating, distutils takes the first text from get_config_var to look for the executable and, in case it exists, assumes that's the compiler and it's good to use

However, xcrun is a shim which has a mandatory argument: clang. Without it xcrun doesn't compile anything

This PR

This seems a pretty nasty bug which, according to some local experimentation, will even prevent extensions from being compiled. Before Apple or Python.org make a fix, we patch for this specific case. However it can potentially happen with other wrappers that require args.

The quick fix check if the "detected compiler" is xcrun. If that's the case then one sets the compiler to the original CC/CXX config var.

NOTE: this is a bug of distutils which only takes the text
of the config_var("CC").
For the moment we patch for xcrun which is a common case in newer OSX
but it can potentially happen with other wrappers that require args.
Truth being said, xcrun is nuts as requires specifying optional arguments
@ferdonline ferdonline requested a review from pramodk May 6, 2020 17:35
@nrnhines nrnhines merged commit d45cc45 into master May 6, 2020
@pramodk pramodk added this to the Release v8.0 milestone May 6, 2020
@alexsavulescu alexsavulescu deleted the fix/shim_xcrun branch December 11, 2020 15:23
olupton pushed a commit that referenced this pull request Dec 7, 2022
* Modified vexp test to have tigheter tolerance (4ULP) on wider range of inputs
* fixed typo double-->float
* Fix clang-format with v11.0
* fixed test normalization for small numbers, made cancellation trick robust
* added short explanation of why reordering cannot happen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants