clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

余生长醉 提交于 2019-11-28 20:47:33

It is due to a change in clang defaults in Xcode 5.1 and Apple not noticing that it would break extension module builds using the system Python. One workaround is to define the following environment variables first:

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

UPDATE [2014-05-16]: As expected, Apple has fixed this problem with updated system Pythons (2.7, 2.6, and 2.5) in OS X 10.9.3 so the workaround is no longer necessary when using the latest Mavericks and Xcode 5.1+. However, as of now, the workaround is still required for OS X 10.8.x (Mountain Lion, currently 10.8.5) if you are using Xcode 5.1+ there.

mircealungu

The latest version of clang raised to the level of error what used to be a warning. To switch back you can remove this behavior inline right before running your install command:

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install <your package>

This should work, but just in case something goes wrong, there is more info here: clang error: unknown argument: '-mno-fused-madd' (python package installation failure)

user3475890

Actually Ned's and Dorian's responses are linked:

  • Removing the -mno-fused-madd from the _sysconfigdata.py prevents the flags from being passed to the compiler.
  • Setting the environment variables tells the compiler to ignore the flags, but the flags are still being passed. This may break in a future release of Xcode.

I just spent DAYS fighting this problem in various packages and, as a Python newbie, couldn't figure out where the flags were coming from. Supplementing Dorian's answer, Xcode 5 supports only Apple's clang compiler and not GCC, but the Python distribution that comes with Mavericks appears to have been built with GCC. The _sysconfigdata.py file contains the flags that were used to build the Python interpreter, and those flags are used by the Python build system by various projects. Therefore any project using the Python build system uses flags that are not compatible with the installed compiler.

I installed python using Homebrew (which puts it into /usr/local/Cellar and used my apple-gcc42 installation also in /usr/local/Cellar) and found that the installed _sysconfigdata.py contains reasonable flags. However, it's still using GCC. You might want to just build Python from sources yourself using clang. I think editing the flags in _sysconfigdata.py is the best way to avoid stepping in this issue repeatedly.

Also remove _sysconfigdata.pyc and _sysconfigdata.pyo.

This is also covered in the following threads:

clang error: unknown argument: '-mno-fused-madd' (python package installation failure) https://discussions.apple.com/thread/5465305

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!