page-brochureware.php

Compilers for Linux on Power

Advanced compiler and optimization technologies

GO compilers

Building gccgo from source:

Documentation with some additional detail can be found here: https://golang.org/doc/install/gccgo as well as https://gcc.gnu.org/install/. Below are some examples of building gccgo from the source.

The directions for building gccgo from the source are similar to building from the gcc release 7, 8, or from the trunk source tree. The following instructions refer to the build directory as $dir, with the source located at $dir/src and the bld directory called $dir/bld.

  1. Get the source:

    The source can be obtained from a gcc mirror site https://gcc.gnu.org/mirrors.html or by using svn https://gcc.gnu.org/svn.html. Using a snapshot from a mirror is usually faster than svn.

    For example, if the tar file is found from a mirror, extract the source:

    mkdir src && cd src && tar -xvf gcc-8.1.0-tar.bz2

    Use the following example to extract source from svn:

    trunk: >svn co svn://gcc.gnu.org/svn/gcc/trunk src release 5: >svn co svn://gcc.gnu.org/svn/gcc/branches/gcc-8-branch src
  2. Configure

    The following example assumes that the source is in $dir/src. In order to configure, you need to create $dir/bld, cd to it, and configure.

    cd $dir

    mkdir bld && cd bld

    ../src/configure --target=powerpc64le-linux --host=powerpc64le-linux --build=powerpc64le-linux --enable-threads=posix --enable-shared --enable-__cxa_atexit --enable-languages=c,c++,go --enable-secureplt --enable-checking=yes --with-long-double-128 --enable-decimal-float --disable-bootstrap --disable-alsa --disable-multilib –prefix=/usr/local

    make

    make install

    This configure command installs into /usr/local, but another install directory can be used. When /usr/local is used, the library directory will be searched by default by the dynamic linker so libgo can be found. If another install directory is used, then you must provide information for where to find the libgo.so.x library to the the dynamic linker.

    There are several ways to do this:

    • Add the path to libgo.so.x to the LD_LIBRARY_PATH
    • Statically link the go program or use -static-libgo as described above to eliminates the dependency on the binaries with libgo.
    • Add the path to libgo.so.x using -Wl,--rpath=$PATHTOLIBGO

    For more information about the full set of configure options and their meaning you can invoke ../src/configure -h or refer to the GCC internals manual found on https://gcc.gnu.org/onlinedocs/