Open jm33-m0 opened 3 years ago
If I set
GOPRIVATE=example.com/user/*
it gives mepublic package xxx can't depend on obfuscated package yyy
And when I move my project to example.com
, I got new error saying relocation target runtime.something_random not defined
My go version is 1.16.3 by the way.
Please try your original command with master and share the results.
Please try your original command with master and share the results.
I installed garble
with go get
, I think it pulls directly from the master branch
You're using modules, so you installed 0.2.0. Use go install mvdan.cc/garble@master
.
@mvdan I have tried with latest code from master branch, with go env -w "GOPRIVATE=*"
, CGO is disabled, build target is 386
, error becomes:
# vendor/golang.org/x/crypto/chacha20
typecheck error: C:\Program Files\Go\src\vendor\golang.org\x\crypto\chacha20\chacha_generic.go:10:2: could not import crypto/cipher (can't find import: "crypto/cipher")
# vendor/golang.org/x/crypto/cryptobyte
typecheck error: C:\Program Files\Go\src\vendor\golang.org\x\crypto\cryptobyte\asn1.go:8:16: could not import encoding/asn1 (can't find import: "encoding/asn1")
# vendor/golang.org/x/text/unicode/norm
typecheck error: C:\Program Files\Go\src\vendor\golang.org\x\text\unicode\norm\composition.go:7:8: could not import unicode/utf8 (can't find import: "unicode/utf8")
# vendor/golang.org/x/text/secure/bidirule
typecheck error: C:\Program Files\Go\src\vendor\golang.org\x\text\secure\bidirule\bidirule.go:12:2: could not import errors (can't find import: "errors")
exit status 2
If I leave out the standard libraries with GOPRIVATE=github.com/*
, it builds fine, and the resulting binary works as expected
Interesting. Can you reproduce on Linux, e.g. inside a Docker container? I haven't seen errors like that on Linux, and I don't have a Windows machine to test on.
Also worth noting that we already test on Windows, and we have a test that does a cross-build for both GOOS and GOARCH. So everything should work on Windows.
Timed out. Happy to reopen if you can provide a way to reproduce this, or if you can help us debug what's going on.
Sorry for the late reply, I just tested my code on Linux with GOPRIVATE=*
, it fails with following error:
# github.com/vishvananda/netlink/nl
:1: cannot convert *a (type h5iKSdK5.L3J_TlQ2) to type syscall.RtAttr
:41: undefined: iota
exit status 2
exit status 2
Similar errors can be triggered at runtime as well.
For example, a binary is built without errors, but when trying to run it, some of its functions might fail due to obfuscated names that it cannot handle.
The runtime errors due to obfuscated names is probably due to reflection; see https://github.com/burrowers/garble#caveats. Garble should get better at automatically doing the right thing in most cases, but reflection by definition is just arbitrary logic, so it's impossible to tell what names can or cannot be obfuscated.
That RtAttr
error looks like a bug. Can you reproduce with garble master? If so, could you provide a standalone way for us to reproduce the error?
That RtAttr error looks like a bug. Can you reproduce with garble master? If so, could you provide a standalone way for us to reproduce the error?
I think simply importing the netlink
package will do
Thanks, I can reproduce via cd core && GOPRIVATE=* garble build github.com/vishvananda/netlink/nl
in your repo.
Fully obfuscating the syscall package to fix this problem at its root will take some time, I think, because that also requires obfuscating the runtime.
For now, you can manually mark your RtAttr type to not be obfuscated via reflect.TypeOf
, as shown in https://github.com/burrowers/garble#caveats.
Recently I found another bug, if a pointer of structure is used as function return variable, it fails to parse as it's obfuscated, even with reflect.TypeOf
, because upper level name is also obfuscated.
My solution is to create the same variable in function body, and use its address as return value
If you can reproduce it I think we should open another issue for this bug.
Can you file that as a separate issue with details on how I can reproduce it? Ideally with a standalone example program.
Run with
I get a bunch of errors:
If I set
GOPRIVATE=example.com/user/*
it gives mepublic package xxx can't depend on obfuscated package yyy