xgboost: While installing on OSX Sierra via gcc-6, keep having "FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!" error

Environment info

Operating System: macOS 10.12.2 (16C68)

Compiler: gcc-6

Steps to reproduce

I’ve installed gcc-6 and modified config.mk as required into

export CC = gcc-6
export CXX = g++-6

But keep having this error:

g++-6 -c -std=c++0x -Wall -Wno-unknown-pragmas -Iinclude   -Idmlc-core/include -Irabit/include -O3 -funroll-loops -msse2 -fPIC -fopenmp src/learner.cc -o build/learner.o
FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!

What have you tried?

  1. Reinstall XCode
  2. Reinstall gcc
  3. Run make clean_all && make -4j

But still went wrong. Any idea?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16

Most upvoted comments

@Marswang92 @jialinzou @mcneale What about the version of as? You can check it by as -v. Maybe your terminal display something like GNU Assembler.

And I think the correct as is like:

Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1as -triple x86_64-apple-macosx10.11.0 -filetype obj -main-file-name - -target-cpu core2 -fdebug-compilation-dir /Users/fcbruce -dwarf-debug-producer Apple LLVM version 8.0.0 (clang-800.0.38) -dwarf-version=2 -mrelocation-model pic -o a.out -
^C

The reason is the system use a different path of as(be overrided). Please attention the error log you met /opt/local/bin/../libexec/as/x86_64/as, the correct as should be /usr/bin/as. You can check it by cd /usr/bin ; ./as -v.

My solution is export PATH=/usr/bin:$PATH. I helped my friend resolve the problem. And I think that can help you.

I found that MacPorts was putting /opt/local/bin ahead of /usr/bin in the $PATH chain via these lines in .profile:

[hash] MacPorts Installer addition on 2018-03-01_at_16:21:35: adding an appropriate PATH variable for use with MacPorts. export PATH=“/opt/local/bin:/opt/local/sbin:$PATH” [hash] Finished adapting your PATH environment variable for use with MacPorts.

So “as” was being found in /opt/local/bin/…/libexec/as/x86_64/as before the preferred (working) version in /usr/bin

Took these lines out of .profile and restarted terminal. My test file hello world.f is now compiling

Late coming to the party… but…

The following worked for me. This solution is independent of system path gyrations.

$ cd /opt/local/bin $ sudo mv ./as ./as-broken $ sudo ln -s /usr/bin/as ./as

Here’s a test that shows that it works:

$ mkdir ~/gcctest $ cd ~/gcctest $ echo ‘int main(){return -1;}’ > conftest.c $ /opt/local/bin/gcc -o conftest conftest.c FATAL:/opt/local/bin/…/libexec/as/x86_64/as: I don’t understand ‘m’ flag! $ cd /opt/local/bin $ sudo mv ./as ./as-broken $ sudo ln -s /usr/bin/as ./as $ cd - $ /opt/local/bin/gcc -o conftest conftest.c $ ./conftest; echo $? 255

Hooray! solution seems to be to remove /opt/local/bin from one’s path. @fcbruce thank you!

How you do this depends on your shell, @fcbruce assumes sh or bash I think. Under tcsh setenv PATH /usr/local/bin for example, might do the trick.