-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: how to pass -mmacosx-version-min=10.8 from cmd/go down to MacOS clang? #18400
Comments
What makes you think it died? It looks like it just decided there was no work to do. (Probably because the CFLAGS environment variable doesn't affect Go and/or is not part of Go's buildid signature.) Have you tried Go's I think this will work if you use the right arguments. |
@bradfitz -extldflags are passed during the linking time, it is not passed during compile time. The compatibility mark is set compile-time AFAIK. |
@bradfitz |
@bradfitz Moreover |
Does |
@bradfitz No. The library still compiled as minimum version 10.12 compatible With |
Delete your target binary and re-run the go build command with all those flags, but also include |
Updated the comment, I always use -x to see full output. And of course I deleted Below is full output. It passes -extldflags to go link, but the final
|
The output from the linker doesn't go in Anyway, I'll reopen this and let @ianlancetaylor decide whether there's a bug. If anything, the bug is that our pkg directory causes confusion and needs to be replaced with a proper cache. That is #4719. |
Have you tried setting $CGO_CFLAGS for go build?
|
You can use The Go linker also invokes dsymutil on Darwin. Perhaps that is the problem here. Try invoking the go tool with |
The reason this is happening is that there are .o files in the standard library that were not compiled with this CGO_CFLAGS setting, and they are being linked into the binary too. To force rebuilding of everything, the best approach (the one that works with go install as well) is to use a custom installsuffix, which keeps those build artifacts separate from the normal ones:
Sorry for the confusion. I expect that a future version of cmd/go that is more careful about reuse of compiled archives will end up recompiling even the standard library automatically when you set CGO_CFLAGS this way, making -installsuffix unneccessary. But for now, that's the best workaround. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.7.4 darwin/amd64
What operating system and processor architecture are you using (
go env
)?MacOS 10.12.2
What did you do?
Build a static library to be used in another project:
GOPATH=$(pwd) go install -buildmode=c-archive main
Then try to use that library in a Qt5.7 project.
What did you expect to see?
Main QTt5.7 projects builds successfully
What did you see instead?
The project build fails, because apparently the MacOS clang by default will compile with compatibility to latest OS version.
COMMENT
It is possible to specify a compatibility version when using MacOS clang++. For example here is how Qt does it with -mmacosx-version-min flag:
However I seem to be unable to pass ANY CFLAGS as then the build script dies:
The text was updated successfully, but these errors were encountered: