garble icon indicating copy to clipboard operation
garble copied to clipboard

include extra context in compiler and linker errors

Open mvdan opened this issue 3 years ago • 5 comments

For example, from a recent bug report:

zdzCF.B: relocation target type.path/to/package/types.ZU31i not defined
zdzCF.F: relocation target type.path/to/package/types.ZHdpV not defined
zHIRS.ZCZ_Z.func1: relocation target type.path/to/package/types.ZHdpV not defined
z3hTq.C.func1.2: relocation target type.path/to/package/types.Z8uvN not defined
z3hTq.C.func1.2: relocation target type.path/to/package/types.ZU31i not defined
z3hTq.B.func1.2: relocation target type.path/to/package/types.Z8uvN not defined
z3hTq.B.func1.2: relocation target type.path/to/package/types.ZU31i not defined
exit status 2
exit status 2

If I was debugging this failure manually, I'd have to do a bunch of debugging to figure out what original bit of code the obfuscated names like ZU31i actually refer to.

This is unnecessary, and the errors are unnecessarily hostile to the average user. We should, at least, provide context as to what was the original name of each of these.

We could probably reuse the work from https://github.com/burrowers/garble/issues/5 here. We would print the usual build error, and then print its un-garbled version too if any garbled identifiers were found.

mvdan avatar Feb 03 '21 14:02 mvdan

Reversing is already good enough to do this. For example, for #315:

$ wgo1 garble build
# github.com/fatedier/frp/client/proxy
E5ewj7pj.go:27: pxy.swzbE4SL.Plugin undefined (type *HliYu5gW.TCPProxyConf has no field or method Plugin)
ck6BOo76.go:1: pxy.swzbE4SL.Plugin undefined (type *HliYu5gW.TCPProxyConf has no field or method Plugin)
ck6BOo76.go:1: pxy.swzbE4SL.PluginParams undefined (type *HliYu5gW.TCPProxyConf has no field or method PluginParams)
M8vRqyjN.go:13: pxy.swzbE4SL.Plugin undefined (type *HliYu5gW.TCPMuxProxyConf has no field or method Plugin)
TQQwyS7C.go:1: pxy.swzbE4SL.Plugin undefined (type *HliYu5gW.TCPMuxProxyConf has no field or method Plugin)
TQQwyS7C.go:1: pxy.swzbE4SL.PluginParams undefined (type *HliYu5gW.TCPMuxProxyConf has no field or method PluginParams)
BXLs4XhX.go:13: pxy.swzbE4SL.Plugin undefined (type *HliYu5gW.HTTPProxyConf has no field or method Plugin)
FJYiROJ6.go:1: pxy.swzbE4SL.Plugin undefined (type *HliYu5gW.HTTPProxyConf has no field or method Plugin)
FJYiROJ6.go:1: pxy.swzbE4SL.PluginParams undefined (type *HliYu5gW.HTTPProxyConf has no field or method PluginParams)
LfBuznMY.go:13: pxy.swzbE4SL.Plugin undefined (type *HliYu5gW.HTTPSProxyConf has no field or method Plugin)
LfBuznMY.go:13: too many errors
exit status 2
exit status 2
$ wgo1 garble build |& wgo1 garble reverse
# github.com/fatedier/frp/client/proxy
E5ewj7pj.go:27: pxy.swzbE4SL.Plugin undefined (type *github.com/fatedier/frp/pkg/config.TCPProxyConf has no field or method Plugin)
github.com/fatedier/frp/client/proxy/proxy.go:136: pxy.swzbE4SL.Plugin undefined (type *github.com/fatedier/frp/pkg/config.TCPProxyConf has no field or method Plugin)
github.com/fatedier/frp/client/proxy/proxy.go:136: pxy.swzbE4SL.PluginParams undefined (type *github.com/fatedier/frp/pkg/config.TCPProxyConf has no field or method PluginParams)
github.com/fatedier/frp/client/proxy/proxy.go:1523: pxy.swzbE4SL.Plugin undefined (type *github.com/fatedier/frp/pkg/config.TCPMuxProxyConf has no field or method Plugin)
github.com/fatedier/frp/client/proxy/proxy.go:165: pxy.swzbE4SL.Plugin undefined (type *github.com/fatedier/frp/pkg/config.TCPMuxProxyConf has no field or method Plugin)
github.com/fatedier/frp/client/proxy/proxy.go:165: pxy.swzbE4SL.PluginParams undefined (type *github.com/fatedier/frp/pkg/config.TCPMuxProxyConf has no field or method PluginParams)
github.com/fatedier/frp/client/proxy/proxy.go:1813: pxy.swzbE4SL.Plugin undefined (type *github.com/fatedier/frp/pkg/config.HTTPProxyConf has no field or method Plugin)
github.com/fatedier/frp/client/proxy/proxy.go:194: pxy.swzbE4SL.Plugin undefined (type *github.com/fatedier/frp/pkg/config.HTTPProxyConf has no field or method Plugin)
github.com/fatedier/frp/client/proxy/proxy.go:194: pxy.swzbE4SL.PluginParams undefined (type *github.com/fatedier/frp/pkg/config.HTTPProxyConf has no field or method PluginParams)
github.com/fatedier/frp/client/proxy/proxy.go:2103: pxy.swzbE4SL.Plugin undefined (type *github.com/fatedier/frp/pkg/config.HTTPSProxyConf has no field or method Plugin)
github.com/fatedier/frp/client/proxy/proxy.go:2103: too many errors
exit status 2
exit status 2

Edit: looks like just the field names aren't reversed, but still, the rest is helpful.

mvdan avatar Apr 17 '21 09:04 mvdan

Fields names are reversed as of https://github.com/burrowers/garble/commit/0150aa8bb0ecc95965540c784aa055d361e4ebc9 right?

capnspacehook avatar Apr 22 '21 23:04 capnspacehook

Also, is there any reason we wouldn't want to automatically reverse the error message(s) instead of making the user reverse the error messages themselves?

capnspacehook avatar Apr 22 '21 23:04 capnspacehook

Fields names are reversed as of 0150aa8 right?

Yep, I fixed that shortly after posting the comment.

Also, is there any reason we wouldn't want to automatically reverse the error message(s) instead of making the user reverse the error messages themselves?

That's what this issue is about :) My last comment just says that reverse is now good enough that hooking it up to build errors is now possible. Before, we were blocked because reverse wasn't good enough.

mvdan avatar Apr 23 '21 08:04 mvdan

Dropping this from the milestone because it doesn't seem urgent.

mvdan avatar May 15 '21 22:05 mvdan