gccgo - another Google Go compiler - Part 3

Thursday, November 26, 2009

gccgo - another Google Go compiler - Part 3

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

Continued... Part 1... Part 2...

Ian Lance Taylor from Google has released yet another patch... let's check it out... [Link: [gccgo] Don't use <linux/user.h>]

Index: libgo/mksysinfo.sh
===================================================================
--- libgo/mksysinfo.sh (revision 154234)
+++ libgo/mksysinfo.sh (working copy)
@@ -41,14 +41,10 @@ cat > sysinfo.c <<EOF
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/un.h>
+#include <sys/user.h>
#include <unistd.h>
EOF

-# FIXME: GNU/Linux specific.
-cat >>sysinfo.c <<EOF
-#include <linux/user.h>
-EOF
-
${CC} -D_GNU_SOURCE -ggo -S -o sysinfo.s sysinfo.c

echo 'package syscall' > ${OUT}
@@ -196,7 +192,8 @@ regs=`grep '^#GO type _user_regs_struct
if test "$regs" != ""; then
regs=`echo $regs | sed -e 's/type _user_regs_struct struct //'`
regs=`echo $regs | sed -e 's/\([^a-zA-Z0-9_]*\)\([a-zA-Z0-9_]\)\([a-zA-Z0-9_]* [^;]*;\)/\1\U\2\E\3/g'`
- regs=`echo $regs | sed -e 's/ __/ X__/'g`
+ # FIXME: x86 specific.
+ regs=`echo $regs | sed -e 's/X\([a-z]\)\([a-z]\) int32/ \U\1\E\2 uint16; X\1\2 uint16/g'`
echo "type PtraceRegs struct $regs" >> ${OUT}
fi

This is what Ian says...

Newer kernel versions don't provide <linux/user.h>. This patch changes the libgo build to not try to use it, but to use <sys/user.h>. I was using <linux/user.h> because it gives more useful values for cs, ds, etc., so this patch also changes the sed script to get those back.

So, we may not need the patch for regs_linux_386.go anymore... let me say about it in the earlier section so that people won't do that...

Also, let me remove that symbolic link to sys/user.h...

$ sudo rm /usr/include/linux/user.h

Let's put back the original files mksysinfo.sh and regs_linux_386.go...

$ cd ../gccgo
$ rm libgo/mksysinfo.sh
$ svn update libgo/mksysinfo.sh
$ rm libgo/go/debug/proc/regs_linux_386.go
$ svn update libgo/go/debug/proc/regs_linux_386.go
$ cd ../objdir

Wow... mksysinfo.sh from SVN is the latest version with patch... :)

Will try make directly... making... expecting another error anytime... nothing... make complete...

At last... it is a complete success...

----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib

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.
----------------------------------------------------------------------

Now, let's test it...

$ gccgo hello.go
/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../libgo.so: undefined reference to `__sync_fetch_and_add_4'
/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../libgo.so: undefined reference to `__sync_bool_compare_and_swap_4'
collect2: ld returned 1 exit status

Will check that later... I am tired... anyways, installation is successful... :)

Update... this is the reply for the issue from Ian...

To get around this, when you run configure on a 32-bit x86, use the --with-arch option. For example, if you have a Pentium 4, use --with-arch=pentium4 when you run configure.

I have an AMD box, need to find out what to use for that... be right back...

I am trying make with --with-arch=i686... will wait...

It worked... now no error during compilation... but when I try to execute...

$ ./a.out
Illegal instruction

No idea what it means...

Ian tried out my a.out and it worked for him... I think the issue is with the --with-arch...

As Majkel J. Smyfsky pointed out, the man page for gcc lists the values to be used for each machine... -march is same as --with-arch... so, now I am gonna install again using --with-arch=athon-xp... c ya soon...

...still the same issue... I am lost... :(

According to Ian, the issue is with my processor (AMD Athlon 2400+ XP)... it does not support SSE2 instruction set, only SSE... the go shared library contains SSE2 instructions... that is why the illegal instruction exception is occurring...

I am waiting for Ian to do something :)

And Ian strikes again... :) He told he had fixed it...

Ian's message:

I think this issue is now fixed. gccgo no longer forces the use of SSE2 on 32-bit x86. Doing an svn update of the sources and forcing a complete rebuild of libgo should fix the problem.

Tonight, I am gonna do it again... keeping --with-arch=athlon-xp...

Configure completed...
Make completed...
Install completed...

And here goes...

$ gccgo hello.go
$ ./a.out
Hello, world; or Καλημέρα κόσμε; or こんにちは 世界

Yep, it is working... thanks to Ian... :)

I need to verify using arch as i686... maybe later... bye...

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

P.S.: I am going to try to make a Debian package (.deb) for gccgo...

Update: Debian Package generation success - gccgo Debian Package


Reference: Setting up and using gccgo

See also... » 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

» VLC 1.0.0 in Ubuntu

» Sudo without Password in Ubuntu

» Internet Explorer in Ubuntu

» Torrent in Ubuntu

» Mounting FAT32 Partitions with Full User Permission in Ubuntu

» Yahoo Messenger! in Ubuntu


ATOzTOA : Latest Headlines


5 comments:

Ridam Chopra said...

thank You!!!!!!!!!!
hv installed successfully!
just facing dis final error:
./a.out: error while loading shared libraries: libgo.so.0: cannot open shared object file: No such file or directory


Plzzzzzzzzzzzzzzz help me out.

atoztoa said...

@Ridam Chopra:

Which distro are you using? Did "sudo make install" show any errors / warnings?

Have you tried out the Debian Package (at the end of the post)?

Also try checking out SVN again...

atoztoa said...

@Ridam Chopra:

Here is another possible solution:

$ locate libgo.so.0

You will have something like this:

/usr/lib/libgo.so.0
/usr/lib/libgo.so.0.0.0


or

/usr/local/lib/libgo.so.0
/usr/local/lib/libgo.so.0.0.0


Just add the directory where it is present (like /usr/local/lib or /usr/lib) to /etc/ld.so.conf.

$ echo "/usr/local/lib" >> /etc/ld.so.conf
$ /sbin/ldconfig


Try that out and tell me what you get...

Anonymous said...

Thanks, It worked for me :D

Post a Comment