LoginSignup
3

More than 5 years have passed since last update.

gcc 8.1に含まれるgccgoをビルドする

Last updated at Posted at 2018-05-02

gccgo とは

The GCC 8 releases are expected to include a complete implementation of the Go 1.10 release, depending on release timing. The Go 1.10 runtime has now been fully merged into the GCC development sources, and concurrent garbage collection is expected to be fully supported in GCC 8.

gccgo はgccのコンパイルエンジンにgoのフロントエンドを組み合わせたもの。
今までは、通常のgolangの処理系に比べてruntimeの実装が少し古いものになっていたが、gcc 8になってgo 1.10のランタイムがマージされて、コンカレントGCもgccgoでサポートされると書いてある。

ちなみにgccのサイトでのgcc8でのgoの変更点はこちら。

Go

  • GCC 8 provides a complete implementation of the Go 1.10.1 user packages.
  • The garbage collector is now fully concurrent. As before, values stored on the stack are scanned conservatively, but value stored in the heap are scanned precisely.
  • Escape analysis is fully implemented and enabled by default in the Go frontend. This significantly reduces the number of heap allocations by allocating values on the stack instead.

gcc, g++, gccgo をビルド

基本は以前の記事、gcc 7.2.0 をソースからビルドする と同じ。
configure のときに、--enable-languages=c,c++,go とする。

wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-8.1.0/gcc-8.1.0.tar.xz
tar xf gcc-8.1.0.tar.xz 
cd gcc-8.1.0/
./contrib/download_prerequisites 
cd ..
mkdir obj
cd obj
../gcc-8.1.0/configure --enable-languages=c,c++,go --prefix=/usr/local --disable-multilib
make -j8
sudo make install
$ which gcc
/usr/local/bin/gcc
$ gcc --version
gcc (GCC) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ which gccgo
/usr/local/bin/gccgo
$ gccgo --version
gccgo (GCC) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ which go
/usr/local/bin/go
$ go version
go: error while loading shared libraries: libgo.so.13: cannot open shared object file: No such file or directory
$ export LD_LIBRARY_PATH=/usr/local/lib64
$ go version
go version go1.10 gccgo (GCC) 8.1.0 linux/amd64

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3