世界線航跡蔵

Mad web programmerのYuguiが技術ネタや日々のあれこれをお送りします。

2011年01月17日

Understanding Go compiler tools (1)

Recently I read Go lang. I began to understand its structure.

How to build

You can build the go compiler and tools as documented in the official documentation.

It is quite easy. But it was confusing for me that I must run ./all.bash instead of usual make(1). I wonder why they don't simply use make. Anyway the bash script internally calls make as usual.

After building, I got the following executables in bin directory.

  • 6a: assembler
  • 6c: C compiler
  • 6g: Go compiler
  • 6l: linker
  • 6nm: same as nm(1)?
  • cgo
  • ebnflint
  • godefs
  • godoc
  • gofmt
  • goinstall
  • gomake
  • gopack
  • gopprof
  • gotest
  • gotry
  • govet
  • goyacc
  • hgpatch
  • quietgcc: gcc wrapper which is little slienter than native gcc

The oddish *1 prefix "6" is because I built the tools on amd64 architecture. The prefix varies according to architecture.

There are only three architectures which is implemented in the source:

  • 6: amd64
  • 8: i386
  • 5: ARM

This convention came from Plan 9. I found the definitions for other architectures in include/mach.h:

  • 0: MIPS2 Little Endian
  • 2: 68020
  • 4: MIPS2 Big Endian
  • 7: Alpha
  • k: Sparc
  • q: Power
  • u: Sparc 64
  • v: MIPS

2c(1) in Plan 9 describes one more architecture:

  • 1: Motorola 68000

Directory structure

bin
where executables will be generated into.
doc
documentation
include
C header files.
lib
where some libraries will be generated into.
misc
misc
pkg
where Go standard packages (libraries) will be compiled into.
src
source codes
test
test cases

Let's dive into src:

cmd
source codes for the Go tool chain
lib9
Plan 9 C library?
libbio
buffered IO library
libcgo
?
libmach
library which contains architecture dependent codes
pkg
source codes of Go standard packages

commands

Let's dive into cmd directory.

  • 5a/
  • 5c/
  • 5g/
  • 5l/
  • 6a/
  • 6c/
  • 6g/
  • 6l/
  • 8a/
  • 8c/
  • 8g/
  • 8l/
  • cc/
  • cgo/
  • cov/
  • ebnflint/
  • gc/
  • godefs/
  • godoc/
  • gofmt/
  • goinstall/
  • gomake/
  • gopack/
  • gotest/
  • govet/
  • goyacc/
  • hgpatch/
  • ld/
  • nm/
  • prof/

[568][acgl] directories contain architecture dependent part of the sources. Architecture independent parts of the Go compiler are in gc directory.

I will read the detail of gc in the next post.


*1oddish, at least for me, who grew with GNU/Linux environment.


トラックバック

http://yugui.jp/articles/864/ping

現在のところトラックバックはありません

コメント

blog comments powered by Disqus

ご案内

前の記事
次の記事

タグ一覧

過去ログ

  1. 2014年09月
  2. 2014年07月
  3. 2014年06月
  4. 2014年02月
  5. 過去ログ一覧

フィード

フィードとは

その他

Powered by "rhianolethe" the blog system