Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: go 1.8 tests fail in "internal linking of -buildmode=pie" #19132

Closed
lfam opened this issue Feb 16, 2017 · 8 comments

Comments

Projects
None yet
7 participants
@lfam
Copy link

commented Feb 16, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.4.3 linux/amd64

I'm using this to build Go 1.8 within GNU Guix. I've attached a copy of the build's environment variables.
environment-variables.txt

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/gnu/store/940bfsfyjfjx3nml9i1kazc451wmkcmp-go-1.4.3"
GOTOOLDIR="/gnu/store/940bfsfyjfjx3nml9i1kazc451wmkcmp-go-1.4.3/pkg/tool/linux_amd64"
CC="/gnu/store/y1g6991kxvdk4vxhsq07r5saww30v8dq-gcc-4.9.4/bin/gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

What did you do?

I tried building Go 1.8 in GNU Guix. I applied the patch found below to a Guix source tree [0] and tried to build Go 1.8.

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 9d8dcda54..376bedb5f 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -196,11 +196,11 @@ garbage collection, various safety features and in the style of communicating
 sequential processes (CSP) concurrent programming features added.")
     (license license:bsd-3)))
 
-(define-public go-1.7
+(define-public go-1.8
   (package
     (inherit go-1.4)
     (name "go")
-    (version "1.7.4")
+    (version "1.8")
     (source
      (origin
        (method url-fetch)
@@ -208,7 +208,7 @@ sequential processes (CSP) concurrent programming features added.")
                            name version ".src.tar.gz"))
        (sha256
         (base32
-         "1k0lnsk5i9swi209wh535lpnpczsh6l8m1pfncmilrdsx48r262c"))))
+         "15imc9ffzdblgdccrjmkg45n0lp23py76v905w4yfjxlhzsnas20"))))
     (arguments
      (substitute-keyword-arguments (package-arguments go-1.4)
        ((#:phases phases)
@@ -373,4 +373,4 @@ sequential processes (CSP) concurrent programming features added.")
      `(("go" ,go-1.4)
        ,@(package-native-inputs go-1.4)))))
 
-(define-public go go-1.7)
+(define-public go go-1.8)

What did you expect to see?

I expected to build Go 1.8 and pass the test suite, excluding tests that are known to fail in the Guix build environment.

What did you see instead?

The test suite fails during "internal linking of -buildmode=pie", specifically like this:

##### internal linking of -buildmode=pie
fork/exec /tmp/guix-build-go-1.8.drv-0/go-build500076877/reflect/_test/reflect.test: no such file or directory
FAIL	reflect	0.001s
2017/02/1

I've attached the full build log.

go-1.8-build-log.txt

It appears to be the same sort of failure noticed by a Nix user (Guix and Nix are very similar build environments):
NixOS/nixpkgs#20082

[0]
https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/golang.scm

@ianlancetaylor ianlancetaylor changed the title go 1.8 tests fail in "internal linking of -buildmode=pie" cmd/link: go 1.8 tests fail in "internal linking of -buildmode=pie" Feb 17, 2017

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Feb 17, 2017

At this point the Go tools have been installed. What do you see if you run

go test reflect -short -buildmode=pie -ldflags=-linkmode=internal

@ianlancetaylor ianlancetaylor added this to the Go1.8.1 milestone Feb 17, 2017

@ixmatus

This comment has been minimized.

Copy link

commented Mar 6, 2017

@lfam in nixpkgs#23122 we've have a patch for stripping out the conditional responsible for adding the test for internal linking of PIE binaries.

@trofi

This comment has been minimized.

Copy link

commented Mar 11, 2017

@ianlancetaylor , does not output much more than that:

# go test reflect -short -buildmode=pie -ldflags=-linkmode=internal
fork/exec /tmp/guix-build-go-1.8.drv-0/go-build562443594/reflect/_test/reflect.test: no such file or directory
FAIL    reflect 0.001s

Works without -buildmode=pie

# go test reflect -short -ldflags=-linkmode=internal               
ok      reflect 0.120s
@trofi

This comment has been minimized.

Copy link

commented Mar 11, 2017

@lfam , I've poked at it a bit more and came to the conclusion it's not a golang problem.

no such file or directory error comes from the fact that guix does not provide /lib64/ld-linux-x86-64.so.2. Any attempts to run such linked binaries will lead to this error. guix build recipe patched all occurences of /lib/ld-linux... to $(glibc-prefix)/lib/ld-linux... for go-1.7.5:

  (substitute* (find-files "cmd" "asm.c")
    (("/lib/ld-linux.*\\.so\\.[0-9]") loader))

For go-1.8 you need to update dynamic linker path in new arch-specific directories:

./go/src/cmd/link/internal/amd64/obj.go:        ld.Thearch.Linuxdynld = "/lib64/ld-linux-x86-64.so.2"

Here is a seemingly working patch for guix recipe:

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 4bb54f031..8ddb13d69 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -136,6 +136,6 @@
                (substitute* "time/zoneinfo_unix.go"
                  (("/usr/share/zoneinfo/") tzdata-path))
-               (substitute* (find-files "cmd" "asm.c")
-                 (("/lib/ld-linux.*\\.so\\.[0-9]") loader))
+               (substitute* (find-files "cmd" "\\.go")
+                 (("/lib(64)?/ld-linux.*\\.so\\.[0-9]") loader))
                #t)))

@@ -197,9 +197,9 @@ sequential processes (CSP) concurrent programming features added.")
     (license license:bsd-3)))

-(define-public go-1.7
+(define-public go-1.8
   (package
     (inherit go-1.4)
     (name "go")
-    (version "1.7.5")
+    (version "1.8")
     (source
      (origin
@@ -209,5 +209,5 @@ sequential processes (CSP) concurrent programming features added.")
        (sha256
         (base32
-         "058q57zmi23rflingzhy1b87yl69mb62ql2psfxqr7q7l89lb0sf"))))
+         "15imc9ffzdblgdccrjmkg45n0lp23py76v905w4yfjxlhzsnas20"))))
     (arguments
      (substitute-keyword-arguments (package-arguments go-1.4)
@@ -363,3 +363,3 @@ sequential processes (CSP) concurrent programming features added.")
        ,@(package-native-inputs go-1.4)))))

-(define-public go go-1.7)
+(define-public go go-1.8)

What go could do for guix here is to add a knob to pass a prefix to dynamic linker at bootstrap time.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Mar 13, 2017

What go could do for guix here is to add a knob to pass a prefix to dynamic linker at bootstrap time.

This should already work:

GO_LDFLAGS=-I=/path/to/interpreter

I can't tell whether there is anything else we need to do here.

@aclements

This comment has been minimized.

Copy link
Member

commented Mar 21, 2017

@ianlancetaylor, ping. Should this issue be closed?

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Mar 21, 2017

Yes, closing because I don't see anything we can reasonably change in Go. Please comment if you disagree.

@rsc rsc removed this from the Go1.8.1 milestone Apr 5, 2017

@rsc

This comment has been minimized.

Copy link
Contributor

commented Apr 5, 2017

No bug no milestone.

@golang golang locked and limited conversation to collaborators Apr 5, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.