LoginSignup
5
3

More than 5 years have passed since last update.

Golang って Solaris ではどうなのか調べてみた

Last updated at Posted at 2016-01-10

Docker が Go で書かれているから。
来るべきその日に備えて。

Installing Go from source に記載されていますが、Go コンパイラのターゲット OS に Solaris は含まれています。

The compilers can target the DragonFly BSD, FreeBSD, Linux, NetBSD, OpenBSD, OS X (Darwin), Plan 9, Solaris and Windows operating systems.

リリースノートに垣間見る Solaris のサポート情報

正式ではなくexperimental support として、Go 1.3 から illumos Kernel や Solaris 11 がサポートされています。

Go 1.3 Release Notes (June 2014):
Support for Solaris

* Go 1.3 now includes experimental support for Solaris on the amd64 (64-bit x86) architecture. It requires illumos, Solaris 11 or above.

Go 1.4 Release Notes (December 2014):

* 特に記載なし
Go 1.5 Release Notes (August 2015):

* The Solaris port now has full support for cgo and the packages net and crypto/x509, as well as a number of other fixes and improvements.

特に言及されていないので、現在のリリース (Go 1.5)でも experimental support は継続中なのですかね

golang-dev で Solaris を話題にしている人がいないかちょっと調べてみました。

サポートされるインストラクション・セットは?

Installing Go from sourceに記載がありますが、現時点では 5 つのインストラクションセット(CPU) をサポートしています。  
Solaris という観点では、amd64 (x86-64) になりますね。

SPARC へのポーティングは行われているようです。はやく dev.sparc64 branch できると良いですね。

The Go compilers support five instruction sets.

There are important differences in the quality of the compilers for the different architectures.

  • amd64 (also known as x86-64)
    A mature implementation. The compiler has an effective optimizer (registerizer) and generates good code (although gccgo can do noticeably better sometimes).
  • 386 (x86 or x86-32)
    Comparable to the amd64 port.
  • arm (ARM)
    Supports Linux, FreeBSD, NetBSD and Darwin binaries. Less widely used than the other ports.
  • arm64 (AArch64)
    Supports Linux and Darwin binaries. New in 1.5 and not as well excercised as other ports.
  • ppc64, ppc64le (64-bit PowerPC big- and little-endian)
    Supports Linux binaries. New in 1.5 and not as well excercised as other ports.

Go コンパイラ・ツールチェーンは、Go 言語で書かれている

Go 1.5 Bootstrap Plan

Go 1.5 will use a toolchain written in Go (at least in part).

Question: how do you build Go if you need Go built already?

Answer: building Go 1.5 will require having Go 1.4 available.

えっ。

Go 1.5 から、Go コンパイラを手に入れるためには Go 1.4 が必須にするというプランに関するドキュメントです。

“Goのソースツリーから,すべてのCプログラムを排除する方法”を検討していたそうです。

Go 1.5のブートストラップ化を目指すGoogle

そして、最新の Go 1.5 は、このプランのとおり Go コンパイラが必要となりました。

現在は、Go コンパイラに必要な toolchaine (ツールチェーン: プログラムを作成するために利用されるプログラムの集合体)として、gc Go コンパイラと関連するツール群を利用する方法
GCC バックエンドを利用した gccgo を利用する方法 の 2 つの方法が提供されている。

Solaris で Go コンパイラを動かすもっとも簡単な方法としては、

  • まずは、Go コンパイラを必要としない Solaris をサポートした Go 1.4 をビルドする
  • できあがった Go コンパイラで Go 1.5 をビルドする

という流れになります。
そのため Solaris では、gc Go コンパイラと関連するツール群を利用する方法 によるインストール手順を採用します。
ビルドは、次回 Golang って Solaris でビルドできるのか調べてみた に続く・・・

おまけ

boltdb - Bolt is a pure Go key/value store が mmap を利用することに対応するパッチおよびユーザーの仮想メモリ領域が特定のパターンで使用されることをカーネルに通知し、メモリおよびスレッドの配置を最適化する madvice() をサポートするパッチを作成している人も。

また、Solaris 上の Go コンパイラでは SYS_IOCTL が未定義のため syscall.Syscall(syscall.SYS_IOCTL,...) のようにシステムコールの直接呼び出しが書かれたコードはエラーになってしまうというのもあります。
上記の Issue に解決策が記載されていました。

ただ、いろいろ調べているとこのような書き方はプラットフォームのポータビリティを無視しているという意見もあり、ちょっと脱線していますが色々と面白い話にも遭遇しました。

On Go, Portability, and System Interfaces

参考情報

5
3
1

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
5
3