Skip to content

cmd/gc: "unexpected GOT reloc" error calling Go functions from C #6661

Closed
@gopherbot

Description

@gopherbot

by [email protected]:

What steps will reproduce the problem?

Unfortunately, I have not been able to create a simple example for this.  Instead, I can
only offer the information on this github issue: 
moovweb/gokogiri#51

To reproduce the error (hopefully!) perform these steps in a Darwin machine:
1) go get -u github.com/moovweb/gokogiri
2) cd $GOPATH/src/github.com/moovweb/gokogiri/xpath
3) go test .

For most Darwin machines, the error should show up, but there's been a couple where the
tests run successfully.

The gist of the problem is we have a Go function that we're exporting, then in embedded
c code in a different file on the same package, we try to declare the header for that
function and use it, however, when we do, we get the below listed compile time error.

The odd thing is that we're doing this with a bunch of different functions, but the only
one that complains is exec_xpath_function.  Commenting only the usage of that functions
makes the compiler happy.

What is the expected output?
To compile normally.

What do you see instead?
gokogiri/xpath(__TEXT/__text): unexpected GOT reloc for non-dynamic symbol
exec_xpath_function

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

Which operating system are you using?
Darwin

Which version are you using?  (run 'go version')
Fails in all go versions tried, go1.0.3, go1.1, go1.2rc2

There's a lot more info in the github issue.  Basically this only seems to happen on
certain Darwin systems, not all.

Here are the specs for a Darwin system where the error is found:

$ clang --version
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin10.8.0
Thread model: posix

$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: Mac OS X Server 10.6.8 (10K549)
      Server Configuration: Advanced
      Kernel Version: Darwin 10.8.0
      Boot Volume: Server HD
      Boot Mode: Normal
      Computer Name: computer
      User Name: user (user)
      Secure Virtual Memory: Not Enabled
      64-bit Kernel and Extensions: Yes
      Time since boot: 34 days 3:36


And the specs for a system where the error does NOT appear (aka, compiles normally):

$ clang --version
Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: Mac OS X 10.7.5 (11G63)
      Kernel Version: Darwin 11.4.2
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: computer
      User Name: user (user)
      Secure Virtual Memory: Enabled
      64-bit Kernel and Extensions: Yes
      Time since boot: 2 days 16:08

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions