Preparing GCC Build: Difference between revisions

m
Replace deprecated enclose attributes
[unchecked revision][unchecked revision]
m (Fixed the link to macports)
m (Replace deprecated enclose attributes)
 
(16 intermediate revisions by 13 users not shown)
Line 3:
<noinclude>'''Note that this article is meant to be included into the [[GCC Cross-Compiler]] and [[Building GCC]] as they share this common section.'''</noinclude>
 
The GNU Compiler Collection is an advanced piece of software with dependencies. You need the following the following in order to build GCC:
 
* A Unix-like environment (Windows users can use the Windows Subsystem for Linux or Cygwin)
Line 17:
* Texinfo
* ISL (optional)
* CLooG (optional)
 
=== Installing Dependencies ===
Line 30 ⟶ 29:
| Cygwin
| OpenBSD
| Arch
|-
|How to install
Line 38:
|Cygwin GUI setup
|'''<tt>doas pkg_add</tt> ''foo'''''
|'''<tt>libcloogpacman -isl-devSyu</tt> ''foo'''''
|-
|Compiler
Line 46 ⟶ 47:
|'''<tt>mingw64-x86_64-gcc-g++</tt>''' / '''<tt>mingw64-i686-gcc-g++</tt>'''
|Preinstalled
|'''<tt>libcloog-islbase-devel</tt>'''
|-
|Make
|N/A
|'''<tt>build-essential</tt>'''
|'''<tt>sysdev-develbuild/make</tt>'''
|'''<tt>make</tt>'''
|'''<tt>make</tt>'''
|Preinstalled
|'''<tt>devbase--libs/cloogdevel</tt>'''
|-
|[https://www.gnu.org/software/bison/ Bison]
Line 62 ⟶ 65:
|'''<tt>bison</tt>'''
|?
|'''<tt>base-devel</tt>'''
|-
|[https://github.com/westes/flex Flex]
Line 70 ⟶ 74:
|'''<tt>flex</tt>'''
|?
|'''<tt>base-devel</tt>'''
|-
|[https://gmplib.org/ GMP]
Line 77 ⟶ 82:
|'''<tt>gmp-devel</tt>'''
|'''<tt>libgmp-devel</tt>'''
|'''<tt>gmp</tt>'''
|'''<tt>gmp</tt>'''
|-
Line 85 ⟶ 91:
|'''<tt>libmpc-devel</tt>'''
|'''<tt>libmpc-devel</tt>'''
|'''<tt>libmpc</tt>'''
|'''<tt>libmpc</tt>'''
|-
Line 93 ⟶ 100:
|'''<tt>mpfr-devel</tt>'''
|'''<tt>libmpfr-devel</tt>'''
|'''<tt>mpfr</tt>'''
|'''<tt>mpfr</tt>'''
|-
Line 102 ⟶ 110:
|'''<tt>texinfo</tt>'''
|'''<tt>texinfo</tt>'''
|'''<tt>base-devel</tt>'''
|-
|[https://www.cloog.org/ CLooG] (Optional)
|[https://www.cloog.org/ CLooG]
|'''<tt>libcloog-isl-dev</tt>'''
|'''<tt>dev--libs/cloog</tt>'''
|?
|'''<tt>libcloog-isl-devel</tt>'''
|N/A
|-
|[http://isl.gforge.inria.fr/ ISL] (Optional)
Line 115 ⟶ 116:
|'''<tt>libisl-dev</tt>'''
|'''<tt>dev-libs/isl</tt>'''
|'''<tt>isl-devel</tt>'''
|?
|'''<tt>libisl-devel</tt>'''
|N/A
|N/A
|}
 
You need to have Texinfo installed to build Binutils. You need to have GMP, MPC, and MPFR installed to build GCC. GCC optionally can make use of the CLooG and ISL librarieslibrary.
 
For instance, you can install '''<tt>libgmp3-dev</tt>''' on Debian by running the shell command: '''<tt>sudo apt install libgmp3-dev</tt>'''
Line 126 ⟶ 128:
'''Note:''' Version 5.x (or later) of Texinfo is known to be incompatible with the current Binutils 2.23.2 release (and older). You can check your current version using <tt>makeinfo --version</tt>. If your version is too new and you encounter problems during the build, you will need to either use Binutils 2.24 release (or newer) or install an older version of Texinfo - perhaps through building from source - and add it to your <tt>PATH</tt> prior and during the Binutils build.
 
'''Note:''' GCC has dropped support for CLooG in the 5.x releases [https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=r5-2770-geae1a5d419d30e], and many distributions have dropped the CLooG package (e.g. Gentoo in December 2022).
'''Note:''' Version 0.13 (or later) of ISL is incompatible with the current CLooG 0.18.1 release (and older). Use version 0.12.2 of ISL or the build '''will''' fail.
 
'''Note:''' GCC requires at least ISL version 0.15.
 
'''Note:''' If you are using '''Cygwin''', it is recommended to install the <tt>'''libintl-devel'''</tt> package (I couldn't build a cross-compiler without this package)
 
=== Downloading the Source Code ===
Line 164 ⟶ 170:
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 <sourcesyntaxhighlight lang="make" enclose="none"inline>$(CC)</sourcesyntaxhighlight> variable to invoke the compiler. On OS X, this resolves to <sourcesyntaxhighlight lang="text" enclose="none"inline>gcc</sourcesyntaxhighlight> by default, which is actually <sourcesyntaxhighlight lang="bash" enclose="none"inline>clang</sourcesyntaxhighlight>. Prior to OS X 10.8, the Clang that came with Xcode's Command Line Tools package was not able to build a working GCC. Users running OS X 10.7 or below may need to find and install GCC, either from [httphttps://brew.sh Homebrew], or from somewhere on Apple's website. You can try with the old GCC that comes preinstalled on some macOS versions.
 
<sourcesyntaxhighlight lang="bash">
# This is only necessary for OS X users running 10.7 or below.
export CC=/usr/bin/gcc-4.2
Line 172 ⟶ 178:
export CPP=/usr/bin/cpp-4.2
export LD=/usr/bin/gcc-4.2
</syntaxhighlight>
</source>
 
You will want to unset these exports once you compiled and installed the cross compiler.
 
'''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 [httphttps://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.
Install GMP, MPFR, Mpc with [httphttps://www.macports.org/ MacPorts].
 
sudo port install gmp mpfr libmpc
Line 196 ⟶ 202:
 
'''Note:''' There is an issue with port's GMP, so the version from OS X from /usr is used instead.
'''Note2:''' If you still have some errors, try making a case-sensitive APFS disk image using disk utility app and build from there
 
=== Windows Users ===
Line 209 ⟶ 216:
 
'''Windows Subsystem for Linux (Beta) Note:''' You cannot have your cross compiler in the /mnt/c/ (or /mnt/"x") areas, as trying to compile your cross-compiler there will generate errors, whereas building to $HOME/opt/cross works perfectly. This is fixed with Windows Update KB3176929
 
=== OpenBSD Users ===
OpenBSD users might need to install "gcc" package from ports because base system's GCC is very outdated. If you want to build GCC, try to use the ports' version instead of the latest version available and apply all patches from ports to your build. Also, if the build fails during compiling lto-plugin, a temporary solution is to disable LTO altogether during configure stage of building GCC by adding <tt>--disable-lto</tt>
 
[[Category:Compilers]]