Commit 41e9f8c4 authored by Srdjan Petrovic's avatar Srdjan Petrovic Committed by David Crawshaw

cmd: -buildmode=c-shared for linux/arm

Already supported platforms are linux/amd64 and android/arm.

Running -buildmode=c-shared on linux/arm is equivalent to:
  -ldflags "-shared" -asmflags "-shared"

Change-Id: Ifdb267f1d6508157f236be912fa369440172d161
Reviewed-on: https://go-review.googlesource.com/8895Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
parent 607d5158
...@@ -308,6 +308,7 @@ var pkgsFilter = func(pkgs []*Package) []*Package { return pkgs } ...@@ -308,6 +308,7 @@ var pkgsFilter = func(pkgs []*Package) []*Package { return pkgs }
func buildModeInit() { func buildModeInit() {
var codegenArg, ldBuildmode string var codegenArg, ldBuildmode string
platform := goos + "/" + goarch
switch buildBuildmode { switch buildBuildmode {
case "archive": case "archive":
pkgsFilter = pkgsNotMain pkgsFilter = pkgsNotMain
...@@ -322,16 +323,16 @@ func buildModeInit() { ...@@ -322,16 +323,16 @@ func buildModeInit() {
ldBuildmode = "c-archive" ldBuildmode = "c-archive"
case "c-shared": case "c-shared":
pkgsFilter = pkgsMain pkgsFilter = pkgsMain
platform := goos + "/" + goarch
switch platform { switch platform {
case "linux/amd64": case "linux/amd64":
codegenArg = "-shared"
buildGcflags = append(buildGcflags, codegenArg)
case "linux/arm":
codegenArg = "-shared"
case "android/arm": case "android/arm":
default: default:
fatalf("-buildmode=c-shared not supported on %s\n", platform) fatalf("-buildmode=c-shared not supported on %s\n", platform)
} }
if goarch == "amd64" {
codegenArg = "-shared"
}
ldBuildmode = "c-shared" ldBuildmode = "c-shared"
case "default": case "default":
ldBuildmode = "exe" ldBuildmode = "exe"
...@@ -342,11 +343,12 @@ func buildModeInit() { ...@@ -342,11 +343,12 @@ func buildModeInit() {
fatalf("buildmode=%s not supported", buildBuildmode) fatalf("buildmode=%s not supported", buildBuildmode)
} }
if buildLinkshared { if buildLinkshared {
if goarch != "amd64" || goos != "linux" { if platform != "linux/amd64" {
fmt.Fprintf(os.Stderr, "go %s: -linkshared is only supported on linux/amd64\n", flag.Args()[0]) fmt.Fprintf(os.Stderr, "go %s: -linkshared is only supported on linux/amd64\n", flag.Args()[0])
os.Exit(2) os.Exit(2)
} }
codegenArg = "-dynlink" codegenArg = "-dynlink"
buildGcflags = append(buildGcflags, codegenArg)
// TODO(mwhudson): remove -w when that gets fixed in linker. // TODO(mwhudson): remove -w when that gets fixed in linker.
buildLdflags = append(buildLdflags, "-linkshared", "-w") buildLdflags = append(buildLdflags, "-linkshared", "-w")
} }
...@@ -355,7 +357,6 @@ func buildModeInit() { ...@@ -355,7 +357,6 @@ func buildModeInit() {
} }
if codegenArg != "" { if codegenArg != "" {
buildAsmflags = append(buildAsmflags, codegenArg) buildAsmflags = append(buildAsmflags, codegenArg)
buildGcflags = append(buildGcflags, codegenArg)
if buildContext.InstallSuffix != "" { if buildContext.InstallSuffix != "" {
buildContext.InstallSuffix += "_" buildContext.InstallSuffix += "_"
} }
......
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