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