gccgo - another Google Go compiler - Part 1

Sunday, November 15, 2009

gccgo - another Google Go compiler - Part 1

This post is about how I am fixing things... for a HOWTO on gccgo, check gccgo mini-HOWTO

As I told during Google Go - A First Look, I am gonna try to build and install gccgo in Ubuntu 9.10 Karmic Koala... it is a compiler for Google Go... a frontend for gcc...

$ mkdir gccgo
$ sudo apt-get -y install subversion
$ svn checkout svn://gcc.gnu.org/svn/gcc/branches/gccgo gccgo

The total source size is 1.3 GB !!!

I have uploaded the tar.gz file... download from here... gccgo-4.5.0.tar.gz or from sourceforge... it is only 80 MB :)

Build process commencing...

$ mkdir objdir
$ cd objdir
$ ../gccgo/configure --enable-languages=c,c++,go

It showed error...

configure: error: Building GCC requires GMP 4.2+ and MPFR 2.3.2+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code 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 and/or MPFR 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.

I searched for the libraries and found this thread [Arbitrary precision in C with GMP and MPFR]...

$ sudo apt-get install libgmp3-dev
$ sudo apt-get install libmpfr-dev

After that configure was success...

$ make

Started checking for lots of things... started making... issued a warning...

WARNING: `flex' is missing on your system. You should only need it if you modified a `.l' file. You may need the `Flex' package in order for those modifications to take effect. You can get `Flex' from any GNU archive site.

After that... boom...

gcc: gengtype-lex.c: No such file or directory
gcc: no input files
make[3]: *** [build/gengtype-lex.o] Error 1
make[3]: Leaving directory `/more/go/objdir/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/more/go/objdir'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/more/go/objdir'
make: *** [all] Error 2

Installed flex...

$ sudo apt-get -y install flex

Tried make again... same error... ran configure again...

$ ../gccgo/configure --enable-languages=c,c++,go
$ make

Went to sleep, 3 and half hours... woke up... make still going... 2 more hours... and still going... 2 more hours... and it happened...

Comparing stages 2 and 3
warning: gcc/cc1plus-checksum.o differs
warning: gcc/cc1-checksum.o differs
Bootstrap comparison failure!
gcc/go/unsafe.o differs
gcc/go/gogo-tree.o differs
gcc/go/import.o differs
gcc/go/statements.o differs
gcc/go/types.o differs
gcc/go/lex.o differs
gcc/go/refcount.o differs
gcc/go/export.o differs
gcc/go/gogo.o differs
gcc/go/parse.o differs
gcc/go/go.o differs
gcc/go/import-elf.o differs
gcc/go/expressions.o differs
gcc/go/import-archive.o differs
gcc/go/dataflow.o differs
make[2]: *** [compare] Error 1
make[2]: Leaving directory `/more/go/objdir'
make[1]: *** [stage3-bubble] Error 2
make[1]: Leaving directory `/more/go/objdir'
make: *** [all] Error 2

I searched for the error and found this page [GCC Build error Bootstrap comparison failure!], it said make distclean and configure again will fix the issue... that is a total of seven and half hours wasted...

But, I tried distclean...

$ make distclean
$ ../gccgo/configure --enable-languages=c,c++,go
$ make

then another error...

sysinfo.c:18:24: fatal error: linux/user.h: No such file or directory
compilation terminated.
make[3]: *** [sysinfo.go] Error 1
make[3]: Leaving directory `/more/go/objdir/i686-pc-linux-gnu/libgo'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/more/go/objdir/i686-pc-linux-gnu/libgo'
make[1]: *** [all-target-libgo] Error 2
make[1]: Leaving directory `/more/go/objdir'
make: *** [all] Error 2

I tried configuring again from start... no use... searched for some solutions and came across this Korean page... [webnautes.tistory.com/]... Google translated it for me... it says about the issue and points to this Portuguese site... [http://www.fernando.scherrer.nom.br/?p=28]... again Google translate...

This was the solution given...

$ cd /usr/include/linux
$ sudo ln -s ../sys/user.h

... that will make a symbolic link to user.h inside linux directory.

Let's try it out... that error was gone... waiting for the next one...

../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:83:16: error: reference to undefined field or method ‘Cs’
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:85:16: error: reference to undefined field or method ‘Ss’
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:87:16: error: reference to undefined field or method ‘Ds’
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:89:16: error: reference to undefined field or method ‘Es’
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:91:16: error: reference to undefined field or method ‘Fs’
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:93:16: error: reference to undefined field or method ‘Gs’
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:121:4: error: reference to undefined field or method ‘Cs’
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:123:4: error: reference to undefined field or method ‘Ss’
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:125:4: error: reference to undefined field or method ‘Ds’
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:127:4: error: reference to undefined field or method ‘Es’
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:129:4: error: reference to undefined field or method ‘Fs’
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:131:4: error: reference to undefined field or method ‘Gs’
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:121:8: error: invalid left hand side of assignment
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:123:8: error: invalid left hand side of assignment
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:125:8: error: invalid left hand side of assignment
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:127:8: error: invalid left hand side of assignment
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:129:8: error: invalid left hand side of assignment
../../../gccgo/libgo/go/debug/proc/regs_linux_386.go:131:8: error: invalid left hand side of assignment
make[3]: *** [debug/libproc.a] Error 1
make[3]: Leaving directory `/more/go/objdir/i686-pc-linux-gnu/libgo'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/more/go/objdir/i686-pc-linux-gnu/libgo'
make[1]: *** [all-target-libgo] Error 2
make[1]: Leaving directory `/more/go/objdir'
make: *** [all] Error 2

Same error as the Korean guy... and he refers this page... [problem building gccgo on Fedora 10]...

There is a patch available there... will try... I don't know how to apply the patch... will check...

ALERT!!! There is a newer patch available, this patch is NO LONGER needed!!!

svn diff
Index: libgo/go/debug/proc/regs_linux_386.go
===================================================================
--- libgo/go/debug/proc/regs_linux_386.go (revision 154104)
+++ libgo/go/debug/proc/regs_linux_386.go (working copy)
@@ -26,12 +26,12 @@
"esp",
"eip",
"eflags",
- "cs",
- "ss",
- "ds",
- "es",
- "fs",
- "gs",
+ "xcs",
+ "xss",
+ "xds",
+ "xes",
+ "xfs",
+ "xgs",
}

