0

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?

0

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 https://mirrors.kernel.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.xz
$ tar xf gcc-7.3.0.tar.xz
$ cd gcc-7.3.0

# Clone gcc
$ git clone https://gcc.gnu.org/git/gcc.git
$ cd gcc; git checkout gcc-7_3_0-release

# Use Ubuntu sources
$ apt-get source gcc-7
$ cd gcc-7-7.3.0

Configure 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.

  • 1
    Your method is for LFS or other source-based distro. What was wrong with getting source of GCC from repository with apt-get source gcc, sudo apt-get build-dep gcc and then configure it and then run sudo checkinstall make install? – N0rbert Sep 26 '18 at 18:50
  • Nothing, it is just a choice of gcc versions. If the gcc versions doesn’t fit your needs. – Simon Sudler Sep 27 '18 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.