Recently I read Go lang. I began to understand its structure.
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)?
- 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
- where executables will be generated into.
- C header files.
- where some libraries will be generated into.
- where Go standard packages (libraries) will be compiled into.
- source codes
- test cases
Let's dive into src:
- source codes for the Go tool chain
- Plan 9 C library?
- buffered IO library
- library which contains architecture dependent codes
- source codes of Go standard packages
Let's dive into cmd directory.
[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.