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/go: go build fails with linker error when using clang v4.0.1 #21042

Closed
OneOfOne opened this issue Jul 17, 2017 · 15 comments
Closed

cmd/go: go build fails with linker error when using clang v4.0.1 #21042

OneOfOne opened this issue Jul 17, 2017 · 15 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@OneOfOne
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

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

➤ git describe --tags
go1.9beta2-129-g504deee608

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

Arch Linux 64bit

What did you do?

$ env GOROOT_BOOTSTRAP=/usr/src/go1.4 CC=clang GOGC=off bash make.bash

Note that using CC=gcc works fine.

What did you expect to see?

Successful compile of the go toolset

What did you see instead?

............
cmd/vet
# runtime/cgo
/usr/bin/ld: -r and -pie may not be used together
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
cmd/go/internal/envcmd
............
@ALTree
Copy link
Member

ALTree commented Jul 17, 2017

The equivalent GCC issue was #20276. It looks like the fix (CL 18359), which was also backported to go1.4-bootstrap (CL 42910), does not cover and/or fails with clang.

@ALTree ALTree added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 17, 2017
@ALTree ALTree changed the title runtime/cgo: can't compile Go with clang v4.0.1 build: go1.4-bootstrap build fails with linker error when using clang v4.0.1 Jul 17, 2017
@ALTree ALTree changed the title build: go1.4-bootstrap build fails with linker error when using clang v4.0.1 go1.4-bootstrap build fails with linker error when using clang v4.0.1 Jul 17, 2017
@ALTree
Copy link
Member

ALTree commented Jul 17, 2017

cc @ianlancetaylor

@ALTree
Copy link
Member

ALTree commented Jul 17, 2017

@OneOfOne I assume you are using the latest go1.4 bootstrap archive, i.e. go1.4-bootstrap-20170531.tar.gz.

@ALTree ALTree added this to the Unreleased milestone Jul 17, 2017
@OneOfOne
Copy link
Contributor Author

OneOfOne commented Jul 17, 2017

@ALTree I'm using the release-branch.go1.4 branch, trying to recompile it however absolutely fails, with both clang and gcc.

https://gist.github.com/OneOfOne/a9116d4c85c32141282fcf9a2973fbd2

edit:

Note that this is a separate issue, I still can't build go with clang even with go1.8 as bootstrap.

@ALTree
Copy link
Member

ALTree commented Jul 17, 2017

Ok so the clang issue is the -r and -pie may not be used together issue, already fixed for GCC (see my comment above), and it's the topic of this issue.

Can you file another issue for the other problem? The fact that compiling go1.4 bootstrap fails with

# net
cannot load DWARF output from $WORK/net/_obj//_cgo_.o: decoding dwarf section info at offset 0x4: unsupported version 0
# os/user
cannot load DWARF output from $WORK/os/user/_obj//_cgo_.o: decoding dwarf section info at offset 0x4: unsupported version 0

on your system, even with GCC. Please include system info and the gcc version in the report.

@ALTree
Copy link
Member

ALTree commented Jul 17, 2017

I still can't build go with clang even with go1.8 as bootstrap.

Wait, does this also affect go1.8? i.e. you can't build go1.8 from source with clang?

EDIT: ah yes I get it now. Sorry for the misunderstanding.

@ALTree ALTree modified the milestones: Go1.10, Unreleased Jul 17, 2017
@ALTree ALTree changed the title go1.4-bootstrap build fails with linker error when using clang v4.0.1 go build fails with linker error when using clang v4.0.1 Jul 17, 2017
@OneOfOne
Copy link
Contributor Author

@ALTree I hadn't tried until you mentioned it, no I can't build 1.8 from source either.

@ianlancetaylor
Copy link
Contributor

Does clang support a -no-pie option?

@ALTree
Copy link
Member

ALTree commented Jul 18, 2017

@ianlancetaylor looks like it does, but it's called -nopie (link: https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-nopie)

@jessfraz jessfraz changed the title go build fails with linker error when using clang v4.0.1 cmd/go: go build fails with linker error when using clang v4.0.1 Jul 18, 2017
@ianlancetaylor
Copy link
Contributor

Well, that sucks. This is not an area where we need gratuitous differences.

@gopherbot
Copy link

CL https://golang.org/cl/49710 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/49711 mentions this issue.

@ianlancetaylor
Copy link
Contributor

Does https://golang.org/cl/49711 fix the problem? You may need 49710 too--49711 applies to Go 1.4, 49710 applies to tip.

@OneOfOne
Copy link
Contributor Author

I can confirm it fixes the problem.

gopherbot pushed a commit that referenced this issue Jul 20, 2017
This is a backport of https://golang.org/cl/49710 to the Go 1.4 branch.

Original CL description:
    GCC says -no-pie, clang says -nopie.

Updates #21042

Change-Id: I67b755ccb0149324098b79e07ee4bbc49429c44c
Reviewed-on: https://go-review.googlesource.com/49711
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
gopherbot pushed a commit that referenced this issue Jul 24, 2017
This avoids an error from clang when using -nopie during compilation,
and permits us to check that the entire build succeeds.

Updates #21042

Change-Id: I2e6c7d5c97a85c223ed3288622bbb58ce33b8774
Reviewed-on: https://go-review.googlesource.com/50874
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
gopherbot pushed a commit that referenced this issue Jul 24, 2017
This avoids an error from clang when using -nopie during compilation,
and permits us to check that the entire build succeeds.

Updates #21042

Change-Id: I2e6c7d5c97a85c223ed3288622bbb58ce33b8774
Reviewed-on: https://go-review.googlesource.com/50874
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/50874 mentions this issue: cmd/link: use full link, not compile, to test for -no-?pie

wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
This is a backport of https://golang.org/cl/49710 to the Go 1.4 branch.

Original CL description:
    GCC says -no-pie, clang says -nopie.

Updates golang#21042

Change-Id: I67b755ccb0149324098b79e07ee4bbc49429c44c
Reviewed-on: https://go-review.googlesource.com/49711
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 26, 2018
This is a backport of https://golang.org/cl/49710 to the Go 1.4 branch.

Original CL description:
    GCC says -no-pie, clang says -nopie.

Updates golang#21042

Change-Id: I67b755ccb0149324098b79e07ee4bbc49429c44c
Reviewed-on: https://go-review.googlesource.com/49711
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
This is a backport of https://golang.org/cl/49710 to the Go 1.4 branch.

Original CL description:
    GCC says -no-pie, clang says -nopie.

Updates golang#21042

Change-Id: I67b755ccb0149324098b79e07ee4bbc49429c44c
Reviewed-on: https://go-review.googlesource.com/49711
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 20, 2018
This is a backport of https://golang.org/cl/49710 to the Go 1.4 branch.

Original CL description:
    GCC says -no-pie, clang says -nopie.

Updates golang#21042

Change-Id: I67b755ccb0149324098b79e07ee4bbc49429c44c
Reviewed-on: https://go-review.googlesource.com/49711
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Jul 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants