Commit 9efc46f1 authored by Joe Sylve's avatar Joe Sylve Committed by Russ Cox

cmd/go: -buildmode=c-shared should work on darwin/386

* Enable c-shared buildmode on darwin/386
* dyld does not support text relocation on i386. Add -read_only_relocs suppress flag to linker

Fixes #13904

Change-Id: I9adbd20d3f36ce9bbccf1bffb746b391780d088f
Reviewed-on: https://go-review.googlesource.com/18500Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 4206e9d3
......@@ -27,7 +27,7 @@ fi
# Directory where cgo headers and outputs will be installed.
# The installation directory format varies depending on the platform.
installdir=pkg/${goos}_${goarch}_testcshared_shared
if [ "${goos}/${goarch}" == "darwin/amd64" ]; then
if [ "${goos}" == "darwin" ]; then
installdir=pkg/${goos}_${goarch}_testcshared
fi
......
......@@ -656,7 +656,7 @@ func (t *tester) supportedBuildmode(mode string) bool {
case "c-shared":
switch pair {
case "linux-386", "linux-amd64", "linux-arm", "linux-arm64",
"darwin-amd64",
"darwin-amd64", "darwin-386",
"android-arm", "android-arm64", "android-386":
return true
}
......
......@@ -354,7 +354,7 @@ func buildModeInit() {
case "linux/amd64", "linux/arm", "linux/arm64", "linux/386",
"android/amd64", "android/arm", "android/arm64", "android/386":
codegenArg = "-shared"
case "darwin/amd64":
case "darwin/amd64", "darwin/386":
default:
fatalf("-buildmode=c-shared not supported on %s\n", platform)
}
......
......@@ -1068,7 +1068,7 @@ func hostlink() {
argv = append(argv, "-pie")
case BuildmodeCShared:
if HEADTYPE == obj.Hdarwin {
argv = append(argv, "-dynamiclib")
argv = append(argv, "-dynamiclib", "-Wl,-read_only_relocs,suppress")
} else {
// ELF.
argv = append(argv, "-Wl,-Bsymbolic")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment