mirror of
https://github.com/golang/go
synced 2024-11-25 10:57:58 -07:00
cmd/dist, cmd/ld: GO_EXTLINK_ENABLED=0 defaults to -linkmode=internal
Change build system to set GO_EXTLINK_ENABLED=0 by default for OS X 10.6, since the system linker has a bug and can not handle the object files generated by 6l. Fixes #5130. R=golang-dev, r CC=golang-dev https://golang.org/cl/8183043
This commit is contained in:
parent
461e7b7d40
commit
3197be4807
@ -291,6 +291,7 @@ extern char* getgoroot(void);
|
|||||||
extern char* getgoversion(void);
|
extern char* getgoversion(void);
|
||||||
extern char* getgoarm(void);
|
extern char* getgoarm(void);
|
||||||
extern char* getgo386(void);
|
extern char* getgo386(void);
|
||||||
|
extern char* getgoextlinkenabled(void);
|
||||||
|
|
||||||
extern char* mktempdir(void);
|
extern char* mktempdir(void);
|
||||||
extern void removeall(char*);
|
extern void removeall(char*);
|
||||||
|
@ -136,6 +136,11 @@ main(int argc, char *argv[])
|
|||||||
if(argc != 1)
|
if(argc != 1)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
// getgoextlinkenabled is based on GO_EXTLINK_ENABLED when
|
||||||
|
// Go was built; see ../../make.bash.
|
||||||
|
if(linkmode == LinkAuto && strcmp(getgoextlinkenabled(), "0") == 0)
|
||||||
|
linkmode = LinkInternal;
|
||||||
|
|
||||||
if(linkmode == LinkExternal) {
|
if(linkmode == LinkExternal) {
|
||||||
diag("only -linkmode=internal is supported");
|
diag("only -linkmode=internal is supported");
|
||||||
errorexit();
|
errorexit();
|
||||||
|
@ -133,11 +133,16 @@ main(int argc, char *argv[])
|
|||||||
if(HEADTYPE == -1)
|
if(HEADTYPE == -1)
|
||||||
HEADTYPE = headtype(goos);
|
HEADTYPE = headtype(goos);
|
||||||
|
|
||||||
|
// getgoextlinkenabled is based on GO_EXTLINK_ENABLED when
|
||||||
|
// Go was built; see ../../make.bash.
|
||||||
|
if(linkmode == LinkAuto && strcmp(getgoextlinkenabled(), "0") == 0)
|
||||||
|
linkmode = LinkInternal;
|
||||||
|
|
||||||
switch(HEADTYPE) {
|
switch(HEADTYPE) {
|
||||||
default:
|
default:
|
||||||
if(linkmode == LinkAuto)
|
if(linkmode == LinkAuto)
|
||||||
linkmode = LinkInternal;
|
linkmode = LinkInternal;
|
||||||
if(linkmode == LinkExternal)
|
if(linkmode == LinkExternal && strcmp(getgoextlinkenabled(), "1") != 0)
|
||||||
sysfatal("cannot use -linkmode=external with -H %s", headstr(HEADTYPE));
|
sysfatal("cannot use -linkmode=external with -H %s", headstr(HEADTYPE));
|
||||||
break;
|
break;
|
||||||
case Hdarwin:
|
case Hdarwin:
|
||||||
|
@ -139,11 +139,16 @@ main(int argc, char *argv[])
|
|||||||
if(HEADTYPE == -1)
|
if(HEADTYPE == -1)
|
||||||
HEADTYPE = headtype(goos);
|
HEADTYPE = headtype(goos);
|
||||||
|
|
||||||
|
// getgoextlinkenabled is based on GO_EXTLINK_ENABLED when
|
||||||
|
// Go was built; see ../../make.bash.
|
||||||
|
if(linkmode == LinkAuto && strcmp(getgoextlinkenabled(), "0") == 0)
|
||||||
|
linkmode = LinkInternal;
|
||||||
|
|
||||||
switch(HEADTYPE) {
|
switch(HEADTYPE) {
|
||||||
default:
|
default:
|
||||||
if(linkmode == LinkAuto)
|
if(linkmode == LinkAuto)
|
||||||
linkmode = LinkInternal;
|
linkmode = LinkInternal;
|
||||||
if(linkmode == LinkExternal)
|
if(linkmode == LinkExternal && strcmp(getgoextlinkenabled(), "1") != 0)
|
||||||
sysfatal("cannot use -linkmode=external with -H %s", headstr(HEADTYPE));
|
sysfatal("cannot use -linkmode=external with -H %s", headstr(HEADTYPE));
|
||||||
break;
|
break;
|
||||||
case Hdarwin:
|
case Hdarwin:
|
||||||
|
1
src/cmd/dist/a.h
vendored
1
src/cmd/dist/a.h
vendored
@ -72,6 +72,7 @@ extern char *gohostos;
|
|||||||
extern char *goos;
|
extern char *goos;
|
||||||
extern char *goroot;
|
extern char *goroot;
|
||||||
extern char *goroot_final;
|
extern char *goroot_final;
|
||||||
|
extern char *goextlinkenabled;
|
||||||
extern char *goversion;
|
extern char *goversion;
|
||||||
extern char *workdir;
|
extern char *workdir;
|
||||||
extern char *tooldir;
|
extern char *tooldir;
|
||||||
|
10
src/cmd/dist/build.c
vendored
10
src/cmd/dist/build.c
vendored
@ -20,6 +20,7 @@ char *goarm;
|
|||||||
char *go386;
|
char *go386;
|
||||||
char *goroot = GOROOT_FINAL;
|
char *goroot = GOROOT_FINAL;
|
||||||
char *goroot_final = GOROOT_FINAL;
|
char *goroot_final = GOROOT_FINAL;
|
||||||
|
char *goextlinkenabled = "";
|
||||||
char *workdir;
|
char *workdir;
|
||||||
char *tooldir;
|
char *tooldir;
|
||||||
char *gochar;
|
char *gochar;
|
||||||
@ -139,6 +140,13 @@ init(void)
|
|||||||
bprintf(&b, "%c", gochars[i]);
|
bprintf(&b, "%c", gochars[i]);
|
||||||
gochar = btake(&b);
|
gochar = btake(&b);
|
||||||
|
|
||||||
|
xgetenv(&b, "GO_EXTLINK_ENABLED");
|
||||||
|
if(b.len > 0) {
|
||||||
|
goextlinkenabled = btake(&b);
|
||||||
|
if(!streq(goextlinkenabled, "0") && !streq(goextlinkenabled, "1"))
|
||||||
|
fatal("unknown $GO_EXTLINK_ENABLED %s", goextlinkenabled);
|
||||||
|
}
|
||||||
|
|
||||||
xsetenv("GOROOT", goroot);
|
xsetenv("GOROOT", goroot);
|
||||||
xsetenv("GOARCH", goarch);
|
xsetenv("GOARCH", goarch);
|
||||||
xsetenv("GOOS", goos);
|
xsetenv("GOOS", goos);
|
||||||
@ -922,6 +930,8 @@ install(char *dir)
|
|||||||
vadd(&compile, bprintf(&b, "GOARM=\"%s\"", goarm));
|
vadd(&compile, bprintf(&b, "GOARM=\"%s\"", goarm));
|
||||||
vadd(&compile, "-D");
|
vadd(&compile, "-D");
|
||||||
vadd(&compile, bprintf(&b, "GO386=\"%s\"", go386));
|
vadd(&compile, bprintf(&b, "GO386=\"%s\"", go386));
|
||||||
|
vadd(&compile, "-D");
|
||||||
|
vadd(&compile, bprintf(&b, "GO_EXTLINK_ENABLED=\"%s\"", goextlinkenabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
// gc/lex.c records the GOEXPERIMENT setting used during the build.
|
// gc/lex.c records the GOEXPERIMENT setting used during the build.
|
||||||
|
13
src/cmd/dist/unix.c
vendored
13
src/cmd/dist/unix.c
vendored
@ -698,6 +698,19 @@ main(int argc, char **argv)
|
|||||||
if(strcmp(gohostarch, "arm") == 0)
|
if(strcmp(gohostarch, "arm") == 0)
|
||||||
maxnbg = 1;
|
maxnbg = 1;
|
||||||
|
|
||||||
|
// The OS X 10.6 linker does not support external
|
||||||
|
// linking mode; see
|
||||||
|
// https://code.google.com/p/go/issues/detail?id=5130 .
|
||||||
|
// The mapping from the uname release field to the OS X
|
||||||
|
// version number is complicated, but basically 10 or under is
|
||||||
|
// OS X 10.6 or earlier.
|
||||||
|
if(strcmp(gohostos, "darwin") == 0) {
|
||||||
|
if(uname(&u) < 0)
|
||||||
|
fatal("uname: %s", strerror(errno));
|
||||||
|
if(u.release[1] == '.' || hasprefix(u.release, "10"))
|
||||||
|
goextlinkenabled = "0";
|
||||||
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
xmain(argc, argv);
|
xmain(argc, argv);
|
||||||
bfree(&b);
|
bfree(&b);
|
||||||
|
@ -51,3 +51,9 @@ getgo386(void)
|
|||||||
{
|
{
|
||||||
return defgetenv("GO386", GO386);
|
return defgetenv("GO386", GO386);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
getgoextlinkenabled(void)
|
||||||
|
{
|
||||||
|
return GO_EXTLINK_ENABLED;
|
||||||
|
}
|
||||||
|
@ -30,6 +30,11 @@
|
|||||||
# to include all cgo related files, .c and .go file with "cgo"
|
# to include all cgo related files, .c and .go file with "cgo"
|
||||||
# build directive, in the build. Set it to 0 to ignore them.
|
# build directive, in the build. Set it to 0 to ignore them.
|
||||||
#
|
#
|
||||||
|
# GO_EXTLINK_ENABLED: Set to 1 to invoke the host linker when building
|
||||||
|
# packages that use cgo. Set to 0 to do all linking internally. This
|
||||||
|
# controls the default behavior of the linker's -linkmode option. The
|
||||||
|
# default value depends on the system.
|
||||||
|
#
|
||||||
# CC: Command line to run to get at host C compiler.
|
# CC: Command line to run to get at host C compiler.
|
||||||
# Default is "gcc". Also supported: "clang".
|
# Default is "gcc". Also supported: "clang".
|
||||||
|
|
||||||
|
10
src/run.bash
10
src/run.bash
@ -83,10 +83,18 @@ set -e
|
|||||||
go test -ldflags '-linkmode=auto'
|
go test -ldflags '-linkmode=auto'
|
||||||
go test -ldflags '-linkmode=internal'
|
go test -ldflags '-linkmode=internal'
|
||||||
case "$GOHOSTOS-$GOARCH" in
|
case "$GOHOSTOS-$GOARCH" in
|
||||||
darwin-386 | darwin-amd64 | openbsd-386 | openbsd-amd64)
|
openbsd-386 | openbsd-amd64)
|
||||||
# test linkmode=external, but __thread not supported, so skip testtls.
|
# test linkmode=external, but __thread not supported, so skip testtls.
|
||||||
go test -ldflags '-linkmode=external'
|
go test -ldflags '-linkmode=external'
|
||||||
;;
|
;;
|
||||||
|
darwin-386 | darwin-amd64)
|
||||||
|
# linkmode=external fails on OS X 10.6 and earlier == Darwin
|
||||||
|
# 10.8 and earlier.
|
||||||
|
case $(uname -r) in
|
||||||
|
[0-9].* | 10.*) ;;
|
||||||
|
*) go test -ldflags '-linkmode=external' ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
freebsd-386 | freebsd-amd64 | linux-386 | linux-amd64 | netbsd-386 | netbsd-amd64)
|
freebsd-386 | freebsd-amd64 | linux-386 | linux-amd64 | netbsd-386 | netbsd-amd64)
|
||||||
go test -ldflags '-linkmode=external'
|
go test -ldflags '-linkmode=external'
|
||||||
go test -ldflags '-linkmode=auto' ../testtls
|
go test -ldflags '-linkmode=auto' ../testtls
|
||||||
|
Loading…
Reference in New Issue
Block a user