Commit 11e254e6 authored by David Symonds's avatar David Symonds Committed by Russ Cox

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
parent 3dbe10c4
...@@ -148,8 +148,11 @@ ldpkg(Biobuf *f, char *pkg, int64 len, char *filename, int whence) ...@@ -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);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment