【发布时间】:2017-12-09 23:44:01
【问题描述】:
我想知道 go 编译器是如何工作的!
https://github.com/golang/go
此来源包含 88% .go 文件。
所以这应该有另一个编译器来执行.go文件。
例如:https://github.com/golang/go/blob/964639cc338db650ccadeafb7424bc8ebb2c0f6c/src/go/ast/ast.go
Golang 使用什么编译器来生成最终的执行文件?!他们从哪里获得?
可能是 Golang 生成一个 c 代码,然后使用 GCC 或 ...?
新更新
我不想 go1.4 然后在使用 c。
88% 的 github.com/golang/go 来源是 .go 文件。在 Go Source 编译 .go 文件是什么?我想看看 Final GO 编译器?
https://github.com/golang/go/search?l=c
我认为这称为cg。
mean 一个旧版本的 Go 编译器(1.4 版)用于编译新版本的 Go 编译器。???!
go-go1.4.3/src/go/token/token.go 这是 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-go1.4.3/src/cmd/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?!
最后一个版本的 GO 语言是如何工作的?!意思是如何为跨平台生成输出?这使用生成代码到C然后使用c编译器?
【问题讨论】:
-
麻烦你了,所以 go 是一个自托管编译器,那么在github.com/golang/go 执行和运行
.go文件呢? -
另请注意,github.com/golang/go 中的大部分内容是标准库,而不是编译器。
-
哇,哪里有可用的编译器源? @阿德里安
-
同一个仓库。它是编译器、工具、标准库、测试和文档,应有尽有。
标签: gcc go compilation compiler-construction cross-compiling