-
Notifications
You must be signed in to change notification settings - Fork 645
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
Cannot build cgo libraries on gcc-6 systems #252
Comments
@damienmg @pmbethe09 any update here? |
Also cc'ing @alandonovan if his team has idea. |
I'll look into this. |
In Maybe we should add |
I can confirm that adding the proposed arguments (and then loading my fork with
However, I don't know enough to know if that is safe elsewhere. Let me know if there's anything I can do to provide identifying information for (my) debian stretch machine. |
Sorry for the long silence. I haven't forgotten about this one. I reproduced this issue in a Debian VM, and verified that adding -Wl,-no-pie fixes the problem on that machine. Unfortunately, adding that option breaks builds on Ubuntu 16.04 with GCC 4.8.4, and probably other builds, too. GCC fails without printing an error message or a nonzero exit code; it just doesn't produce an output. We may need to do some configuration in the repository rules to check which linker options are supported. I don't think we can have a single set of options that works everywhere. Somewhat related issue: golang/go #13937. |
Still an issue on Ubuntu 16.10: Default gcc (mean
or
And when gcc downgraded to 5:
Gives:
So I see no way to build |
After upgrading to Ubuntu 17.04, same issue. Using
|
I've just run across this issue while attempting the the Bazel build of Kubernetes. I can provide my Bazel WORKSPACE if needed, but it's a bit verbose at this point. Assuming that's not needed, on Ubuntu 17.04 using default build toolchain, the following is enough to repro this error. $ bazel build @io_kubernetes//test/... |
I'm currently working around it with:
|
except it doesn't work with people having clang-4.0 due to:
this is quite annoying since my team runs on variety of ubuntu platforms |
Possibly related https://phabricator-dot-kythe-repo.appspot.com/D1161 |
I'm successfully working around this on ubuntu 17.04 by adding this to my
|
An update: https://golang.org/cl/64793 removes the partial link step in cgo in "go build". I plan to remove this from the Bazel rules as well. This should fix this issue, since we'll no longer link with -r at any point. |
Previously cgo compiled generated .c files, along with the other C sources in a package, then partially linked them all into a single .o file which was packed into the .a file for the library. This partial linking caused problems on platforms where -pie is on by default (newer Debian and Ubuntu) because the -r flag we used conflicted. The partial link is not necessary and is being removed from "go build", so we will remove it, too. The .a file generated by the cgo cc_library rule is unpacked, and its contents are packed into the .a file for the go_library. Fixes bazelbuild#252
Previously cgo compiled generated .c files, along with the other C sources in a package, then partially linked them all into a single .o file which was packed into the .a file for the library. This partial linking caused problems on platforms where -pie is on by default (newer Debian and Ubuntu) because the -r flag we used conflicted. The partial link is not necessary and is being removed from "go build", so we will remove it, too. The .a file generated by the cgo cc_library rule is unpacked, and its contents are packed into the .a file for the go_library. Fixes #252
I've encountered the same issue reported in kubernetes/kubernetes#39819.
Repro steps
I've checked out a Cgo project, apcera/gssapi@5fb4217df13b8e6878046fe1e5c10e560e1b86dc, into vendor/github.com/apcera/gssapi.
I've then used the following minimal rule:
Error received when building
//vendor:github.com/apcera/gssapi_c
is/usr/bin/ld: -r and -pie may not be used together
.Trying to pass
clinkopts = ["--no-pie", "-Wl,-no-pie"]
sometimes doesn't help, and sometimes results incannot find "-lgcc_s"
."bleh.c" may be needed and is an empty file.
bazel clean --expunge
may be required to reproduce-lgcc_s
. Building without bleh.c and using *.go should result in the same output as long as --expunge was run between switching between GCC 4.9 and GCC 6.Cause
Quoting @mikedanese in kubernetes/kubernetes#39819 (comment):
Versions
The text was updated successfully, but these errors were encountered: