You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go version devel +748aa84 Wed Aug 10 20:33:11 2016 +0000 linux/ppc64le
What operating system and processor architecture are you using (go env)?
ppc64le Ubuntu 16.04
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
Simple testcase:
test-setX.go:
package main
import (
"fmt"
)
var VERSION string
func main() {
fmt.Printf("Hello, World! Version is: %s\n", VERSION)
}
Make sure there is a shared std libary
go install -buildmode=shared std
go build -linkshared -ldflags '-X main.VERSION=123' test-setX.go
What did you expect to see?
Successful build and execution. Output without -linkshared is:
./test-setX
Hello, World! Version is: 123
What did you see instead?
Program didn't build, error message was:
cannot use -X with non-string symbol main.VERSION type.TwVfYA92
(I modified src/cmd/link/internal/ld/data.go to print out the actual type at the end of the message. That does not appear by default.)
I also just tried removing the test in data.go where this error message occurs, and then the program built successfully but panicked at runtime.
The text was updated successfully, but these errors were encountered:
Pretty sure that type.TwVfYA92 is actually type.string, type symbols get their names compressed (in general, it's actually getting expanded here). A fix would be to not mangle type names when the mangling would in fact make the names longer (@crawshaw?)
When dynamically linking, a type symbol's name is replaced with a name based on
the SHA1 of the name as type symbol's names can be very long. However, this
can make a type's symbol name longer in some cases. So skip it in that case.
One of the symbols this changes the treatment of is 'type.string' and that fixes a
bug where -X doesn't work when dynamically linking.
Fixesgolang#16671
Change-Id: If5269038261b76fb0ec52e25a9c1d64129631e3c
Reviewed-on: https://go-review.googlesource.com/26890
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Please answer these questions before submitting your issue. Thanks!
go version
)?go version devel +748aa84 Wed Aug 10 20:33:11 2016 +0000 linux/ppc64le
go env
)?ppc64le Ubuntu 16.04
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
Simple testcase:
test-setX.go:
package main
import (
"fmt"
)
var VERSION string
func main() {
fmt.Printf("Hello, World! Version is: %s\n", VERSION)
}
Make sure there is a shared std libary
go install -buildmode=shared std
go build -linkshared -ldflags '-X main.VERSION=123' test-setX.go
Successful build and execution. Output without -linkshared is:
./test-setX
Hello, World! Version is: 123
Program didn't build, error message was:
cannot use -X with non-string symbol main.VERSION type.TwVfYA92
(I modified src/cmd/link/internal/ld/data.go to print out the actual type at the end of the message. That does not appear by default.)
I also just tried removing the test in data.go where this error message occurs, and then the program built successfully but panicked at runtime.
The text was updated successfully, but these errors were encountered: