Mar 12 2014

Bypassing “clang: error: unknown argument”

Note: I originally wrote the blog post while installing mitmproxy on OS X Mavericks, but it is relevant to the “unknown argument” error in general, so keep reading.

Having a Mac laptop is like going on a journey every single day… My latest issue happened today while trying to install mitmproxy. Python’s pip was exiting with the following error:

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

Well, it turns out that the latest (5.1) version of Xcode ships with a compiler that treats unknown passed parameters as errors. From the changelog:

The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified.

Projects using invalid compiler options will need to be changed to remove those options. To help ease that transition, the compiler will temporarily accept an option to downgrade the error to a warning:

-Wno-error=unused-command-line-argument-hard-error-in-future

Note: This option will not be supported in the future.

To workaround this issue, set the ARCHFLAGS environment variable to downgrade the error to a warning. For example, you can install a Python native extension with:

$ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future easy_install ExtensionName

Similarly, you can install a Ruby Gem with:

$ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName 16214764 updated

So, basically you can install mitmproxy (or any other program with a similar error) by:

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install mitmproxy

Bear in mind that you if you need to combine the above with sudo, you will need to add it at the beginning of the command and not before “pip”. Otherwise you can also run the above logged in as root user from the start.

22 comments

6 pings

Skip to comment form

    • Deadman44 on March 15, 2014 at 4:33 PM
    • Reply

    Thank your very much. I had the same issue with (ruby) gem installing sqlite3.

      • Ion on March 17, 2014 at 1:25 PM
      • Reply

      Glad that it helped you! Yeap, Python & Ruby are both affected.

  1. Thanks a lot! I successfully (gem) installed Breakpoint for Sass with this snippet.

      • Ion on March 17, 2014 at 1:24 PM
      • Reply

      Great! It seems like a common error these days. Blame Apple 🙂

    • Burak on March 25, 2014 at 7:46 AM
    • Reply

    Great. Thank you for the solution. Solved my nightmare.

    • Sam on March 29, 2014 at 1:31 PM
    • Reply

    Fixed the problem I was having with installing the alpha release of compass, many thanks!

  2. super useful. fixed my problem for ‘gem install rmagick’. cheers!

    1. Hi Dominick, glad it worked!

  3. Awesome! Solved my issues with ‘pip install mitmproxy’ – many thanks for the post 🙂

    1. Hello Daniel, this was initially what I was trying to install as well 🙂

    • John on April 2, 2014 at 4:32 PM
    • Reply

    Excellent and thank you… worked for ‘gem install nokogiri’

    • tweisbach on April 7, 2014 at 2:21 PM
    • Reply

    You can use sudo the following way: sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install mitmproxy

      • Ugs on May 19, 2014 at 5:02 PM
      • Reply

      You can also append:

      Defaults env_keep += “ARCHFLAGS”

      to the list env env_keep additions to make sure ARCHFLAGS is maintained by sudo, and then add:

      export ARCHFLAGS=’-Wno-error=unused-command-line-argument-hard-error-in-future’

      to your ~/.bashrc to hide all this craziness

        • Ugs on May 19, 2014 at 5:04 PM

        sorry, append Defaults env_keep += “ARCHFLAGS” in /etc/sudoers

    • Srinivas HN on April 14, 2014 at 1:45 PM
    • Reply

    it solved my mavericks issues
    Thanks lot

  4. Thank you! Problems installing a gem on Mavericks here.

    • AA on April 22, 2014 at 8:48 AM
    • Reply

    your solution is the only one that worked

    • QS on July 8, 2014 at 5:15 PM
    • Reply

    I judge you for spelling “bear” as “bare”, but I appreciate your assistance.

    1. Hah, thanks QS.

    • Ethan Eldridge on August 28, 2014 at 6:46 PM
    • Reply

    Extremely useful! Thanks so much, pycrypto was giving this error on a clients computer

    • MacTommy on January 26, 2015 at 11:59 AM
    • Reply

    Many thanks! This helped 😉

  5. that didnt work on El capitain, aka EL SHIT!, but for anyone that made the mistake i did by not waiting 3 years until after it came out, if u r using homebrew with python, do brew reinstall python –from-src, and make a little change on tweisbach,s helpful piece of info and use sudo -H instead of just sudo on the front of ARCHFLAGS.. was pulling my hair out until i remembered the -H is the key when sudo wont work.

  1. […] Security Bloggers Network, Ion, […]

  2. […] Bare in mind that you’ll probably get the “clang: error: unknown argument” failure message but fear not, a I have written the solution here if you need it: http://bruteforcelab.com/bypassing-clang-error-unknown-argument.html […]

  3. […] Bypassing “clang: error: unknown argument” – BruteForce Lab’s Blog Note: I originally wrote the blog post while installing mitmproxy on OS X Maverics, but it is relevant to the “unknown argument” error in general, so keep reading. Having a Mac laptop is like going on a journey every single day… My latest issue happened today while trying to install mitmproxy. […]

  4. […] After lots of research on web and googling, I found many people had faced this issue after updating the Xcode  to 5.1 or above mine is 6.1 You can find your Xcode version using pkgutil –pkg-info=com.apple.pkg.CLTools_Executables […]

Leave a Reply

More in General News
Using KeePass on Mac OS X
Make apt-get use IPv4 instead of IPv6
BlackHat USA 2012 – Owning Bad Guys (and Mafia) with Javascript Botnets
Christiaan008: The Honey project and CIC News Engine
Disable mod_security with htaccess
Close