osx - gcc 4.8 on MacOS fails depending on -arch order

06
2014-06
  • Andrew Jaffe

    I am trying to get a recent version of gcc 4.8.2 up on my machine. I have tried installs that come from MacPorts as well as the one that gets installed alongside the binary install of gfortran.

    For a minimal source file, I get errors depending on the order of the -arch flags.

    Specifically, -arch x86_64 -arch i386 (or either of them alone) works:

    % /opt/local/bin/gcc-mp-4.8 -arch x86_64 -arch i386 conftest.c
    % /opt/local/bin/gcc-mp-4.8 -arch x86_64 -arch i386 -O3 conftest.c
    

    But -arch i386 -arch x86_64 fails:

    % /opt/local/bin/gcc-mp-4.8 -arch i386 -arch x86_64 conftest.c
    /var/folders/6l/7gzvw1zs42sbhj7_hlrpykfm0000gv/T//cc6JCBdP.s:5:bad register name `%rbp'
    /var/folders/6l/7gzvw1zs42sbhj7_hlrpykfm0000gv/T//cc6JCBdP.s:7:bad register name `%rsp'
    /var/folders/6l/7gzvw1zs42sbhj7_hlrpykfm0000gv/T//cc6JCBdP.s:10:bad register name `%rbp'
    
    % /opt/local/bin/gcc-mp-4.8 -arch i386 -arch x86_64 -O3 conftest.c
    /var/folders/6l/7gzvw1zs42sbhj7_hlrpykfm0000gv/T//ccs67E0q.s:34:FATAL:Bad fx_size (0x8) in fix_to_relocation_info()
    

    Help!

    The minimal source:

     int main ()
     {
      return 0;
     }
    

    For info:

    % /opt/local/bin/gcc-mp-4.8 --version
    gcc-mp-4.8 (MacPorts gcc48 4.8.2_0+universal) 4.8.2
    Copyright (C) 2013 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    How to install GCC on Windows7
  • There is nothing we can do

    I've downloaded GCC 4.5.1 and do not now what to do next. I've found inside the Install directory instructions how to configure, build and install but still cannot do much with this. May someone step by step write down how am I suppose to go through this process? For example, they saying something like this:

        % mkdir objdir 
        % cd objdir 
        % srcdir/configure [options] [target]   
    

    and I do understand that first line asks to create an directory and second asks to go into this but what about third one and how am I suppose to execute this? Am I suppose to go to source directory and type configure + options + target?


  • Related Answers
  • Shiki

    You don't install gcc like this. You use "Cygwin" or "MSYS" for this purpose (compiling). Cygwin is like a.... linux-windows combination? One should read the documentation. In a nutshell: You get a bash, gcc and other stuff, but it is SLOW.

    MSYS is much better on the other hand. It provides a win32 binary of gcc and all the development tools. http://www.mingw.org/wiki/MSYS

    If you just want to develop, you should choose a package like this:
    http://www.codeblocks.org/downloads/26
    codeblocks-10.05mingw-setup.exe << This one.

  • rubenvb

    GCC for Windows is provided by two projects currently. They both provide a very own implementation of the Windows SDK (headers and libraries) which is necessary because GCC does not work with Visual Studio files.

    1. The older mingw.org, which @Mat already pointed you to. They provide only a 32-bit compiler, and the latest version is GCC 4.5 as of the time of this writing. See here for the downloads you need:

      • Binutils is the linker and resource compiler etc.
      • GCC is the compiler, and is split in core and language packages
      • GDB is the debugger.
      • runtime library is required only for mingw.org
      • You might need to download mingw32-make seperately.
      • For support, you can try (don't expect friendly replies) [email protected]
    2. The newer mingw-w64, which as the name predicts, also provides a 64-bit variant. I use it and build toolchains with their CRT. Personal and auto builds are found under "Toolchains targetting Win32/64" here. They also provide Linux to Windows cross-compilers. I suggest you try a personal build first, they are more complete. Try mine (rubenvb) for GCC 4.6, or use sezero's for GCC 4.4 and 4.5. Both of us provide 32-bit and 64-bit native toolchains. These packages include everything listed above. For support, send an email to [email protected] or the forum via sourceforge.net.

    Both projects have their files listed on sourceforge, and all you have to do is either run the installer (in case of mingw.org) or download a suitable zipped package and extract it (in the case of mingw-w64).

    There are a lot of "non-official" toolchain builders, one of the most popular is TDM-GCC. They may use patches that break binary compatibility with official/unpatched toolchains, so be careful using them. It's best to use the official releases (or in the case of mingw-w64, the Personal builds are easier to get started with).

    Re the other answer: Cygwin/MSYS != gcc. Using GCC does not require the other. Plain users shouldn't be coimpiling GCC. That process is waaay to involved and time-consuming. Enough binary distributions floating around...