'gc'和'gccgo'之间的主要区别是什么? [英] What are the primary differences between 'gc' and 'gccgo'?

查看:522
本文介绍了'gc'和'gccgo'之间的主要区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两种流行的Go编译器'gc'和'gccgo'之间的主要区别是什么?建立性能?运行时间性能?命令行选项?许可?



我并不是在寻找哪一个最好的意见,只是对他们之间差异的基本概述,所以我可以决定哪一个最适合我的需求。您可以在 noreferrer>设置和使用gccgo


gccgo是Go语言的编译器。 gccgo编译器是GCC的新前端。

请注意,gccgo不是gc编译器


如上所述在 GCC 4.7.1中的Gccgo (2012年7月)


Go语言一直由规范定义,而不是实现。 Go团队编写了两个不同的编译器来实现该规范:gc和gccgo。


  • Gc是原始编译器,go工具使用它默认。

  • Gccgo是另一个不同焦点的实现



与gc相比,gccgo更慢编译代码但支持更强大的优化,所以通过gccgo构建的CPU绑定程序通常运行得更快。


另外:



  • gc编译器仅支持最常用的处理器:x86(32位和64位)和ARM。然而,Gccgo支持GCC支持的所有处理器。

    并非所有这些处理器都经过了gccgo的全面测试,但其中许多处理器都具有,包括x86(32位) 64位),SPARC,MIPS,PowerPC甚至Alpha。

    Gccgo还在gc编译器不支持的操作系统上进行了测试,特别是Solaris。

  • 如果您从标准Go版本安装go命令,它已通过 -compiler 选项支持gccgo: go build -compiler gccgo myprog






简而言之: gccgo:更多优化,更多处理器




然而,正如 OneOfOne (<一个href =https://golang.org/doc/go1.3#gccgo =noreferrer>来源),gccgo支持的go和最新的go版本之间通常会有一个不同步:


gccgo仅支持版本v1.2 ,因此如果您需要1.3 / 1.4版本中的新功能(小费)gccgo无法使用。 -



GCC版本4.9 将包含Go 1.2(而不是1.3)版本的gccgo

GCC和Go项目的发布时间表不一致,这意味着1.3将可用在开发分支中,但下一代GCC版本4.10可能会有Go 1.4版本的gccgo。






twotwotwo 提及评论 Brad Fitzpatrick演讲稿幻灯片


gccgo生成非常好的代码

...但缺乏逃生分析:杀死很多小型分配的性能+垃圾

... GC不精确。

twotwotwo补充:

$ b $另一张幻灯片提到非gccgo ARM代码生成是不可靠的。

假设它是您的项目的一个有趣的选项,可能比较您的目标架构上的用例的二进制文件。







由于 peterSO 评论开始1.5 (2015年第3季度)意味着:
$ b


编译器和运行时现在完全用Go编写(用一个小汇编器)。

C不再参与实现,因此曾经是构建发布所需的C编译器已经不存在了。


Go in Go幻灯片提及:


C不见了。

Side注意:gccgo仍然强劲。



What are the primary differences between the two popular Go compilers, 'gc' and 'gccgo'? Build performance? Run-time performance? Command line options? Licensing?

I'm not looking for opinions on which is best, just a basic overview of their differences, so I can decide which is best for my needs.

解决方案

You can see more in "Setting up and using gccgo":

gccgo, a compiler for the Go language. The gccgo compiler is a new frontend for GCC.
Note that gccgo is not the gc compiler

As explained in "Gccgo in GCC 4.7.1" (July 2012)

The Go language has always been defined by a spec, not an implementation. The Go team has written two different compilers that implement that spec: gc and gccgo.

  • Gc is the original compiler, and the go tool uses it by default.
  • Gccgo is a different implementation with a different focus

Compared to gc, gccgo is slower to compile code but supports more powerful optimizations, so a CPU-bound program built by gccgo will usually run faster.

Also:

  • The gc compiler supports only the most popular processors: x86 (32-bit and 64-bit) and ARM.
  • Gccgo, however, supports all the processors that GCC supports.
    Not all those processors have been thoroughly tested for gccgo, but many have, including x86 (32-bit and 64-bit), SPARC, MIPS, PowerPC and even Alpha.
    Gccgo has also been tested on operating systems that the gc compiler does not support, notably Solaris.

if you install the go command from a standard Go release, it already supports gccgo via the -compiler option: go build -compiler gccgo myprog.


In short: gccgo: more optimization, more processors.


However, as commented by OneOfOne (source), there is often a desynchronization between go supported by gccgo, and the latest go release:

gccgo only supports up to version go v1.2, so if you need anything new in 1.3 / 1.4 (tip) gccgo cant be used. –

GCC release 4.9 will contain the Go 1.2 (not 1.3) version of gccgo.
The release schedules for the GCC and Go projects do not coincide, which means that 1.3 will be available in the development branch but that the next GCC release, 4.10, will likely have the Go 1.4 version of gccgo.


twotwotwo mentions in the comments the slide of Brad Fitzpatrick's presentation

gccgo generates very good code
... but lacks escape analysis: kills performance with many small allocs + garbage
... GC isn't precise. Bad for 32-bit.

twotwotwo adds:

Another slide mentions that non-gccgo ARM code generation is wonky.
Assuming it's an interesting option for your project, probably compare binaries for your use case on your target architecture.


As peterSO comments, Go 1.5 now (Q3/Q4 2015) means:

The compiler and runtime are now written entirely in Go (with a little assembler).
C is no longer involved in the implementation, and so the C compiler that was once necessary for building the distribution is gone.

The "Go in Go" slide do mention:

C is gone.
Side note: gccgo is still going strong.

这篇关于'gc'和'gccgo'之间的主要区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