diff options
author | Shenghou Ma <minux@golang.org> | 2014-12-05 02:22:20 -0500 |
---|---|---|
committer | Shenghou Ma <minux@golang.org> | 2014-12-05 02:22:20 -0500 |
commit | 57231fa56130b0863b592dc8fda71cf87c947c74 (patch) | |
tree | d0de7b2dd3899f5a6f56c429c6973ac45d11c905 /src/cmd/ld/lib.c | |
parent | 99c8479cc6b9cac330eecb041e6f13479322c0d2 (diff) | |
download | go-57231fa56130b0863b592dc8fda71cf87c947c74.tar.gz |
[dev.cc] cmd/ld: finalize linkmode before determining whether to import runtime/cgo
Frankly, I don't understand how the current code could possibly work except
when every android program is using cgo. Discovered this while working on
the iOS port.
LGTM=crawshaw, rsc
R=rsc, crawshaw
CC=golang-codereviews
https://codereview.appspot.com/177470043
Diffstat (limited to 'src/cmd/ld/lib.c')
-rw-r--r-- | src/cmd/ld/lib.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c index 64608d226..925274bfd 100644 --- a/src/cmd/ld/lib.c +++ b/src/cmd/ld/lib.c @@ -202,7 +202,18 @@ loadlib(void) iscgo |= strcmp(ctxt->library[i].pkg, "runtime/cgo") == 0; objfile(ctxt->library[i].file, ctxt->library[i].pkg); } - + + if(linkmode == LinkAuto) { + if(iscgo && externalobj) + linkmode = LinkExternal; + else + linkmode = LinkInternal; + + // Force external linking for android. + if(strcmp(goos, "android") == 0) + linkmode = LinkExternal; + } + if(linkmode == LinkExternal && !iscgo) { // This indicates a user requested -linkmode=external. // The startup code uses an import of runtime/cgo to decide @@ -229,17 +240,6 @@ loadlib(void) } } - if(linkmode == LinkAuto) { - if(iscgo && externalobj) - linkmode = LinkExternal; - else - linkmode = LinkInternal; - - // Force external linking for android. - if(strcmp(goos, "android") == 0) - linkmode = LinkExternal; - } - if(linkmode == LinkInternal) { // Drop all the cgo_import_static declarations. // Turns out we won't be needing them. |