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: linker uses gcc even when environment variable $CC is defined to clang #5150

Closed
fsouza opened this issue Mar 28, 2013 · 6 comments
Closed
Milestone

Comments

@fsouza
Copy link
Contributor

fsouza commented Mar 28, 2013

What steps will reproduce the problem?

1. Checkout go code at tip
2. set environment variable CC=<path/to/clang>
3. run ./all.bash

What is the expected output?

Go compiles and all tests pass.

What do you see instead?

Go compiles, but some cgo tests fail. Here is the complete all.bash output:
https://gist.github.com/fsouza/5265724

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

darwin_amd64

Which version are you using?  (run 'go version')

% go version
go version devel +833bf2ef1527 Thu Mar 28 11:35:24 2013 -0700 darwin/amd64

Please provide any additional information below.

I know that neither clang nor gcc 4.8.0 are supported at the moment, but since it worked
before revision 030625a923ca
(https://code.google.com/p/go/source/detail?r=030625a923ca), I'm reporting this issue.
@robpike
Copy link
Contributor

robpike commented Mar 28, 2013

Comment 1:

Which version of OS X are you using? I just tried this on 10.8.3 and did not reproduce
the failure.
Marking as Go 1.1 assuming we can reproduce the problem.

Labels changed: added priority-soon, go1.1, removed priority-triage.

Status changed to Accepted.

@fsouza
Copy link
Contributor Author

fsouza commented Mar 28, 2013

Comment 2:

I'm on 10.8.3 too.
The failure is related to gcc 4.8.0, go won't work properly using gcc 4.8.0, but the
point is that I've defined $CC as /opt/bin/clang, so it looks like that at some point
the linker bypasses the CC environment variable.
The first entry of "gcc" in my PATH points to /opt/bin/gcc, which is gcc 4.8.0. If I put
/usr/bin/gcc (the one distributed by Apple) before it, all.bash passes. The version of
gcc should not matter when I define the compiler to be clang. Ideally, I should be able
to uninstall gcc and still comile Go with cgo support (I know that's not possible at the
moment).
Anyway, I don't believe this should be a Go 1.1 issue - unless you want Go 1.1 to
support gcc 4.8.0 for cgo builds, but that's another issue, this one is about clang
support on cgo.

@ianlancetaylor
Copy link
Contributor

Comment 3:

It does look like -rdynamic is not supported on the vanilla GCC for Darwin.
The point of the -rdynamic option is to tell the linker to make all symbols visible to
the dynamic linker.  I don't know if such an option is meaningful or required on Darwin.
Could you please see if everything works with https://golang.org/cl/8120043 ? 
Thanks.

Owner changed to @ianlancetaylor.

Status changed to Started.

@ianlancetaylor
Copy link
Contributor

Comment 4:

My change is intended to get things working with the vanilla GCC 4.8.0.
We also need to change the Go linker to permit specifying the compiler to use as the
host linker.  This is a TODO item in the sources, required for Go 1.1.

@fsouza
Copy link
Contributor Author

fsouza commented Mar 28, 2013

Comment 5:

I confirm it works with CL 8120043, using either CC=clang (I know that it's still using
gcc linker as the host linker, but now all.bash passes) or CC=gcc-4.8.0.
Thank you.

@ianlancetaylor
Copy link
Contributor

Comment 6:

This issue was closed by revision 47ec6e2.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants