为什么“-a”在调试时添加 [英] Why is "-a" added when debugging

查看:133
本文介绍了为什么“-a”在调试时添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CGO导入项目(sqlite3)。当我在调试时运行Go应用程序配置时,IDE会添加-a标志,这会导致重建所有内容。在我的情况下,它需要40秒以上才能开始运行。



我在Go 1.9 Release中使用EAP 172.3968.42(9月4日)



有没有办法告诉它不要添加-a标志?



无需调试,并且不添加标志,编译需要3秒钟的时间。
我不需要调试任何导入,只有我的代码在纯Go中。



谢谢。



现在是更长版本:



你是对的,由于改进的调试支持,使用EAP 12+时编译速度有所降低。

发生的事情是,Go 1.9现在可以在编译所有优化关闭时编译传递依赖性方面做得更好,这意味着Delve可以在您的应用程序中更好地工作。



这意味着所有在GOPATH / pkg和GOROOT / pkg中重新编译以进行调试,以确保没有任何包含在优化过程中的意外。



如果发生这种情况,那么你最终可能会得到一个无法调试的软件包,有时甚至可能是你的软件包之一。



不幸的是,现在,优化关闭了构建由于-a的工作原理而不可缓存。这意味着去构建-i -a -gcflags'-N -l'... package / name ...目前是不可能的。



Delve本身会在运行dlv debug ... package / name ....时应用-a标志,虽然你可以在Gogland中关闭-a标志,但我会建议不要这样做(或者你如果您遇到任何错误,d必须重做调试会话,因为这不是Delve正式支持的模式)。



对于原始问题的链接,请参阅: https://youtrack.jetbrains.com/issue/GO-4249



希望这有助于。


I have a project with a CGO import (sqlite3). When I am running a Go application configuration with debugging the IDE adds the -a flag which causes everything to be rebuilt. In my case it takes above 40 seconds for it to start running.

I am using EAP 172.3968.42 (Sep 4th) with Go 1.9 Release

Is there a way to tell it not to add the -a flag?

When I am running without debugging and the flag is not added it takes 3 seconds to compile. I don't need to debug any imports, only my code which is in pure Go.

Thanks.

解决方案

Gogland will build the debug binary with "go build -a .... package/name ...." in order to debug it. If you want the old behavior, then you need to go in Settings | Build, Execution, Deployment | Debugger | Delve and toggle Rebuild transitive dependencies. However, this is discouraged and for any debugging issue you have you'll need to first turn that back on and then report the issue. This is because Gogland will bypass what Delve would otherwise do when running "dlv debug package/name". There are plans to have better support in Go 1.10, hopefully, but this depends on work from the Go team as well.

Now for the longer version:

You are correct, the compilation speed has degraded a bit when using the EAP 12+ because of improved debugging support.

What happened is that Go 1.9 can now do a better job at compiling the transitive dependencies with all the optimizations turned off which means Delve can work better on your application.

This means everything in GOPATH/pkg and GOROOT/pkg is recompiled for debugging in order to ensure that there's no package that has been included accidentally with the optimizations on.

If that would happen, then you could potentially end up with a package that does not debug as well, and sometimes that could even be one of your packages.

Unfortunately, for now, optimizations off builds are not cacheable, due to how "-a" works. This means "go build -i -a -gcflags '-N -l' ... package/name ... " is not possible at the moment.

Delve itself would apply the "-a" flag when running "dlv debug ... package/name .... " so, while you can turn the "-a" flag off in Gogland, I would advise against it (or you'd have to redo the debugging session using it in case you encounter any bugs since this is not a mode supported by Delve officially).

For a link to the original issue, please see: https://youtrack.jetbrains.com/issue/GO-4249

Hope this helps.

这篇关于为什么“-a”在调试时添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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