I have recently become frustrated with the new clang compiler included with Xcode 5. I was wondering what the best way to install GNU GCC on OS X would be.
Things to consider:
- I don't want to use MacPorts, fink, homebrew or any other third party package manager.
- I would like to use the latest GCC, compiled from source, if possible.
- I need the existing GCC (hardlink to clang) to remain the default, but to easily be able to use GNU GCC when I need to.
- I would like to avoid modifying the code if at all possible.
EDIT: Success! Using GCC 4.9.2 (with GMP 5.1.3, MPFR 3.1.2, MPC 1.0.2, ISL 0.12.2, and CLooG 0.18.1) I succesfully built GCC. Tips to take from here:
- Make sure you use ISL and CLooG. Yes, they are optional, but they make a more optimised compiler and I had trouble building without them. Make sure you use ISL 0.12, not the latest version (0.14).
- If possible, use the standalone Developer Tools, not XCode. (XCode has some buggy headers, and while I didn't notice any issues building GCC I have had issues with other software (e.g. GPG)).
- I recommend putting all your sources in the gcc directory, rather than building and installing separately (it's faster this way)
- Make sure you invoke
CC=clang CXX=clang++so GCC knows it isn't being compiled by GCC.
- Definitely, definitely, definitely, invoke
-j8, or otherwise the build will take about 4 hours! (With
-j8, it took 1 1/3 hours on my Mid-2012 MBP with 8gb RAM.) (
makecan build 8 threads simultaneously (4 cores + HT), whereas on a 2-core machine you would run
Hope this helps!