title: Building a cross compile of binutils on OS X Yosemite
body: <p>I'm trying to build binutils for generating MIPS code on Mac OS X. </p>
  
  <p>I found this site (<a href="http://www.theairportwiki.com/index.php/Building_a_cross_compile_of_GCC_for_MIPS_on_OS_X" rel="nofollow noreferrer">http://www.theairportwiki.com/index.php/Building_a_cross_compile_of_GCC_for_MIPS_on_OS_X</a>) from <a href="https://stackoverflow.com/questions/22776307/how-to-build-gcc-4-8-x-on-mac-os-x-host-for-mips-target">How to build GCC 4.8.x on Mac OS X host for MIPS target</a>, and followed the instructions. </p>
  
  <p>I install the gcc-4.8 from brew, and installed source code of binutils and gcc. This is the compilation option setup.  </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/gcc-mips
  $ export CFLAGS=-Wno-error=deprecated-declarations
  </code></pre>
  
  <p>Then I configure, and make the bintuils. </p>
  
  <p>The issue is that after building static libraries I have an error message that archive is not built for <code>x86_64</code>, and then I have a bunch of undefined symbol error. </p>
  
  <pre><code>ignoring file ./../intl/libintl.a, file was built for archive which is not the architecture being linked (x86_64): ./../intl/libintl.a
  
  Undefined symbols for architecture x86_64:
    "__bfd_abort", referenced from:
        _fix_new_internal in write.o
        _size_seg in write.o
  </code></pre>
  
  <p>Googling to find that I need to setup AR (archive) variable also from <a href="https://github.com/tpoechtrager/osxcross/issues/11" rel="nofollow noreferrer">https://github.com/tpoechtrager/osxcross/issues/11</a>. I added <code>export AR=/usr/local/bin/gcc-ar-4.8</code>, but I have another error message because gcc-ar-4.8 doesn't work. </p>
  
  <pre><code>/usr/local/bin/gcc-ar-4.8 
  /usr/local/bin/gcc-ar-4.8: Cannot find plugin 'liblto_plugin.so'
  </code></pre>
  
  <p>Googling again to find that gcc-ar doesn't work with Mac OS X (<a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56893" rel="nofollow noreferrer">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56893</a>). </p>
  
  <pre><code>gcc-ar is for use with newer GNU binutils only as that is the only ar which supports plugins.  
  Apple's ar does not support plugins (though it could be made to; it will be a different plugin interface than the GNU BFD 
  plugin interface which GCC supports right now).
  </code></pre>
  
  <p>I just created a dumb 'liblto_plugin.so' file in <code>/usr/local/Cellar/gcc48/4.8.4/libexec/gcc/x86_64-apple-darwin14.3.0/4.8.4</code> directory to suppress the error message, but in this case it looks like that <code>/usr/ar</code> is invoked when I use <code>/usr/bin/gcc-ar-4.8</code> to get the same architecture and undefined symbols error. </p>
  
  <p>How to solve these issues? How to build cross compiler tools (gcc and binutils) on Mac OS X? </p>