我想知道编译器是如何工作的!
https://github.com/golang/go
此来源包含88%.go
个文件。
所以这应该有另一个编译器来执行.go
文件。
示例:https://github.com/golang/go/blob/964639cc338db650ccadeafb7424bc8ebb2c0f6c/src/go/ast/ast.go
可能是Golang生成c代码,然后使用GCC或......?
我不想go1.4然后使用c。
88%的github.com/golang/go来源是.go
文件。什么编译Go Source的.go
文件?我想看看Final GO Compiler?
https://github.com/golang/go/search?l=c
我认为这称为cg
。
意味着旧版本的Go编译器(版本1.4)用于编译较新版本的Go编译器。???!
go-go1.4.3/src/go/token/token.go
这是令牌,词法分析器,写在GO
FUNC: "func",
GO: "go",
GOTO: "goto",
IF: "if",
IMPORT: "import",
.go
文件的主编译器是什么? go-go1.4.3/src/runtime/compiler.go
// Copyright 2012 The Go Authors. All rights reserved.
package runtime
// Compiler is the name of the compiler toolchain that built the
// running binary. Known toolchains are:
//
// gc The 5g/6g/8g compiler suite at code.google.com/p/go.
// gccgo The gccgo front end, part of the GCC compiler suite.
//
const Compiler = "gc"
go tool dist install -v
make: go: Command not found
../../Make.dist:13: recipe for target 'install' failed
make: *** [install] Error 127
make gc为什么需要Go?!
答案 0 :(得分:4)
根据https://golang.org/doc/go1.5#implementation和https://www.infoq.com/news/2015/01/golang-15-bootstrapped,Go最初是在C中实现的,但在1.5版本中自行托管。 Bootstrapping是用自己编译编译器的过程。 Go开发人员写了一个C - >转至转换器将原始的C编译器转换为Go,然后他们手动编辑Go代码,使其成为惯用语。