Disable -enable-default-pie for gcc
Mia Lopez
I need to disable the -enable-default-pie option in the configuration of gcc, but I don't know how to do it. Is there a text file where I simply have to delete that option or how should this be done?
1 Answer
If you need a different configuration for the GCC, you need to recompile it.
Download GCC
Download or clone the GCC from the official website. As alternative, you can also install it from the Ubuntu source packages.
# Download gcc
$ wget
$ tar xf gcc-7.3.0.tar.xz
$ cd gcc-7.3.0
# Clone gcc
$ git clone
$ cd gcc; git checkout gcc-7_3_0-release
# Use Ubuntu sources
$ apt-get source gcc-7
$ cd gcc-7-7.3.0Configure GCC
Enter the GCC source folder and run the autoconf script configure. Before that, all development libraries for gcc need to be installed. Most common case configure only requires the languages c and c++ (see also this page). This is also the place, where you should put the custom option --enable-default-pie.
$ sudo apt-get build-dep gcc-7
$ configure --enable-languages=c,c++Build and Install
Simple start make and make install. This will build and install the custom gcc in /usr/local/bin. If you need a different location, you can change that with the --prefix=... option in the configuration step.
$ make -j $(grep -c processor /proc/cpuinfo)
$ sudo make install
# Or better with checkinstall which, creates a deb packet
$ sudo checkinstall make install Depending on the amount of CPUs you have, this can take a while. After that, just run gcc --version and watch the new compiler in action.