func (r *_386Regs) PC() Word { return Word(r.Eip) }
@@ -80,17 +80,17 @@
case 9:
return Word(uint32(r.Eflags))
case 10:
- return Word(r.Cs)
+ return Word(r.Xcs)
case 11:
- return Word(r.Ss)
+ return Word(r.Xss)
case 12:
- return Word(r.Ds)
+ return Word(r.Xds)
case 13:
- return Word(r.Es)
+ return Word(r.Xes)
case 14:
- return Word(r.Fs)
+ return Word(r.Xfs)
case 15:
- return Word(r.Gs)
+ return Word(r.Xgs)
}
panic("invalid register index ", strconv.Itoa(i));
}
@@ -118,17 +118,17 @@
case 9:
r.Eflags = int32(val)
case 10:
- r.Cs = uint16(val)
+ r.Xcs = int32(val)
case 11:
- r.Ss = uint16(val)
+ r.Xss = int32(val)
case 12:
- r.Ds = uint16(val)
+ r.Xds = int32(val)
case 13:
- r.Es = uint16(val)
+ r.Xes = int32(val)
case 14:
- r.Fs = uint16(val)
+ r.Xfs = int32(val)
case 15:
- r.Gs = uint16(val)
+ r.Xgs = int32(val)
default:
panic("invalid register index ", strconv.Itoa(i))
}
Index: libgo/mksysinfo.sh
===================================================================
--- libgo/mksysinfo.sh (revision 154104)
+++ libgo/mksysinfo.sh (working copy)
@@ -45,11 +45,13 @@
EOF

# FIXME: GNU/Linux specific.
+#include <sys/user.h>
+#include <linux/user.h>
cat >>sysinfo.c <<EOF
-#include <linux/user.h>
+#include <sys/user.h>
EOF

-${CC} -D_GNU_SOURCE -ggo -S -o sysinfo.s sysinfo.c
+${CC} ${CFLAGS} -D_GNU_SOURCE -ggo -S -o sysinfo.s sysinfo.c

echo 'package syscall' > ${OUT}

For applying the patch...

$ cd ../gccgo
$ patch -p0 -i ~/gccgo.diff

I need to install patch :)

$ sudo apt-get -y install patch

Tried patch, but only mksysinfo.sh got patched, regs_linux_386.go showed error... I tried changing tabs and spaces but only one change worked... so I will fix it manually...

Trying again...

$ cd ../objdir
$ make

It is working... I am getting late for work... will do the rest of the making after I return... I stayed to post this thread and make is complete... voila... :)

$ sudo make install

Installed successfully... but...

make[2]: *** No rule to make target `go.install-plugin', needed by `lang.install-plugin'. Stop.
make[2]: Leaving directory `/more/go/objdir/gcc'
make[1]: *** [install-gcc] Error 2
make[1]: Leaving directory `/more/go/objdir'
make: *** [install] Error 2

don't know what it means...

Let's try using gccgo...

$ gccgo hello.go
hello.go:3:8: error: import file ‘fmt’ not found
hello.go:6:1: error: reference to undefined name ‘fmt’

So, something is still not working... will check later... bye 4 now...

To be continued... Part 2... Part 3...

Check out the mini-HOWTO on gccgo... gccgo mini-HOWTO

DYK? MOTU stands for Masters Of The Universe, it is a team at Ubuntu... ;)

Reference: Setting up and using gccgo

See also... » gccgo Debian Package

» gccgo mini-HOWTO

» Google Go - A First Look

» Booting Ubuntu 9.10 - Part 1 (The Downfall)

» Booting Ubuntu 9.10 - Part 2 (The Koala Reborn)

» Effective Use of VIM - Part 1

» Ubuntu 9.10 Karmic Koala on the move

» Install Firefox 3.5.1 Official Release in Ubuntu

» Sudo without Password in Ubuntu

» Mounting FAT32 Partitions with Full User Permission in Ubuntu

» Yahoo Messenger! in Ubuntu


ATOzTOA : Latest Headlines


1 comments:

Anonymous said...

FYI, if you build on amd64, you'll also need libc6-dev-i386 ; otherwise you get an error relating to /usr/include/gnu/stubs-32.h

Post a Comment