Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
cmd/dist: misc/cgo/test: incorrect pie options used for ppc64x #21954
What version of Go are you using (go version)?
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (go env)?
When building golang with ./all.bash, failures occur in some tests in misc/cgo/test with errors like this:
After digging through cmd/dist/test.go I found that the failures occurred only when the tests were built with the external linker when passing -pie as a flag to the external linker. For example in misc/cgo/nocgo I can build the test by hand:
According to the linker documentation -pie should only be used with position independent code, but for ppc64x, it is not PIC by default. Either these tests should not be built and run on ppc64x with these options, or different options should be used. It seems like -buildmode=pie is what should be used here because that will build PIC but I tried that and that resulted in different build errors which I haven't investigated yet.
If I try to build these tests with -buildmode=pie it does build the test and it says it passes but I get this warning. Not sure if it matters:
searching for runtime.a in $WORK/_/home/boger/golang/go1.9/go/misc/cgo/nocgo/test/runtime.a
My toolchain doesn't have a pkg/linux_ppc64le_shared directory and I'm not sure what causes it to get built. I went looking for that directory on various systems and golang builds I've done and see that it is there sometimes but not others and I'm not aware of what I might have done to cause it to be created and populated.
I don't know why this failure only happens on Ubuntu 16.04. I built on a 17.04 as well as earlier Ubuntu versions, and some RHEL 7.x systems and they all worked. 16.04 has 2.26.1, 17.04 has 2.28. I believe the message comes from the dynamic linker at runtime so maybe the glibc version is a factor. Once I noticed that the testscase is not using valid linker options for ppc64le, I no longer thought it was important why it failed, especially since it did not seem easy for me to figure that out.
with latest code, following tests are passed:
But breaking later in the code:
…=-pie Errors occur in runtime test testCgoPprofPIE when the test is built by passing -pie to the external linker with code that was not built as PIC. This occurs on ppc64le because non-PIC is the default, and fails only on newer distros where the address range used for programs is high enough to cause relocation overflow. This test should be built with -buildmode=pie since that correctly generates PIC with -pie. Related issues are #21954 and #22126. Updates #22459 Change-Id: Ib641440bc9f94ad2b97efcda14a4b482647be8f7 Reviewed-on: https://go-review.googlesource.com/73970 Run-TryBot: Lynn Boger <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com> Reviewed-by: Ian Lance Taylor <firstname.lastname@example.org>