将优化标志传递给Go编译器? [英] Passing an optimization flag to a Go compiler?
问题描述
要编译Go程序,请键入 go build myprogram.go
,是否可以传递优化标志,或者始终以相同的方式编译代码?我说的是速度优化,代码大小优化或其他优化.
To compile a Go program you type go build myprogram.go
, can you pass an optimization flags along or the code is always compiled in the same way? I am talking about speed optimizations, code size optimizations or other optimizations.
我知道如果您使用 gccgo
只是通过 -O2
或 -O0
,但是我的问题是关于官方Go编译器去
.
I know if you use gccgo
you just pass -O2
or -O0
but my question is about an official Go compiler go
.
推荐答案
实际上没有明确的标记,此Go Wiki golang-nuts 组.
Actually no explicit flags, this Go wiki page lists optimizations done by the Go compiler and there was a discussion around this topic in golang-nuts groups.
您可以在Go gc编译器中关闭优化和内联功能以进行调试.
You can turn off optimization and inlining in Go gc compilers for debugging.
-gcflags '-N -l'
-
-N
:禁用优化 -
-l </code>:禁用内联
这篇关于将优化标志传递给Go编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!