From: Michael Hudson-Doyle Date: Tue, 1 Sep 2015 02:03:38 +0000 (+1200) Subject: cmd/compile, cmd/go: generate position independent code with -buildmode=c-shared... X-Git-Tag: go1.6beta1~1179 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=876b7cc2273a64cd44c1f7932c612bdf696c27fe;p=gostls13.git cmd/compile, cmd/go: generate position independent code with -buildmode=c-shared on arm All the code was there to do this, it just wasn't hooked up. Fixes #10914 Change-Id: Ide8f9bbe50fecb5d11cd579915ee98d4c7efe403 Reviewed-on: https://go-review.googlesource.com/14142 Reviewed-by: Ian Lance Taylor --- diff --git a/src/cmd/compile/internal/gc/lex.go b/src/cmd/compile/internal/gc/lex.go index 09a44b28e6..8e762d0ed3 100644 --- a/src/cmd/compile/internal/gc/lex.go +++ b/src/cmd/compile/internal/gc/lex.go @@ -237,9 +237,11 @@ func Main() { obj.Flagcount("y", "debug declarations in canned imports (with -d)", &Debug['y']) var flag_shared int var flag_dynlink bool + if Thearch.Thechar == '6' || Thearch.Thechar == '5' { + obj.Flagcount("shared", "generate code that can be linked into a shared library", &flag_shared) + } if Thearch.Thechar == '6' { obj.Flagcount("largemodel", "generate code that assumes a large memory model", &flag_largemodel) - obj.Flagcount("shared", "generate code that can be linked into a shared library", &flag_shared) flag.BoolVar(&flag_dynlink, "dynlink", false, "support references to Go symbols defined in other shared libraries") } obj.Flagstr("cpuprofile", "write cpu profile to `file`", &cpuprofile) diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go index 0b147252ec..df74338593 100644 --- a/src/cmd/go/build.go +++ b/src/cmd/go/build.go @@ -344,12 +344,9 @@ func buildModeInit() { codegenArg = "-fPIC" } else { switch platform { - case "linux/amd64": + case "linux/amd64", "linux/arm", "android/arm": codegenArg = "-shared" - case "linux/arm": - buildAsmflags = append(buildAsmflags, "-shared") case "darwin/amd64": - case "android/arm": default: fatalf("-buildmode=c-shared not supported on %s\n", platform) }