]> Cypherpunks repositories - gostls13.git/commit
gc, ld: detect stale or incompatible object files
authorRuss Cox <rsc@golang.org>
Thu, 3 Feb 2011 18:51:43 +0000 (13:51 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 3 Feb 2011 18:51:43 +0000 (13:51 -0500)
commit3f61184e1bec975b91ac17295695c5582d241c5e
treec4f32c0b4773decd15ff091662af480fddc56394
parenta6736cae30a707794db3d418c75aec2a2554b1e5
gc, ld: detect stale or incompatible object files

The object files begin with a header that is

        $GOARCH

on a line by itself.  This CL changes that header to

        go object $GOOS $GOARCH release.2011-01-01 4567+

where the final two fields are the most recent release
tag and the current hg version number.

All objects imported into a Go compilation or linked into an
executable must have the same header line, and that header
line must match the compiler and linker versions.

The effect of this will be that if you update and run all.bash
and then try to link in objects compiled with an earlier version
of the compiler (or invoke the wrong version of the compiler),
you will get an error showing the different headers instead
of perhaps silent incompatibility.

Normal usage with all.bash should be unaffected, because
all.bash deletes all the object files in $GOROOT/pkg/$GOOS_$GOARCH
and cleans all intermediate object files before starting.

This change is intended to diagnose stale objects arising when
users maintaining alternate installation directories forget to
rebuild some of their files after updating.

It should help make the adoption of $GOPATH (CL 3780043)
less error-prone.

R=ken2, r
CC=golang-dev
https://golang.org/cl/4023063
14 files changed:
src/cmd/5a/lex.c
src/cmd/5c/swt.c
src/cmd/6a/lex.c
src/cmd/6c/swt.c
src/cmd/8a/lex.c
src/cmd/8c/swt.c
src/cmd/gc/align.c
src/cmd/gc/lex.c
src/cmd/gc/obj.c
src/cmd/gc/subr.c
src/cmd/gopack/ar.c
src/cmd/ld/lib.c
src/libmach/obj.c
src/version.bash