我想知道go编译器是如何工作的!
https://github.com/golang/go此源包含88%的.go
文件。
因此,应该有另一个编译器来执行.go
文件。
示例:https://github.com/golang/go/blob/964639cc338db650ccadeafb7424bc8ebb2c0f6c/src/go/ast/ast.go
戈朗用什么编译器最终生成执行文件?!他们从哪里找到的?
可能是歌朗生成一个c码,然后用GCC还是.?
新更新
我不想去1.4然后在使用c。
github.com/golang/go的88%来源于.go
文件。Go Source上有什么编译的.go
文件?我要看最后一次编译吗?
https://github.com/golang/go/search?l=c
我想这叫cg
。
意思是用一个旧版本的Go编译器(1.4版)来编译较新版本的Go编译器。?!
go-go1.4.3/src/go/token/token.go
这是go令牌,lexer,是在写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-go1.4.3/src/cmd/gc$ make
go tool dist install -v
make: go: Command not found
../../Make.dist:13: recipe for target 'install' failed
make: *** [install] Error 127
让gc为什么要走!
GO语言的最后一个版本如何工作?!这意味着如何生成跨平台的输出?这个使用生成代码到C,然后使用c编译器?
发布于 2017-12-09 23:50:24
根据https://golang.org/doc/go1.5#implementation和https://www.infoq.com/news/2015/01/golang-15-bootstrapped的说法,Go最初是用C实现的,但在1.5版时变成了自托管的。引导是用自己编译编译器的过程。Go开发人员编写了一个C -> Go转换程序,将原来的C编译器转换为Go,然后手工编辑Go代码,使其成为惯用代码。
https://stackoverflow.com/questions/47734417
复制相似问题