Skip to content

Instantly share code, notes, and snippets.

@imweijh
Created March 26, 2025 13:14
Show Gist options
  • Save imweijh/13025f6c020878e455be1e7ebc1583fb to your computer and use it in GitHub Desktop.
Save imweijh/13025f6c020878e455be1e7ebc1583fb to your computer and use it in GitHub Desktop.
Your new compiler will be at ~/gcc10/bin/gcc
sudo apt install -y curl build-essential libgmp-dev libmpfr-dev libmpc-dev
mkdir /tmp/$$ && cd /tmp/$$
curl -s https://ftp.gnu.org/gnu/gcc/gcc-10.3.0/gcc-10.3.0.tar.xz | tar xJ
mkdir build && cd build
../gcc-10.3.0/configure --prefix=$HOME/gcc10 \
--disable-dependency-tracking \
--disable-nls \
--disable-multilib \
--enable-default-pie \
--enable-languages=c,c++
make -j$(nproc)
make install
@imweijh
Copy link
Author

imweijh commented Mar 26, 2025

https://gcc.gnu.org/wiki/FAQ#configure

GCC tends to have problems when configured in the same directory as the GCC source code, or in any subdirectory therein

So put your objdir up a level:

$ git clone ... gcc
$ mkdir objdir
$ cd objdir
$ ../gcc/configure ...

If you're just building a native compiler, you don't need --host. It will figure that out on its own. Just pick an install prefix, --prefix=, which is where your compiler will go when you make install. You don't need it installed in the system. Just put it somewhere your user has write permissions, then add that to your PATH.

@imweijh
Copy link
Author

imweijh commented Mar 26, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment