Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
plugin: spurious version-mismatch error for packages that differ only in debug information #31278
What version of Go are you using (
referenced this issue
Apr 5, 2019
Thanks for looking at this Bryan.
Each module has a go.mod file that cotains:
the line is the same in both cases:
The output of
in both cases.
If I look at the stored hashes by looking at the data stored in the ELF data, for the program, I see:
For the plugin that works (the one without the -mod=vendor flag), I see:
For the plugin that does not work (with the -mod=vendor flag), I see:
(does not match).
I've been looking the linker code but I can't figure out how these hashes are computed.
Investigating a little further (and guessing a lot), I can get this to work if I pass
It does not interoperate, and I'm not sure if it should. What I mean is that if I build the program with
I gues the questions are this point are:
Additional info. For the non-working case, the hashes are:
Adding -trimpath to get it working:
Since -trimpath doesn't seem to have an effect with / without -mod=vendor, I'm guessing $GOPATH/pkg/mod/ is somehow involved in the computation of the hash?
Just to be clear, everything above has been done without GOPATH set (so it's using the $HOME/go default).
If I set GOPATH to something (just to hold the pkg/mod files in a different directory), I can see the hashes in the "without -mod=vendor" case changing, but the "with -mod=vendor" case stays the same.
So the end result is that I have to use -mod=vendor (otherwise I have to build using the same path for the code) and I have to set -trimpath (otherwise the code cannot be loaded).
Should this be captured in a document?
Probably at least one difference here is in the debug information, which by default includes the full file paths. That's why you need
If that's correct, then you may find that if you set
While revisiting this for a different reason, I also noticed that -trimpath is a string (
The build command uses the -trimpath flag internally, calling compile for example as
That means if I pass
Does this matter?