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/cgo: fails to parse object file generated by clang -flto #46295

Closed
ianlancetaylor opened this issue May 20, 2021 · 4 comments
Closed

cmd/cgo: fails to parse object file generated by clang -flto #46295

ianlancetaylor opened this issue May 20, 2021 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ianlancetaylor
Copy link
Contributor

On tip, on linux-amd64, in the misc/swig/callback directory, running this command

CC=clang CGO_CFLAGS="-g -O2 -flto" CGO_LDFLAGS="-flto" go test -v

fails as follows:

# misc/swig/callback
cgo: cannot parse gcc output $WORK/b059//_cgo_.o as ELF, Mach-O, PE, XCOFF object
FAIL	misc/swig/callback [build failed]

At least when using clang, cgo has to disable -flto when it compiles the object, because cgo is unable to parse the byte code generated by clang.

@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label May 20, 2021
@ianlancetaylor ianlancetaylor added this to the Go1.17 milestone May 20, 2021
@ianlancetaylor ianlancetaylor self-assigned this May 20, 2021
@MrQubo
Copy link

MrQubo commented May 21, 2021

Same with gcc.

@MrQubo
Copy link

MrQubo commented May 21, 2021

Might be a duplicate of #43505.

@gopherbot
Copy link

Change https://golang.org/cl/322614 mentions this issue: cmd/link, cmd/cgo: support -flto in CFLAGS

@gopherbot
Copy link

Change https://golang.org/cl/324049 mentions this issue: cmd/link: move issue 43830 tests out of TestScript

gopherbot pushed a commit that referenced this issue Jun 2, 2021
These tests pass or fail depending on the exact compiler version,
which the TestScript tests don't support. Rewrite into Go.

For #43830
For #46295

Change-Id: I91b61dfe329d518e461ee56f186f0e9b42858e77
Reviewed-on: https://go-review.googlesource.com/c/go/+/324049
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
@golang golang locked and limited conversation to collaborators Jun 1, 2022
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

3 participants