安装目标: 从源码生成gcc 4.3.2(最新版本)编译器 ( x86 / SPARC的步骤相同!) 原版的安装文档地址: http://gcc.gnu.org/install/index.html
硬件要求: Sun x86的工作站一台 (CPU单核主频越高越好!) 软件准备: Solaris 10 update 6 引用:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq Select the Solaris software to install on the system.
NOTE: After selecting a software group, you can add or remove software by customizing it. However, this requires understanding of software dependencies and how Solaris software is packaged.
[color=Red][X] [/color] Entire Distribution plus OEM support ....... 6974.00 MB [ ] Entire Distribution ........................ 6929.00 MB [ ] Developer System Support ................... 6729.00 MB [ ] End User System Support .................... 5640.00 MB [ ] Core System Support ........................ 1405.00 MB qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
需要下载的软件有: gcc-4.3.2.tar.gz ftp://ftp.gnu.org/gnu/gcc/gcc-4.3.2/gcc-4.3.2.tar.gz binutils-2.18.tar.gz ftp://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.gz mpfr-2.3.2.tar.gz http://www.mpfr.org/mpfr-current/mpfr-2.3.2.tar.gz gmp-4.2.1.tar.bz2 ftp://ftp.gnu.org/gnu/gmp/gmp-4.2.1.tar.gz
废话不说了,整点关键的~~~, [size=6]安装编译过程:[/size]
环境准备: 最关键是root的环境变量: # vi $HOME.profile [color=Blue]PATH=/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin:/usr/ucb LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/sfw/lib export PATH LD_LIBRARY_PATH alias ll="df -hFufs" alias m="gmake && gmake install" PS1="\u@\H# "[/color] #注意: 把/usr/local的path和LD_LIBRARY_PATH提前到/usr/sfw/lib下面,因为solaris自带的一些命令不是gnu的,在编译过程中可能会报错,ld/ar等命令都需要额外安装!下面的步骤会有叙述!
编译binutils-2.18 cd /tmp; gtar zxvf binutils-2.18.tar.gz cd binutils-2.18 ./configure && m
cd /tmp; gtar zxvf gcc-4.3.2.tar.gz cd /tmp/ && bzcat zxvf gmp-4.2.1.tar.bz2 && mv gmp-4.2.1 gmp && gtar xvf - && ./configure && m cd /tmp/ && gtar zxvf mpfr-2.3.2.tar.gz && mv mpfr-2.3.2 mpfr && ./configure -with-gmp-build=/tmp/gmp && m
cd /tmp/gcc-4.3.2 && bzcat zxvf gmp-4.2.1.tar.bz2 && gtar xvf - && mv gmp-4.2.1 gmp cd /tmp/gcc-4.3.2 && gtar zxvf mpfr-2.3.2.tar.gz && mv mpfr-2.3.2 mpfr
开始编译gcc了 cd /tmp/gcc-4.3.2 ./configure --prefix=/tmp/gcc --enable-languages=c,c++ --with-gnu-as --with-as=/usr/local/bin/as --with-gnu-ld --with-ld=/usr/local/bin/ld LD=/usr/local/bin/ld AS=/usr/local/bin/as AR=/usr/local/bin/ar NM=/usr/local/bin/nm RANLIB=/usr/local/bin/ranlib STRIP=/usr/local/bin/strip OBJCOPY=/usr/local/bin/objcopy OBJDUMP=/usr/local/bin/objdump m #这步需要70分钟完成,我的主机是双核2.4G CPU,仅供参考!
上述步骤大家感觉写的很少,但是我尽可能地把步骤精简地写!
安装总结: gmp/mpfr/binutils等软件强烈建议使用最新的!我在编译的过程中,曾经尝试使用solaris自带的gnu软件,但是编译根本就无法通过。
gmp/mpfr软件需要解压到gcc source code的home目录下面。这样在gcc编译的过程中,它可以自动提取其中的一些头文件。
gmp/mpfr的编译采用默认的配置,直接./configure,不要加任何参数!除非你有特殊要求。我加了一个-m64的参数,大家可以不用这个参数的。
编译的过程中,大家可以发现我的source code全部放在tmp目录下,一个目的:是编译过程中,更快一点!当然你需要确认你的/tmp可用空间不少于2GB。
如果编译的过程中,出现失败,那么我建议重新解压gcc gzip文件!
下帖附原版gcc的安装准备文档
[ 本帖最后由 nimysun 于 2008-12-1 12:41 编辑 ]
nimysun 回复于:2008-12-01 11:38:54
[size=6]Prerequisites for GCC[/size] GCC requires that various tools and packages be available for use in the build procedure. Modifying GCC sources requires additional tools described below. Tools/packages necessary for building GCC
ISO C90 compiler Necessary to bootstrap GCC, although versions of GCC prior to 3.4 also allow bootstrapping with a traditional (K&R) C compiler.
To build all languages in a cross-compiler or other configuration where 3-stage bootstrap is not performed, you need to start with an existing GCC binary (version 2.95 or later) because source code for language frontends other than C might use GCC extensions. GNAT In order to build the Ada compiler (GNAT) you must already have GNAT installed because portions of the Ada frontend are written in Ada (with GNAT extensions.) Refer to the Ada installation instructions for more specific information. A “working” POSIX compatible shell, or GNU bash Necessary when running configure because some /bin/sh shells have bugs and may crash when configuring the target libraries. In other cases, /bin/sh or ksh have disastrous corner-case performance problems. This can cause target configure runs to literally take days to complete in some cases.
So on some platforms /bin/ksh is sufficient, on others it isn't. See the host/target specific instructions for your platform, or use bash to be sure. Then set CONFIG_SHELL in your environment to your “good” shell prior to running configure/make.
zsh is not a fully compliant POSIX shell and will not work when configuring GCC. A POSIX or SVR4 awk Necessary for creating some of the generated source files for GCC. If in doubt, use a recent GNU awk version, as some of the older ones are broken. GNU awk version 3.1.5 is known to work. GNU binutils Necessary in some circumstances, optional in others. See the host/target specific instructions for your platform for the exact requirements. gzip version 1.2.4 (or later) or bzip2 version 1.0.2 (or later) Necessary to uncompress GCC tar files when source code is obtained via FTP mirror sites. GNU make version 3.80 (or later) You must have GNU make installed to build GCC. GNU tar version 1.14 (or later) Necessary (only on some platforms) to untar the source code. Many systems' tar programs will also work, only try GNU tar if you have problems. GNU Multiple Precision Library (GMP) version 4.1 (or later) Necessary to build GCC. If you do not have it installed 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. Alternatively, if a GMP source distribution is found in a subdirectory of your GCC sources named gmp, it will be built together with GCC. MPFR Library version 2.3.2 (or later) Necessary to build GCC. It can be downloaded from http://www.mpfr.org/. The version of MPFR that is bundled with GMP 4.1.x contains numerous bugs. Although GCC may appear to function with the buggy versions of MPFR, there are a few bugs that will not be fixed when using this version. It is strongly recommended to upgrade to the recommended version of MPFR.
The --with-mpfr configure option should be used if your MPFR Library is not installed in your default library search path. See also --with-mpfr-lib and --with-mpfr-include. Alternatively, if a MPFR source distribution is found in a subdirectory of your GCC sources named mpfr, it will be built together with GCC. jar, or InfoZIP (zip and unzip) Necessary to build libgcj, the GCJ runtime.
[color=Red]下面的部分大家可以不考虑![/color] Tools/packages necessary for modifying GCC
autoconf version 2.59 GNU m4 version 1.4 (or later) Necessary when modifying configure.ac, aclocal.m4, etc. to regenerate configure and config.in files. automake version 1.9.6 Necessary when modifying a Makefile.am file to regenerate its associated Makefile.in.
Much of GCC does not use automake, so directly edit the Makefile.in file. Specifically this applies to the gcc, intl, libcpp, libiberty, libobjc directories as well as any of their subdirectories.
For directories that use automake, GCC requires the latest release in the 1.9.x series, which is currently 1.9.6. When regenerating a directory to a newer version, please update all the directories using an older 1.9.x to the latest released version. gettext version 0.14.5 (or later) Needed to regenerate gcc.pot. gperf version 2.7.2 (or later) Necessary when modifying gperf input files, e.g. gcc/cp/cfns.gperf to regenerate its associated header file, e.g. gcc/cp/cfns.h. DejaGnu 1.4.4 Expect Tcl Necessary to run the GCC testsuite; see the section on testing for details. autogen version 5.5.4 (or later) and guile version 1.4.1 (or later) Necessary to regenerate fixinc/fixincl.x from fixinc/inclhack.def and fixinc/*.tpl.
Necessary to run `make check' for fixinc.
Necessary to regenerate the top level Makefile.in file from Makefile.tpl and Makefile.def. Flex version 2.5.4 (or later) Necessary when modifying *.l files.
Necessary to build GCC during development because the generated output files are not included in the SVN repository. They are included in releases. Texinfo version 4.7 (or later) Necessary for running makeinfo when modifying *.texi files to test your changes.
Necessary for running make dvi or make pdf to create printable documentation in DVI or PDF format. Texinfo version 4.8 or later is required for make pdf.
Necessary to build GCC documentation during development because the generated output files are not included in the SVN repository. They are included in releases. TeX (any working version) Necessary for running texi2dvi and texi2pdf, which are used when running make dvi or make pdf to create DVI or PDF files, respectively. SVN (any version) SSH (any version) Necessary to access the SVN repository. Public releases and weekly snapshots of the development sources are also available via FTP. Perl version 5.6.1 (or later) Necessary when regenerating Makefile dependencies in libiberty. Necessary when regenerating libiberty/functions.texi. Necessary when generating manpages from Texinfo manuals. Necessary when targetting Darwin, building libstdc++, and not using --disable-symvers. Used by various scripts to generate some files included in SVN (mainly Unicode-related and rarely changing) from source tables. GNU diffutils version 2.7 (or later) Useful when submitting patches for the GCC source code. patch version 2.5.4 (or later) Necessary when applying patches, created with diff, to one's own sources. ecj1 gjavah If you wish to modify .java files in libjava, you will need to configure with --enable-java-maintainer-mode, and you will need to have executables named ecj1 and gjavah in your path. The ecj1 executable should run the Eclipse Java compiler via the GCC-specific entry point. You can download a suitable jar from ftp://sourceware.org/pub/java/, or by running the script contrib/download_ecj. antlr.jar version 2.7.1 (or later) antlr binary If you wish to build the gjdoc binary in libjava, you will need to have a antlr.jar library available. The library is searched in system locations but can be configured with --with-antlr-jar= instead. When configuring with --enable-java-maintainer-mode, you will need to have one of the executables named cantlr, runantlr or antlr in your path. |