From: David Crawshaw Date: Thu, 9 Apr 2015 19:09:52 +0000 (-0400) Subject: runtime: add isarchive, set by the linker X-Git-Tag: go1.5beta1~1213 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d1b1eee280cf21c3776fdcc50d7f7721465dea68;p=gostls13.git runtime: add isarchive, set by the linker According to Go execution modes, a Go program compiled with -buildmode=c-archive has a main function, but it is ignored on run. This gives the runtime the information it needs not to run the main. I have this working with pending linker changes on darwin/amd64. Change-Id: I49bd7d65aa619ec847c464a872afa5deea7d4d30 Reviewed-on: https://go-review.googlesource.com/8701 Reviewed-by: Ian Lance Taylor Run-TryBot: David Crawshaw TryBot-Result: Gobot Gobot --- diff --git a/src/runtime/proc.go b/src/runtime/proc.go index e596cab9bd..7b6183d905 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -99,6 +99,11 @@ func main() { needUnlock = false unlockOSThread() + if isarchive { + // A program compiled with -buildmode=c-archive has a main, + // but it is not executed. + return + } main_main() if raceenabled { racefini() diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 842ebe52f5..1f4f0daec4 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -621,9 +621,12 @@ var ( cpuid_ecx uint32 cpuid_edx uint32 lfenceBeforeRdtsc bool +) - // Set by the linker when linking with -shared. - islibrary bool +// Set by the linker so the runtime can determine the buildmode. +var ( + islibrary bool // -buildmode=c-shared + isarchive bool // -buildmode=c-archive ) /*