1
0
mirror of https://github.com/golang/go synced 2024-11-12 09:50:21 -07:00

ld: fail linking if the top-level package is not main.

This makes {5,6,8}l conform to the spec more tightly.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4826063
This commit is contained in:
David Symonds 2011-08-02 07:45:04 -04:00 committed by Russ Cox
parent 3dbe10c453
commit 11e254e62c

View 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); fprint(2, "%s: %s: not package main (package %s)\n", argv0, filename, name);
nerrors++;
errorexit();
}
loadpkgdata(filename, pkg, p0, p1 - p0); loadpkgdata(filename, pkg, p0, p1 - p0);
} }