Last active
May 6, 2024 18:18
-
-
Save jeetsukumaran/5224956 to your computer and use it in GitHub Desktop.
Build and Install GCC Suite from Scratch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
GCC_VERSION="5.2.0" | |
WORKDIR="$HOME/src/" | |
INSTALLDIR="/platform" | |
## NOTE: XCode must be installed (through App Store) and the following run to install command-line tools. | |
## THIS IS IMPORTANT! Among other things, it creates '/usr/include' and installs the system header files. | |
# xcode-select --install | |
# get the source code | |
cd $WORKDIR | |
wget http://www.netgull.com/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2 | |
tar -xf gcc-${GCC_VERSION}.tar.bz2 | |
# download the prerequisites | |
cd gcc-${GCC_VERSION} | |
./contrib/download_prerequisites | |
# create the build directory | |
cd .. | |
mkdir gcc-build | |
cd gcc-build | |
# build | |
../gcc-${GCC_VERSION}/configure \ | |
--prefix=${INSTALLDIR} \ | |
--enable-shared \ | |
--enable-threads=posix \ | |
--enable-__cxa_atexit \ | |
--enable-clocale=gnu \ | |
--enable-languages=all \ | |
&& make \ | |
&& make install | |
# Notes | |
# | |
# --enable-shared --enable-threads=posix --enable-__cxa_atexit: | |
# These parameters are required to build the C++ libraries to published standards. | |
# | |
# --enable-clocale=gnu: | |
# This parameter is a failsafe for incomplete locale data. | |
# | |
# --disable-multilib: | |
# This parameter ensures that files are created for the specific | |
# architecture of your computer. | |
# This will disable building 32-bit support on 64-bit systems where the | |
# 32 bit version of libc is not installed and you do not want to go | |
# through the trouble of building it. Diagnosis: "Compiler build fails | |
# with fatal error: gnu/stubs-32.h: No such file or directory" | |
# | |
# --with-system-zlib: | |
# Uses the system zlib instead of the bundled one. zlib is used for | |
# compressing and uncompressing GCC's intermediate language in LTO (Link | |
# Time Optimization) object files. | |
# | |
# --enable-languages=all | |
# --enable-languages=c,c++,fortran,go,objc,obj-c++: | |
# This command identifies which languages to build. You may modify this | |
# command to remove undesired language |
They use .tar.gz
now instead of .tar.bz2
#! /bin/bash
GCC_VERSION="9.3.0"
WORKDIR="$HOME/src/"
INSTALLDIR="/platform"
## NOTE: XCode must be installed (through App Store) and the following run to install command-line tools.
## THIS IS IMPORTANT! Among other things, it creates '/usr/include' and installs the system header files.
# xcode-select --install
# get the source code
cd $WORKDIR
wget http://www.netgull.com/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz
tar -xvf gcc-${GCC_VERSION}.tar.gz
# download the prerequisites
cd gcc-${GCC_VERSION}
./contrib/download_prerequisites
# create the build directory
cd ..
mkdir gcc-build
cd gcc-build
# build
../gcc-${GCC_VERSION}/configure \
--prefix=${INSTALLDIR} \
--enable-shared \
--enable-threads=posix \
--enable-__cxa_atexit \
--enable-clocale=gnu \
--enable-languages=all \
--disable-multilib \
&& make
#&& make install
# Notes
#
# --enable-shared --enable-threads=posix --enable-__cxa_atexit:
# These parameters are required to build the C++ libraries to published standards.
#
# --enable-clocale=gnu:
# This parameter is a failsafe for incomplete locale data.
#
# --disable-multilib:
# This parameter ensures that files are created for the specific
# architecture of your computer.
# This will disable building 32-bit support on 64-bit systems where the
# 32 bit version of libc is not installed and you do not want to go
# through the trouble of building it. Diagnosis: "Compiler build fails
# with fatal error: gnu/stubs-32.h: No such file or directory"
#
# --with-system-zlib:
# Uses the system zlib instead of the bundled one. zlib is used for
# compressing and uncompressing GCC's intermediate language in LTO (Link
# Time Optimization) object files.
#
# --enable-languages=all
# --enable-languages=c,c++,fortran,go,objc,obj-c++:
# This command identifies which languages to build. You may modify this
# command to remove undesired language
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I followed the steps. However, I am stuck with an error related to -no-pie not being supported by the old g++ I was using to build this new one. Please help.
The configure command I used to build gcc 8.2:
Details of my system and g++: