]> Cypherpunks repositories - gostls13.git/commitdiff
ld: fail linking if the top-level package is not main.
authorDavid Symonds <dsymonds@golang.org>
Tue, 2 Aug 2011 11:45:04 +0000 (07:45 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 2 Aug 2011 11:45:04 +0000 (07:45 -0400)
This makes {5,6,8}l conform to the spec more tightly.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4826063

src/cmd/ld/go.c

index cc0262f04077005041861a52b34291e0fb7bada8..fd7278a7b42f3986ab7a1c943c224912fa5da360 100644 (file)
@@ -148,8 +148,11 @@ ldpkg(Biobuf *f, char *pkg, int64 len, char *filename, int whence)
                                        ;
                        }
                }
-               if(strcmp(pkg, "main") == 0 && strcmp(name, "main") != 0)
+               if(strcmp(pkg, "main") == 0 && strcmp(name, "main") != 0) {
                        fprint(2, "%s: %s: not package main (package %s)\n", argv0, filename, name);
+                       nerrors++;
+                       errorexit();
+               }
                loadpkgdata(filename, pkg, p0, p1 - p0);
        }