]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile, cmd/go, cmd/link: enable -buildmode=shared and related flags on linux/386
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Tue, 27 Oct 2015 03:39:00 +0000 (16:39 +1300)
committerMichael Hudson-Doyle <michael.hudson@canonical.com>
Wed, 28 Oct 2015 01:21:54 +0000 (01:21 +0000)
Change-Id: If3417135ca474468a480b08cf46334fda28f79b4
Reviewed-on: https://go-review.googlesource.com/16345
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/compile/internal/gc/lex.go
src/cmd/go/build.go
src/cmd/link/internal/ld/lib.go

index 50885774eb3ef20d4ab5d70a990ff1d27337e1b0..318a538c1b702f0165edd04308124fed80a51932 100644 (file)
@@ -226,7 +226,7 @@ func Main() {
        if Thearch.Thechar == '6' {
                obj.Flagcount("largemodel", "generate code that assumes a large memory model", &flag_largemodel)
        }
-       if Thearch.Thechar == '6' || Thearch.Thechar == '9' {
+       if Thearch.Thechar == '6' || Thearch.Thechar == '8' || Thearch.Thechar == '9' {
                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)
index c2be1351ebe75877abbc58d838142332588c335e..08d84adf62f719a015d89713189662a3fe85b156 100644 (file)
@@ -387,7 +387,8 @@ func buildModeInit() {
                        codegenArg = "-fPIC"
                } else {
                        switch platform {
-                       case "linux/amd64":
+                       case "linux/386", "linux/amd64":
+                               buildAsmflags = append(buildAsmflags, "-D=shared=1")
                        default:
                                fatalf("-buildmode=shared not supported on %s\n", platform)
                        }
@@ -404,9 +405,11 @@ func buildModeInit() {
                if gccgo {
                        codegenArg = "-fPIC"
                } else {
-                       if platform != "linux/amd64" {
-                               fmt.Fprintf(os.Stderr, "go %s: -linkshared is only supported on linux/amd64\n", flag.Args()[0])
-                               os.Exit(2)
+                       switch platform {
+                       case "linux/386", "linux/amd64":
+                               buildAsmflags = append(buildAsmflags, "-D=shared=1")
+                       default:
+                               fatalf("-buildmode=shared not supported on %s\n", platform)
                        }
                        codegenArg = "-dynlink"
                        // TODO(mwhudson): remove -w when that gets fixed in linker.
index a2f70cbd6ff77032c27e8dde51aac2e73d86bee0..b97cf0fe58f251e02a2715919d5a3fa6f998c76f 100644 (file)
@@ -321,7 +321,7 @@ func (mode *BuildMode) Set(s string) error {
                }
                *mode = BuildmodeCShared
        case "shared":
-               if goos != "linux" || (goarch != "amd64" && goarch != "arm") {
+               if goos != "linux" || (goarch != "386" && goarch != "amd64" && goarch != "arm") {
                        return badmode()
                }
                *mode = BuildmodeShared