Preparing GCC Build: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Line 69: Line 69:


=== Mac OS X Users ===
=== Mac OS X Users ===
Additionally, Mac OS X users need a replacement libiconv because the system libiconv is seriously out of date. Mac OS X users can download the latest libiconv release by visiting the [https://gnu.org/software/libiconv/ libiconv website] or directly accessing the [ftp://ftp.gnu.org/gnu/libiconv/ GNU main ftp mirror].
Additionally, Mac OS X users need a replacement libiconv because the system libiconv is seriously out of date. Mac OS X users can download the latest libiconv release by visiting the [https://gnu.org/software/libiconv/ libiconv website] or directly accessing the [ftp://ftp.gnu.org/gnu/libiconv/ GNU main FTP mirror].


When compiling GCC 4.3 or higher on OS X 10.4 and 10.5, you may get unresolved symbol errors related to libiconv. This is because the version shipped with OS X is seriously out of date. Install a new version (compile it yourself or use macports) and add <tt>--with-libiconv-prefix=/opt/local</tt> (or <tt>/usr/local</tt> if you compiled it yourself) to GCC's <tt>./configure</tt> line. Alternatively you may place the libiconv source as gcc-x.y.z/libiconv and it will be compiled as part of the GCC compilation process. (This trick also works for mpfr, gmp, and mpc).
When compiling GCC 4.3 or higher on OS X 10.4 and 10.5, you may get unresolved symbol errors related to libiconv. This is because the version shipped with OS X is seriously out of date. Install a new version (compile it yourself or use MacPorts) and add <tt>--with-libiconv-prefix=/opt/local</tt> (or <tt>/usr/local</tt> if you compiled it yourself) to GCC's <tt>./configure</tt> line. Alternatively you may place the libiconv source as gcc-x.y.z/libiconv and it will be compiled as part of the GCC compilation process. (This trick also works for MPFR, GMP, and Mpc).


The makefiles of binutils and GCC use the <source lang="make" enclose="none">$(CC)</source> variable to invoke the compiler. On OS X, this resolves to <source lang="text" enclose="none">gcc</source> by default, which is actually not the "real thing", but <source lang="bash" enclose="none">clang</source>. Note that since at least OS X 10.8, Xcode's Command Line Tools package comes with clang, and this version of clang does indeed work to compile a working version of GCC, unlike what these instructions previously reflected.
The makefiles of Binutils and GCC use the <source lang="make" enclose="none">$(CC)</source> variable to invoke the compiler. On OS X, this resolves to <source lang="text" enclose="none">GCC</source> by default, which is actually not the "real thing", but <source lang="bash" enclose="none">Clang</source>. Note that since at least OS X 10.8, Xcode's Command Line Tools package comes with Clang, and this version of Clang does indeed work to compile a working version of GCC, unlike what these instructions previously reflected.


Note that users running OS X 10.7 may need to find and install gcc, either from [http://brew.sh homebrew], or from somewhere on Apple's website.
Note that users running OS X 10.7 may need to find and install GCC, either from [http://brew.sh homebrew], or from somewhere on Apple's website.
Thus, the instructions below are really only relevant for these users, but your mileage may vary.
Thus, the instructions below are really only relevant for these users, but your mileage may vary.
<source lang="bash">
<source lang="bash">
Line 87: Line 87:
You might want to unset these exports once you compiled and installed the cross compiler, as it might confuse other builds. '''Do not''' make these permanent!
You might want to unset these exports once you compiled and installed the cross compiler, as it might confuse other builds. '''Do not''' make these permanent!


'''Note for Lion users:''' If you're on Lion (or above) chances are that you don't have the "real" gcc since Apple removed it from the Xcode package, but you can still install it. You can do it via Homebrew or by compiling from source, both are perfectly described on [http://apple.stackexchange.com/a/38247 a StackExchange answer].
'''Note for Lion users:''' If you're on Lion (or above) chances are that you don't have the "real" GCC since Apple removed it from the Xcode package, but you can still install it. You can do it via Homebrew or by compiling from source, both are perfectly described on [http://apple.stackexchange.com/a/38247 a StackExchange answer].


'''Note for Maverick users:''' You can build binutils-2.24 and gcc-4.8.3 (possible other version) with xcode 5.1.1. Note that building gcc with llvm is not officially supported and may cause interesting bugs, if you are willing to take this risk and save time building host-gcc just to compile a cross-gcc, follow this.
'''Note for Maverick users:''' You can build binutils-2.24 and gcc-4.8.3 (possible other version) with Xcode 5.1.1. Note that building GCC with LLVM is not officially supported and may cause interesting bugs, if you are willing to take this risk and save time building host-gcc just to compile a cross-gcc, follow this.
Install GMP, MPFR, MPC with [http://http://www.macports.org/ macport].
Install GMP, MPFR, Mpc with [http://http://www.macports.org/ MacPorts].
sudo port install gmp mpfr libmpc
sudo port install gmp mpfr libmpc


Line 105: Line 105:
--with-gmp=/usr --with-mpc=/opt/local --with-mpfr=/opt/local
--with-gmp=/usr --with-mpc=/opt/local --with-mpfr=/opt/local


*Note that there is issue with port's gmp, we use the version from mac os x from /usr instead.
*Note that there is issue with port's GMP, we use the version from Mac OS X from /usr instead.


=== Windows Users ===
=== Windows Users ===