Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: option to display accumulated cgo LDFLAGS for -buildmode=c-archive/c-shared #11258
Trying to build a simple Go library that spins up an
More thorough description and full code examples are available in this StackOverflow question.
This might be related to the OSX/darwin arch as a commenter was able to get it working on Ubuntu.
Does it work if you add "-framework CoreFoundation -framework Security" to the gcc link line? Probably just before the -pthread option.
I took those options from the # cgo LDFLAGS line in crypto/x509/root_cgo_darwin.go. I don't see a way for us to add those lines to the final command line, as that is not under our control. I don't know if there is a way to avoid needing them at all. There may be Darwin-specific approaches that I am not aware of.
I started to write docs in helpBuildmode in cmd/go/help.go, but it's too horrible to make people dig into the crypto/x509 sources to figure out what options to pass. I think what we need to do is have a way for cmd/go to print out the accumulated cgo LDFLAGS from the packages added to a c-archive or c-shared build. Then people can in principle capture that at the time they build the archive/shared library (probably using a Makefile), and pass it on their final linker command line.
So, postponing until 1.7.
changed the title
cmd/link: buildmode=c-archive with net/http.Server fails to be linked against
Jan 6, 2016
As a follow up to this, there is a bigger related issue on iOS. The following functions exist on macOS but not on iOS:
So adding -framework Security doesn't help there. This means that any code that imports net/http (or anything else that uses crypto/x509) can not be used on iOS.