title: How to make ARM cross compilation on Mac OS X (error: invalid listing option `r' - cross compiling error)
body: <p>I'm trying to build a gcc cross compiler on Mac OS X, the target is <code>arm-elf-eabi</code>.</p>
  
  <p>This is what I've done so far:</p>
  
  <h3>Install gcc and environmental setup</h3>
  
  <p>I tried not to use clang/llvm from Mac, so I used the gcc-4.8 from brew.</p>
  
  <pre><code>brew tap homebrew/versions 
  brew install gcc48
  brew install binutils
  </code></pre>
  
  <p>Before the building, I set the environment variables:</p>
  
  <pre><code>export CC=/usr/local/bin/gcc-4.8
  export CXX=/usr/local/bin/g++-4.8
  export CPP=/usr/local/bin/cpp-4.8
  export LD=/usr/local/bin/gcc-4.8
  export PREFIX=/opt/cross
  export TARGET=arm-elf-eabi
  </code></pre>
  
  <h3>build binutils</h3>
  
  <p>Downloading a binutils source, then creating a build directory, and could build binutils without an issue:</p>
  
  <pre><code>mkdir build-binutils
  cd build-binutils
  ../binutils-2.24/configure --target=$TARGET --prefix=$PREFIX --with-sysroot --enable-64-bit-bfd --disable-shared --disable-werror --disable-nls
  make configure-host
  make LDFLAGS="-all-static"
  sudo make install
  </code></pre>
  
  <h3>building gcc</h3>
  
  <p>Downloading gcc 4.8 source, and run the build process</p>
  
  <pre><code>mkdir build-gcc
  cd build-gcc
  ../gcc-4.8.3/configure --target=$TARGET --prefix=$PREFIX --disable-nls --enable-languages=c,c++ --without-headers --disable-shared --enable-multilib --with-sysroot --disable-werror
  make configure-host
  make all-gcc &lt;&lt; ERROR
  make all-target-libgcc
  </code></pre>
  
  <p>However, I got <code>invalid listing option</code>r'` error in building. </p>
  
  <pre><code>/usr/local/bin/g++-4.8 -c   -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../../gcc-4.8.3/gcc -I../../gcc-4.8.3/gcc/build -I../../gcc-4.8.3/gcc/../include  -I../../gcc-4.8.3/gcc/../libcpp/include  \
          -o build/genconstants.o ../../gcc-4.8.3/gcc/genconstants.c
  Assembler messages:
  Fatal error: invalid listing option `r'
  make[2]: *** [build/genconstants.o] Error 1
  make[1]: *** [all-gcc] Error 2
  </code></pre>
  
  <h3>Alternative building process</h3>
  
  <p>I tried to use default compiler from Mac with the following configuration:</p>
  
  <pre><code>./contrib/download_prerequisites
  CFLAGS="-arch i386 -arch x86_64 -Wno-error=deprecated-declarations -Wno-error=unused-variable -Wno-error=unused-function" ../gcc-4.8.3/configure --target=$TARGET --prefix=$PREFIX --disable-nls --enable-languages=c --without-headers --disable-shared --enable-multilib
  </code></pre>
  
  <p>Then, it works fine with <code>make all-gcc</code>, but I also have different error with <code>make all-target-libgcc</code>, so I'll stick to gcc approach instead of clang/llvm approach. </p>
  
  <p>My guess is that the assembler <code>as</code> from Apple has something wrong with parameters that gcc gives (because there's nothing wrong with clang/llvm). </p>
  
  <p>What might be wrong? How to solve this issue?</p>