Compile gcc for Solaris 10 on x86 platform

Buzz sentence for me these days “How to compile gcc on Solaris10 for x86 platform”. There are a lot of problems and missing links exists in the latest source code available for gcc. Use following steps to get gcc compiled successfully on S10 for x86.
1) Download the gcc source code using any tool available to you, for example in my case i used svn to download the aource tree of gcc.
svn checkout http://gcc.gnu.org/svn/gcc/trunk gcc
This will create a gcc directory with all source files init.
2) Download latest binutils from http://ftp.gnu.org/gnu/binutils/ to compile loader and other tools.
3) Optional thing is to create a seprate directory by linking all the source files for running gmake.
4) Now first compile binutil directory using following command
./configure –prefix= –with-gmp= –with-mpfr=

** Here –with-gmp and –with-mpfr paths need to set before running configure command. So if you do not have gmp and mprf library then first download and compile them.
The GNU MP Bignum Library
The MPFR Library

then
./gmake
./gmake install
5) Now go in gcc soource dir
./configure –prefix= –with-gmp-include= –with-gmp-lib= -with-mpfr-include= –with-mpfr-lib= –disable-nls
–disable-multilib –with-gnu-ld –with-gnu-as
./gmake -j 8
./gmake install

now you are done .

BUT it is not that easy … these are some troubles i faced and fixed. Have an look …

1) Following changes are required for lib/gen-classlist.sh

abs_top_builddir=`cd “${top_builddir}”; pwd`
> abs_top_srcdir=`cd “/net/dv1.india/vol/wsvol/ws1/sg160228/OPENAIS/gcc/libjava/classpath”; pwd`
> if test “$abs_top_builddir” != “$abs_top_srcdir”; then

if test -f ${top_builddir}/lib/classes.2; then

2) Following changes are required for classpath/lib/Makefile

< if ! [ -e gnu ]; then mkdir gnu; fi
< if ! [ -e gnu/java ]; then mkdir gnu/java; fi
< if ! [ -e gnu/java/locale ]; then mkdir gnu/java/locale; fi
if test ! -d gnu; then mkdir gnu; fi
> if test ! -d gnu/java; then mkdir gnu/java; fi
> if test ! -d gnu/java/locale; then mkdir gnu/java/locale; fi

> if test ! -d gnu/javax/swing/plaf/gtk/icons; then mkdir -p gnu/javax/swing/plaf/gtk/icons; fi

if test ! -d $$p; then mkdir $$p; fi; \

3) Following changes are required for libjava/scripts/jar

if test -f “$2″/”$1”; then

elif test -f “$1”; then

mkdir_p_fun () {

mkdir_p=’mkdir_p_fun’
+
4) Following changes are required for /gcc/gcc/Makefile

< STRICT2_WARN = -pedantic -Wno-long-long -Wno-variadic-macros \
STRICT2_WARN = -pedantic -Wno-long-long \
> -Wold-style-definition -Wmissing-format-attribute \

< echo 'SYSTEM_HEADER_DIR="'"$(SYSTEM_HEADER_DIR)"'"'
$(DESTDIR)$(itoolsdatadir)/mkheaders.conf

> echo ‘SYSTEM_HEADER_DIR=”$(SYSTEM_HEADER_DIR)”‘ > $(DESTDIR)$(itoolsdatadir)/mkheaders.conf

5) There could the case when gcc loader could not load some directories then we need to copy that particular .so file in $BuildDir/$BuildDir/lib/ . For this i think there is some bug with binutils loader that is why it could not load same library from /usr/bin or /lib/. So need to go for above work around.

6) Set following environmental param if required :
LD_LIBRARY_PATH , LD_RUN_PATH , CC , RPATH.

Advertisements
This entry was posted in Solaris/Linux and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s