@@ -4,6 +4,9 @@ How to Build GCC from Source
44Step 1: Install Dependancies
55----------------------------
66
7+ The percise command to install dependencies will vary between operating systems.
8+ On Fedora, for example:
9+
710.. code-block :: console
811
912 sudo dnf install gcc-c++ \
@@ -30,6 +33,12 @@ edit to the source directory, you will have to recompile the object files.
3033
3134 mkdir -p ~/bld/trunk && mkdir ~/src/
3235
36+ .. note ::
37+
38+ The src directory should take up about 3.1GB, and the build directory should
39+ take about 2.5GB
40+
41+
3342Step 2a: Clone Git Repo into Source Directory
3443^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3544
@@ -49,7 +58,7 @@ Then you will want to checkout branch ``trunk`` or ``master``
4958 .. note ::
5059
5160 If your git username and email are not the same as the one you use to
52- contribute to GCC (i.e. work email) , it's helpful to set it to the correct
61+ contribute to GCC, it's helpful to set it to the correct
5362 information inside the git directory.
5463
5564 .. code-block :: console
@@ -65,7 +74,7 @@ Step 2b: Set up Build Directory Configuration
6574^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6675
6776GCC has a script called ``configure `` inside the source directory at
68- ``~/gcc/configure ``. Calling by itself will enable every option by default.
77+ ``~/gcc/configure ``. Calling by itself will enable every default option .
6978If you want a different configuration you will have to use option flags to
7079change the configuration settings. For example, I mostly work on front end C and
7180C++ stuff, so my configuration would look like this:
@@ -77,7 +86,14 @@ C++ stuff, so my configuration would look like this:
7786 --disable-libvtv --disable-libcilkrts --disable-libitm --disable-libgomp \
7887 --disable-libcc1 --disable-libstdcxx-pch --disable-libssp --disable-isl \
7988 --disable-libmpx --disable-libsanitizer --disable-libquadmath \
80- --disable-libatomic
89+ --disable-libatomic --enable-valgrind-annotations
90+
91+ .. note ::
92+
93+ Setting a ``--prefix `` for where the built gcc should be installed to, a
94+ sibling directory of the build directory, is useful because then it can be
95+ installed without needing sudo
96+
8197
8298You can find the configuration options `here `_.
8399
@@ -115,7 +131,8 @@ From inside the build directory ``~/bld/trunk/gcc``, we will run the command:
115131 The ``-quiet `` option makes it so the compiler doesn't print out annoying
116132messages to console when compiling. The ``-Iinclude `` option lets you
117133compile code that contains ``#include ``'s when using
118- either ``cc1 `` or ``cc1plus ``.
134+ either ``cc1 `` or ``cc1plus ``. An alternative to this would be to invoke
135+ ``./xgcc `` or ``./xg++ ``.
119136
120137Step 4 (Optional): Set up Older Versions of GCC
121138-----------------------------------------------
@@ -127,7 +144,8 @@ this version. What I like to do is have working directories for ``trunk``,
127144``gcc-9 ``, ``gcc-8 ``, and ``gcc-7 ``.
128145
129146To set these directories up, all you have to do is copy your working ``trunk ``
130- source directory into a seperate one and check out ``gcc-7/8/9-branch ``
131- inside those directories. Then follow the steps above to configure the build
132- directory, but changing the path of the script to fit the correct version. For
133- example: ``~/src/gcc9/configure `` instead of ``~/src/gcc/configure ``.
147+ source directory into a seperate one and check out ``gcc-7-branch ``
148+ , ``gcc-8-branch ``, and ``gcc-9-branch `` inside those directories. Then follow
149+ the steps above to configure the build directory, but changing the path of the
150+ script to fit the correct version. For example: ``~/src/gcc9/configure ``
151+ instead of ``~/src/gcc/configure ``.
0 commit comments