Index of /software/gcc/releases/gcc-7.4.0下找到了源码，下载下来
We use srcdir to refer to the toplevel source directory for GCC; we use objdir to refer to the toplevel build/object directory.
First, we highly recommend that GCC be built into a separate directory from the sources which does not reside within the source tree. This is how we generally build GCC; building where srcdir == objdir should still work, but doesn’t get extensive testing; building where objdir is a subdirectory of srcdir is unsupported.
To configure GCC:
>% mkdir objdir >% cd objdir >% srcdir/configure [options] [target]
cd /public/fgn/software/gcc/install-package tar -xvf gcc-7.4.0.tar.gz cd /public/fgn/software/gcc/7.4 mkdir install /public/fgn/software/gcc/install-package/gcc-7.4.0/configure --prefix=`pwd`/install
checking for the correct version of gmp.h... no configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+. Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify their locations. Source code for these libraries can be found at their respective hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/. See also http://gcc.gnu.org/install/prerequisites.html for additional info. If you obtained GMP, MPFR and/or MPC from a vendor distribution package, make sure that you have installed both the libraries and the header files. They may be located in separate packages.
Several support libraries are necessary to build GCC, some are required, others optional. While any sufficiently new version of required tools usually work, library requirements are generally stricter. Newer versions may work in some cases, but it’s safer to use the exact versions documented. We appreciate bug reports about problems with newer versions, though. If your OS vendor provides packages for the support libraries then using those packages may be the simplest way to install the libraries.
GNU Multiple Precision Library (GMP) version 4.3.2 (or later)
Necessary to build GCC. If a GMP source distribution is found in a subdirectory of your GCC sources named gmp, it will be built together with GCC. Alternatively, if GMP is already installed but it is not in your library search path, you will have to configure with the –with-gmp configure option. See also –with-gmp-lib and –with-gmp-include. The in-tree build is only supported with the GMP version that download_prerequisites installs.
MPFR Library version 2.4.2 (or later)
Necessary to build GCC. It can be downloaded from https://www.mpfr.org. If an MPFR source distribution is found in a subdirectory of your GCC sources named mpfr, it will be built together with GCC. Alternatively, if MPFR is already installed but it is not in your default library search path, the –with-mpfr configure option should be used. See also –with-mpfr-lib and –with-mpfr-include. The in-tree build is only supported with the MPFR version that download_prerequisites installs.
MPC Library version 0.8.1 (or later)
Necessary to build GCC. It can be downloaded from http://www.multiprecision.org/mpc/. If an MPC source distribution is found in a subdirectory of your GCC sources named mpc, it will be built together with GCC. Alternatively, if MPC is already installed but it is not in your default library search path, the –with-mpc configure option should be used. See also –with-mpc-lib and –with-mpc-include. The in-tree build is only supported with the MPC version that download_prerequisites installs.
isl Library version 0.15 or later.
Necessary to build GCC with the Graphite loop optimizations. It can be downloaded from ftp://gcc.gnu.org/pub/gcc/infrastructure/. If an isl source distribution is found in a subdirectory of your GCC sources named isl, it will be built together with GCC. Alternatively, the –with-isl configure option should be used if isl is not installed in your default library search path.
Necessary to build GCC with zstd compression used for LTO bytecode. The library is searched in your default library patch search. Alternatively, the –with-zstd configure option should be used.
cd /public/fgn/software/gcc/install-package/gcc-7.4.0 mkdir gmp cd gmp wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 tar -xvf gmp-6.1.0.tar.bz2 mv gmp-6.1.0/* ./ && rm -r gmp-6.1.0 # 对于mpfr、mpc、isl同理 cd /public/fgn/software/gcc/7.4 /public/fgn/software/gcc/install-package/gcc-7.4.0/configure --prefix=`pwd`/install
g++ -std=gnu++98 -c -g -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedant ic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common -DHAVE_CONFIG_H -DGENERATOR_FILE -fno-PIE -I. -Ibuild -I/public/fgn/software/gcc/install-package/gcc-7.4.0/gcc -I/public/fgn/software/gc c/install-package/gcc-7.4.0/gcc/build -I/public/fgn/software/gcc/install-package/gcc-7.4.0/gcc/../include -I/public/fgn/software/gcc/install-package/gcc-7.4.0/gcc/../libcpp/include \ -o build/genmddeps.o /public/fgn/software/gcc/install-package/gcc-7.4.0/gcc/genmddeps.c In file included from ./bconfig.h:3:0, from /public/fgn/software/gcc/install-package/gcc-7.4.0/gcc/genmddeps.c:18: ./auto-host.h:2363:16: error: declaration does not declare anything [-fpermissive] #define rlim_t long ^
configure: error: I suspect your system does not have 32-bit development libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.
/public/fgn/software/gcc/install-package/gcc-7.4.0/configure --prefix=`pwd`/install --disable-multilib
make -j make install
---------------------------------------------------------------------- Libraries have been installed in: /public/fgn/software/gcc/7.4/install/lib/../lib64 If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ----------------------------------------------------------------------
#%Module 1.0 set DIR /public/fgn/software/gcc/7.4/install prepend-path PATH $DIR/bin prepend-path CPATH $DIR/install prepend-path LD_LIBRARY_PATH $DIR/lib64 prepend-path LIBRARY_PATH $DIR/lib64 prepend-path MANPATH $DIR/share/man