]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: implicitly include math in a shared library on arm
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Thu, 3 Sep 2015 00:33:06 +0000 (12:33 +1200)
committerMichael Hudson-Doyle <michael.hudson@canonical.com>
Thu, 29 Oct 2015 00:37:32 +0000 (00:37 +0000)
In the same manner in which runtime/cgo is included on other architectures.

Change-Id: I90a5ad8585248b2566d763d33994a600508d89cb
Reviewed-on: https://go-review.googlesource.com/14221
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/go/build.go

index 30af02e40114e82ead47830e32bc0b7e108d11f6..c87cedc571dda552a671a69462cfd79a96de5de8 100644 (file)
@@ -982,7 +982,11 @@ func (b *builder) action1(mode buildMode, depMode buildMode, p *Package, looksha
 
 func (b *builder) libaction(libname string, pkgs []*Package, mode, depMode buildMode) *action {
        a := &action{}
-       if mode == modeBuild {
+       switch mode {
+       default:
+               fatalf("unrecognized mode %v", mode)
+
+       case modeBuild:
                a.f = (*builder).linkShared
                a.target = filepath.Join(b.work, libname)
                for _, p := range pkgs {
@@ -991,14 +995,15 @@ func (b *builder) libaction(libname string, pkgs []*Package, mode, depMode build
                        }
                        a.deps = append(a.deps, b.action(depMode, depMode, p))
                }
-       } else if mode == modeInstall {
+
+       case modeInstall:
                // Currently build mode shared forces external linking mode, and
-               // external linking mode forces an import of runtime/cgo. So if it
-               // was not passed on the command line and it is not present in
-               // another shared library, add it here.
-               seencgo := false
+               // external linking mode forces an import of runtime/cgo (and
+               // math on arm). So if it was not passed on the command line and
+               // it is not present in another shared library, add it here.
                _, gccgo := buildToolchain.(gccgoToolchain)
                if !gccgo {
+                       seencgo := false
                        for _, p := range pkgs {
                                seencgo = seencgo || (p.Standard && p.ImportPath == "runtime/cgo")
                        }
@@ -1018,6 +1023,28 @@ func (b *builder) libaction(libname string, pkgs []*Package, mode, depMode build
                                        pkgs = append(pkgs, p)
                                }
                        }
+                       if goarch == "arm" {
+                               seenmath := false
+                               for _, p := range pkgs {
+                                       seenmath = seenmath || (p.Standard && p.ImportPath == "math")
+                               }
+                               if !seenmath {
+                                       var stk importStack
+                                       p := loadPackage("math", &stk)
+                                       if p.Error != nil {
+                                               fatalf("load math: %v", p.Error)
+                                       }
+                                       computeStale(p)
+                                       // If math is in another shared library, then that's
+                                       // also the shared library that contains runtime, so
+                                       // something will depend on it and so math's staleness
+                                       // will be checked when processing that library.
+                                       if p.Shlib == "" || p.Shlib == libname {
+                                               pkgs = append([]*Package{}, pkgs...)
+                                               pkgs = append(pkgs, p)
+                                       }
+                               }
+                       }
                }
 
                // Figure out where the library will go.
@@ -1068,8 +1095,6 @@ func (b *builder) libaction(libname string, pkgs []*Package, mode, depMode build
                                shlibnameaction.deps = append(shlibnameaction.deps, buildAction)
                        }
                }
-       } else {
-               fatalf("unregonized mode %v", mode)
        }
        return a
 }