Go patch committed: Support and use single argument go:linkname

Message ID CAOyqgcWxVOZAr7XRZjBaJm-Eh4G-Xuap5_Ty-Jei76kJipsLcA@mail.gmail.com
State New
Headers show
Series
  • Go patch committed: Support and use single argument go:linkname
Related show

Commit Message

Ian Lance Taylor Aug. 31, 2019, 3:01 a.m.
The gc compiler has started permitting go:linkname comments with a
single argument to mean that a function should be externally visible
outside the package.  This patch implements this in the Go frontend.

We also change the libgo runtime package to use it, rather than
repeating the name just to export a function.

We also remove a couple of unnecessary go:linkname comments on declarations.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 275238)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-80403eb9e95c9642ebabb4d7c43deedaa763211f
+289d94b9e6303ec74649d1f08d418300f2b4d0fd
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/gogo.cc
===================================================================
--- gcc/go/gofrontend/gogo.cc	(revision 275227)
+++ gcc/go/gofrontend/gogo.cc	(working copy)
@@ -2531,9 +2531,22 @@  Gogo::add_linkname(const std::string& go
   if (no == NULL)
     go_error_at(loc, "%s is not defined", go_name.c_str());
   else if (no->is_function())
-    no->func_value()->set_asm_name(ext_name);
+    {
+      if (ext_name.empty())
+	no->func_value()->set_is_exported_by_linkname();
+      else
+	no->func_value()->set_asm_name(ext_name);
+    }
   else if (no->is_function_declaration())
-    no->func_declaration_value()->set_asm_name(ext_name);
+    {
+      if (ext_name.empty())
+	go_error_at(loc,
+		    ("//%<go:linkname%> missing external name "
+		     "for declaration of %s"),
+		    go_name.c_str());
+      else
+	no->func_declaration_value()->set_asm_name(ext_name);
+    }
   else
     go_error_at(loc,
 		("%s is not a function; "
@@ -5465,7 +5478,8 @@  Function::Function(Function_type* type,
     calls_recover_(false), is_recover_thunk_(false), has_recover_thunk_(false),
     calls_defer_retaddr_(false), is_type_specific_function_(false),
     in_unique_section_(false), export_for_inlining_(false),
-    is_inline_only_(false), is_referenced_by_inline_(false)
+    is_inline_only_(false), is_referenced_by_inline_(false),
+    is_exported_by_linkname_(false)
 {
 }
 
@@ -6220,6 +6234,11 @@  Function::get_or_make_decl(Gogo* gogo, N
       if (this->is_referenced_by_inline_)
 	flags |= Backend::function_is_visible;
 
+      // A go:linkname directive can be used to force a function to be
+      // visible.
+      if (this->is_exported_by_linkname_)
+	flags |= Backend::function_is_visible;
+
       // If a function calls the predeclared recover function, we
       // can't inline it, because recover behaves differently in a
       // function passed directly to defer.  If this is a recover
Index: gcc/go/gofrontend/gogo.h
===================================================================
--- gcc/go/gofrontend/gogo.h	(revision 274890)
+++ gcc/go/gofrontend/gogo.h	(working copy)
@@ -547,7 +547,9 @@  class Gogo
   { this->file_block_names_[name] = location; }
 
   // Add a linkname, from the go:linkname compiler directive.  This
-  // changes the externally visible name of go_name to be ext_name.
+  // changes the externally visible name of GO_NAME to be EXT_NAME.
+  // If EXT_NAME is the empty string, GO_NAME is unchanged, but the
+  // symbol is made publicly visible.
   void
   add_linkname(const std::string& go_name, bool is_exported,
 	       const std::string& ext_name, Location location);
@@ -1359,6 +1361,11 @@  class Function
   set_asm_name(const std::string& asm_name)
   { this->asm_name_ = asm_name; }
 
+  // Mark this symbol as exported by a linkname directive.
+  void
+  set_is_exported_by_linkname()
+  { this->is_exported_by_linkname_ = true; }
+
   // Return the pragmas for this function.
   unsigned int
   pragmas() const
@@ -1706,6 +1713,9 @@  class Function
   // True if this function is referenced from an inlined body that
   // will be put into the export data.
   bool is_referenced_by_inline_ : 1;
+  // True if we should make this function visible to other packages
+  // because of a go:linkname directive.
+  bool is_exported_by_linkname_ : 1;
 };
 
 // A snapshot of the current binding state.
Index: gcc/go/gofrontend/lex.cc
===================================================================
--- gcc/go/gofrontend/lex.cc	(revision 274614)
+++ gcc/go/gofrontend/lex.cc	(working copy)
@@ -1996,7 +1996,7 @@  Lex::skip_cpp_comment()
 
 	      while (ps < pend && *ps != ' ' && *ps != '\t')
 		++ps;
-	      if (ps < pend)
+	      if (ps <= pend)
 		go_name = std::string(pg, ps - pg);
 	      while (ps < pend && (*ps == ' ' || *ps == '\t'))
 		++ps;
@@ -2015,8 +2015,8 @@  Lex::skip_cpp_comment()
 	      ext_name.clear();
 	    }
 	}
-      if (go_name.empty() || ext_name.empty())
-	go_error_at(loc, "usage: %<//go:linkname%> localname linkname");
+      if (go_name.empty())
+	go_error_at(loc, "usage: %<//go:linkname%> localname [linkname]");
       else
 	{
 	  if (this->linknames_ == NULL)
Index: gcc/go/gofrontend/lex.h
===================================================================
--- gcc/go/gofrontend/lex.h	(revision 274614)
+++ gcc/go/gofrontend/lex.h	(working copy)
@@ -380,7 +380,7 @@  class Lex
 
   struct Linkname
   {
-    std::string ext_name;	// External name.
+    std::string ext_name;	// External name; empty to just export.
     bool is_exported;		// Whether the internal name is exported.
     Location loc;		// Location of go:linkname directive.
 
Index: libgo/go/runtime/alg.go
===================================================================
--- libgo/go/runtime/alg.go	(revision 274169)
+++ libgo/go/runtime/alg.go	(working copy)
@@ -10,44 +10,43 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname memhash0 runtime.memhash0
-//go:linkname memhash8 runtime.memhash8
-//go:linkname memhash16 runtime.memhash16
-//go:linkname memhash32 runtime.memhash32
-//go:linkname memhash64 runtime.memhash64
-//go:linkname memhash128 runtime.memhash128
-//go:linkname strhash runtime.strhash
-//go:linkname f32hash runtime.f32hash
-//go:linkname f64hash runtime.f64hash
-//go:linkname c64hash runtime.c64hash
-//go:linkname c128hash runtime.c128hash
-//go:linkname interhash runtime.interhash
-//go:linkname nilinterhash runtime.nilinterhash
-//go:linkname memequal0 runtime.memequal0
-//go:linkname memequal8 runtime.memequal8
-//go:linkname memequal16 runtime.memequal16
-//go:linkname memequal32 runtime.memequal32
-//go:linkname memequal64 runtime.memequal64
-//go:linkname memequal128 runtime.memequal128
-//go:linkname strequal runtime.strequal
-//go:linkname f32equal runtime.f32equal
-//go:linkname f64equal runtime.f64equal
-//go:linkname c64equal runtime.c64equal
-//go:linkname c128equal runtime.c128equal
-//go:linkname interequal runtime.interequal
-//go:linkname nilinterequal runtime.nilinterequal
-//go:linkname efaceeq runtime.efaceeq
-//go:linkname ifaceeq runtime.ifaceeq
-//go:linkname ifacevaleq runtime.ifacevaleq
-//go:linkname ifaceefaceeq runtime.ifaceefaceeq
-//go:linkname efacevaleq runtime.efacevaleq
-//go:linkname cmpstring runtime.cmpstring
+//go:linkname memhash0
+//go:linkname memhash8
+//go:linkname memhash16
+//go:linkname memhash32
+//go:linkname memhash64
+//go:linkname memhash128
+//go:linkname strhash
+//go:linkname f32hash
+//go:linkname f64hash
+//go:linkname c64hash
+//go:linkname c128hash
+//go:linkname interhash
+//go:linkname nilinterhash
+//go:linkname memequal0
+//go:linkname memequal8
+//go:linkname memequal16
+//go:linkname memequal32
+//go:linkname memequal64
+//go:linkname memequal128
+//go:linkname strequal
+//go:linkname f32equal
+//go:linkname f64equal
+//go:linkname c64equal
+//go:linkname c128equal
+//go:linkname interequal
+//go:linkname nilinterequal
+//go:linkname efaceeq
+//go:linkname ifaceeq
+//go:linkname ifacevaleq
+//go:linkname ifaceefaceeq
+//go:linkname efacevaleq
+//go:linkname cmpstring
 //
 // Temporary to be called from C code.
-//go:linkname alginit runtime.alginit
+//go:linkname alginit
 
 const (
 	c0 = uintptr((8-sys.PtrSize)/4*2860486313 + (sys.PtrSize-4)/4*33054211828000289)
Index: libgo/go/runtime/cgocall.go
===================================================================
--- libgo/go/runtime/cgocall.go	(revision 274169)
+++ libgo/go/runtime/cgocall.go	(working copy)
@@ -12,8 +12,8 @@  import (
 )
 
 // Functions called by cgo-generated code.
-//go:linkname cgoCheckPointer runtime.cgoCheckPointer
-//go:linkname cgoCheckResult runtime.cgoCheckResult
+//go:linkname cgoCheckPointer
+//go:linkname cgoCheckResult
 
 // Pointer checking for cgo code.
 
Index: libgo/go/runtime/chan.go
===================================================================
--- libgo/go/runtime/chan.go	(revision 274169)
+++ libgo/go/runtime/chan.go	(working copy)
@@ -23,18 +23,17 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname makechan runtime.makechan
-//go:linkname makechan64 runtime.makechan64
-//go:linkname chansend1 runtime.chansend1
-//go:linkname chanrecv1 runtime.chanrecv1
-//go:linkname chanrecv2 runtime.chanrecv2
-//go:linkname closechan runtime.closechan
-//go:linkname selectnbsend runtime.selectnbsend
-//go:linkname selectnbrecv runtime.selectnbrecv
-//go:linkname selectnbrecv2 runtime.selectnbrecv2
+//go:linkname makechan
+//go:linkname makechan64
+//go:linkname chansend1
+//go:linkname chanrecv1
+//go:linkname chanrecv2
+//go:linkname closechan
+//go:linkname selectnbsend
+//go:linkname selectnbrecv
+//go:linkname selectnbrecv2
 
 const (
 	maxAlign  = 8
Index: libgo/go/runtime/ffi.go
===================================================================
--- libgo/go/runtime/ffi.go	(revision 274169)
+++ libgo/go/runtime/ffi.go	(working copy)
@@ -37,7 +37,7 @@  func ffi_type_void() *__ffi_type
 func ffi_prep_cif(*_ffi_cif, _ffi_abi, uint32, *__ffi_type, **__ffi_type) _ffi_status
 
 // ffiFuncToCIF is called from C code.
-//go:linkname ffiFuncToCIF runtime.ffiFuncToCIF
+//go:linkname ffiFuncToCIF
 
 // ffiFuncToCIF builds an _ffi_cif struct for function described by ft.
 func ffiFuncToCIF(ft *functype, isInterface bool, isMethod bool, cif *_ffi_cif) {
Index: libgo/go/runtime/hash32.go
===================================================================
--- libgo/go/runtime/hash32.go	(revision 274169)
+++ libgo/go/runtime/hash32.go	(working copy)
@@ -12,10 +12,9 @@  package runtime
 
 import "unsafe"
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname memhash runtime.memhash
+//go:linkname memhash
 
 const (
 	// Constants for multiplication: four random odd 32-bit numbers.
Index: libgo/go/runtime/hash64.go
===================================================================
--- libgo/go/runtime/hash64.go	(revision 274169)
+++ libgo/go/runtime/hash64.go	(working copy)
@@ -12,10 +12,9 @@  package runtime
 
 import "unsafe"
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname memhash runtime.memhash
+//go:linkname memhash
 
 const (
 	// Constants for multiplication: four random odd 64-bit numbers.
Index: libgo/go/runtime/iface.go
===================================================================
--- libgo/go/runtime/iface.go	(revision 274169)
+++ libgo/go/runtime/iface.go	(working copy)
@@ -10,23 +10,22 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname requireitab runtime.requireitab
-//go:linkname assertitab runtime.assertitab
-//go:linkname panicdottype runtime.panicdottype
-//go:linkname ifaceE2E2 runtime.ifaceE2E2
-//go:linkname ifaceI2E2 runtime.ifaceI2E2
-//go:linkname ifaceE2I2 runtime.ifaceE2I2
-//go:linkname ifaceI2I2 runtime.ifaceI2I2
-//go:linkname ifaceE2T2P runtime.ifaceE2T2P
-//go:linkname ifaceI2T2P runtime.ifaceI2T2P
-//go:linkname ifaceE2T2 runtime.ifaceE2T2
-//go:linkname ifaceI2T2 runtime.ifaceI2T2
-//go:linkname ifaceT2Ip runtime.ifaceT2Ip
+//go:linkname requireitab
+//go:linkname assertitab
+//go:linkname panicdottype
+//go:linkname ifaceE2E2
+//go:linkname ifaceI2E2
+//go:linkname ifaceE2I2
+//go:linkname ifaceI2I2
+//go:linkname ifaceE2T2P
+//go:linkname ifaceI2T2P
+//go:linkname ifaceE2T2
+//go:linkname ifaceI2T2
+//go:linkname ifaceT2Ip
 // Temporary for C code to call:
-//go:linkname getitab runtime.getitab
+//go:linkname getitab
 
 // The gccgo itab structure is different than the gc one.
 //
Index: libgo/go/runtime/lock_futex.go
===================================================================
--- libgo/go/runtime/lock_futex.go	(revision 274169)
+++ libgo/go/runtime/lock_futex.go	(working copy)
@@ -12,16 +12,15 @@  import (
 )
 
 // For gccgo, while we still have C runtime code, use go:linkname to
-// rename some functions to themselves, so that the compiler will
-// export them.
+// export some functions.
 //
-//go:linkname lock runtime.lock
-//go:linkname unlock runtime.unlock
-//go:linkname noteclear runtime.noteclear
-//go:linkname notewakeup runtime.notewakeup
-//go:linkname notesleep runtime.notesleep
-//go:linkname notetsleep runtime.notetsleep
-//go:linkname notetsleepg runtime.notetsleepg
+//go:linkname lock
+//go:linkname unlock
+//go:linkname noteclear
+//go:linkname notewakeup
+//go:linkname notesleep
+//go:linkname notetsleep
+//go:linkname notetsleepg
 
 // This implementation depends on OS-specific implementations of
 //
Index: libgo/go/runtime/lock_sema.go
===================================================================
--- libgo/go/runtime/lock_sema.go	(revision 274169)
+++ libgo/go/runtime/lock_sema.go	(working copy)
@@ -12,16 +12,15 @@  import (
 )
 
 // For gccgo, while we still have C runtime code, use go:linkname to
-// rename some functions to themselves, so that the compiler will
-// export them.
+// export some functions.
 //
-//go:linkname lock runtime.lock
-//go:linkname unlock runtime.unlock
-//go:linkname noteclear runtime.noteclear
-//go:linkname notewakeup runtime.notewakeup
-//go:linkname notesleep runtime.notesleep
-//go:linkname notetsleep runtime.notetsleep
-//go:linkname notetsleepg runtime.notetsleepg
+//go:linkname lock
+//go:linkname unlock
+//go:linkname noteclear
+//go:linkname notewakeup
+//go:linkname notesleep
+//go:linkname notetsleep
+//go:linkname notetsleepg
 
 // This implementation depends on OS-specific implementations of
 //
Index: libgo/go/runtime/malloc.go
===================================================================
--- libgo/go/runtime/malloc.go	(revision 275010)
+++ libgo/go/runtime/malloc.go	(working copy)
@@ -114,13 +114,12 @@  import (
 // C function to get the end of the program's memory.
 func getEnd() uintptr
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname newobject runtime.newobject
+//go:linkname newobject
 
 // Functions called by C code.
-//go:linkname mallocgc runtime.mallocgc
+//go:linkname mallocgc
 
 const (
 	debugMalloc = false
Index: libgo/go/runtime/map.go
===================================================================
--- libgo/go/runtime/map.go	(revision 274169)
+++ libgo/go/runtime/map.go	(working copy)
@@ -60,21 +60,20 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname makemap runtime.makemap
-//go:linkname makemap64 runtime.makemap64
-//go:linkname makemap_small runtime.makemap_small
-//go:linkname mapaccess1 runtime.mapaccess1
-//go:linkname mapaccess2 runtime.mapaccess2
-//go:linkname mapaccess1_fat runtime.mapaccess1_fat
-//go:linkname mapaccess2_fat runtime.mapaccess2_fat
-//go:linkname mapassign runtime.mapassign
-//go:linkname mapdelete runtime.mapdelete
-//go:linkname mapclear runtime.mapclear
-//go:linkname mapiterinit runtime.mapiterinit
-//go:linkname mapiternext runtime.mapiternext
+//go:linkname makemap
+//go:linkname makemap64
+//go:linkname makemap_small
+//go:linkname mapaccess1
+//go:linkname mapaccess2
+//go:linkname mapaccess1_fat
+//go:linkname mapaccess2_fat
+//go:linkname mapassign
+//go:linkname mapdelete
+//go:linkname mapclear
+//go:linkname mapiterinit
+//go:linkname mapiternext
 
 const (
 	// Maximum number of key/value pairs a bucket can hold.
Index: libgo/go/runtime/map_fast32.go
===================================================================
--- libgo/go/runtime/map_fast32.go	(revision 274169)
+++ libgo/go/runtime/map_fast32.go	(working copy)
@@ -9,14 +9,13 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname mapaccess1_fast32 runtime.mapaccess1_fast32
-//go:linkname mapaccess2_fast32 runtime.mapaccess2_fast32
-//go:linkname mapassign_fast32 runtime.mapassign_fast32
-//go:linkname mapassign_fast32ptr runtime.mapassign_fast32ptr
-//go:linkname mapdelete_fast32 runtime.mapdelete_fast32
+//go:linkname mapaccess1_fast32
+//go:linkname mapaccess2_fast32
+//go:linkname mapassign_fast32
+//go:linkname mapassign_fast32ptr
+//go:linkname mapdelete_fast32
 
 func mapaccess1_fast32(t *maptype, h *hmap, key uint32) unsafe.Pointer {
 	if raceenabled && h != nil {
Index: libgo/go/runtime/map_fast64.go
===================================================================
--- libgo/go/runtime/map_fast64.go	(revision 274169)
+++ libgo/go/runtime/map_fast64.go	(working copy)
@@ -9,14 +9,13 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname mapaccess1_fast64 runtime.mapaccess1_fast64
-//go:linkname mapaccess2_fast64 runtime.mapaccess2_fast64
-//go:linkname mapassign_fast64 runtime.mapassign_fast64
-//go:linkname mapassign_fast64ptr runtime.mapassign_fast64ptr
-//go:linkname mapdelete_fast64 runtime.mapdelete_fast64
+//go:linkname mapaccess1_fast64
+//go:linkname mapaccess2_fast64
+//go:linkname mapassign_fast64
+//go:linkname mapassign_fast64ptr
+//go:linkname mapdelete_fast64
 
 func mapaccess1_fast64(t *maptype, h *hmap, key uint64) unsafe.Pointer {
 	if raceenabled && h != nil {
Index: libgo/go/runtime/map_faststr.go
===================================================================
--- libgo/go/runtime/map_faststr.go	(revision 274169)
+++ libgo/go/runtime/map_faststr.go	(working copy)
@@ -9,13 +9,12 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname mapaccess1_faststr runtime.mapaccess1_faststr
-//go:linkname mapaccess2_faststr runtime.mapaccess2_faststr
-//go:linkname mapassign_faststr runtime.mapassign_faststr
-//go:linkname mapdelete_faststr runtime.mapdelete_faststr
+//go:linkname mapaccess1_faststr
+//go:linkname mapaccess2_faststr
+//go:linkname mapassign_faststr
+//go:linkname mapdelete_faststr
 
 func mapaccess1_faststr(t *maptype, h *hmap, ky string) unsafe.Pointer {
 	if raceenabled && h != nil {
Index: libgo/go/runtime/mbarrier.go
===================================================================
--- libgo/go/runtime/mbarrier.go	(revision 274169)
+++ libgo/go/runtime/mbarrier.go	(working copy)
@@ -18,12 +18,11 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname typedmemmove runtime.typedmemmove
-//go:linkname typedslicecopy runtime.typedslicecopy
-//go:linkname memclrHasPointers runtime.memclrHasPointers
+//go:linkname typedmemmove
+//go:linkname typedslicecopy
+//go:linkname memclrHasPointers
 
 // Go uses a hybrid barrier that combines a Yuasa-style deletion
 // barrier—which shades the object whose reference is being
Index: libgo/go/runtime/mem_gccgo.go
===================================================================
--- libgo/go/runtime/mem_gccgo.go	(revision 274169)
+++ libgo/go/runtime/mem_gccgo.go	(working copy)
@@ -12,8 +12,8 @@  import (
 )
 
 // Functions called by C code.
-//go:linkname sysAlloc runtime.sysAlloc
-//go:linkname sysFree runtime.sysFree
+//go:linkname sysAlloc
+//go:linkname sysFree
 
 //extern mmap
 func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
Index: libgo/go/runtime/mgc_gccgo.go
===================================================================
--- libgo/go/runtime/mgc_gccgo.go	(revision 274169)
+++ libgo/go/runtime/mgc_gccgo.go	(working copy)
@@ -11,10 +11,9 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname gcWriteBarrier runtime.gcWriteBarrier
+//go:linkname gcWriteBarrier
 
 // gcRoot is a single GC root: a variable plus a ptrmask.
 //go:notinheap
@@ -130,7 +129,7 @@  func createGcRootsIndex() {
 }
 
 // registerGCRoots is called by compiler-generated code.
-//go:linkname registerGCRoots runtime.registerGCRoots
+//go:linkname registerGCRoots
 
 // registerGCRoots is called by init functions to register the GC
 // roots for a package.  The init functions are run sequentially at
Index: libgo/go/runtime/mgcmark.go
===================================================================
--- libgo/go/runtime/mgcmark.go	(revision 274613)
+++ libgo/go/runtime/mgcmark.go	(working copy)
@@ -1042,7 +1042,7 @@  func scanobject(b uintptr, gcw *gcWork)
 	gcw.scanWork += int64(i)
 }
 
-//go:linkname scanstackblock runtime.scanstackblock
+//go:linkname scanstackblock
 
 // scanstackblock is called by the stack scanning code in C to
 // actually find and mark pointers in the stack block. This is like
@@ -1064,7 +1064,7 @@  func scanstackblock(b, n uintptr, gcw *g
 
 // scanstackblockwithmap is like scanstackblock, but with an explicit
 // pointer bitmap. This is used only when precise stack scan is enabled.
-//go:linkname scanstackblockwithmap runtime.scanstackblockwithmap
+//go:linkname scanstackblockwithmap
 //go:nowritebarrier
 func scanstackblockwithmap(pc, b0, n0 uintptr, ptrmask *uint8, gcw *gcWork) {
 	// Use local copies of original parameters, so that a stack trace
Index: libgo/go/runtime/netpoll.go
===================================================================
--- libgo/go/runtime/netpoll.go	(revision 274169)
+++ libgo/go/runtime/netpoll.go	(working copy)
@@ -12,7 +12,7 @@  import (
 )
 
 // Export temporarily for gccgo's C code to call:
-//go:linkname netpoll runtime.netpoll
+//go:linkname netpoll
 
 // Integrated network poller (platform-independent part).
 // A particular implementation (epoll/kqueue) must define the following functions:
Index: libgo/go/runtime/os_gccgo.go
===================================================================
--- libgo/go/runtime/os_gccgo.go	(revision 274169)
+++ libgo/go/runtime/os_gccgo.go	(working copy)
@@ -9,7 +9,7 @@  import (
 )
 
 // For C code to call:
-//go:linkname minit runtime.minit
+//go:linkname minit
 
 func goenvs() {
 	goenvs_unix()
Index: libgo/go/runtime/panic.go
===================================================================
--- libgo/go/runtime/panic.go	(revision 274998)
+++ libgo/go/runtime/panic.go	(working copy)
@@ -9,39 +9,38 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname deferproc runtime.deferproc
-//go:linkname deferprocStack runtime.deferprocStack
-//go:linkname deferreturn runtime.deferreturn
-//go:linkname setdeferretaddr runtime.setdeferretaddr
-//go:linkname checkdefer runtime.checkdefer
-//go:linkname gopanic runtime.gopanic
-//go:linkname canrecover runtime.canrecover
-//go:linkname makefuncfficanrecover runtime.makefuncfficanrecover
-//go:linkname makefuncreturning runtime.makefuncreturning
-//go:linkname gorecover runtime.gorecover
-//go:linkname deferredrecover runtime.deferredrecover
-//go:linkname goPanicIndex runtime.goPanicIndex
-//go:linkname goPanicIndexU runtime.goPanicIndexU
-//go:linkname goPanicSliceAlen runtime.goPanicSliceAlen
-//go:linkname goPanicSliceAlenU runtime.goPanicSliceAlenU
-//go:linkname goPanicSliceAcap runtime.goPanicSliceAcap
-//go:linkname goPanicSliceAcapU runtime.goPanicSliceAcapU
-//go:linkname goPanicSliceB runtime.goPanicSliceB
-//go:linkname goPanicSliceBU runtime.goPanicSliceBU
-//go:linkname goPanicSlice3Alen runtime.goPanicSlice3Alen
-//go:linkname goPanicSlice3AlenU runtime.goPanicSlice3AlenU
-//go:linkname goPanicSlice3Acap runtime.goPanicSlice3Acap
-//go:linkname goPanicSlice3AcapU runtime.goPanicSlice3AcapU
-//go:linkname goPanicSlice3B runtime.goPanicSlice3B
-//go:linkname goPanicSlice3BU runtime.goPanicSlice3BU
-//go:linkname goPanicSlice3C runtime.goPanicSlice3C
-//go:linkname goPanicSlice3CU runtime.goPanicSlice3CU
-//go:linkname panicmem runtime.panicmem
+//go:linkname deferproc
+//go:linkname deferprocStack
+//go:linkname deferreturn
+//go:linkname setdeferretaddr
+//go:linkname checkdefer
+//go:linkname gopanic
+//go:linkname canrecover
+//go:linkname makefuncfficanrecover
+//go:linkname makefuncreturning
+//go:linkname gorecover
+//go:linkname deferredrecover
+//go:linkname goPanicIndex
+//go:linkname goPanicIndexU
+//go:linkname goPanicSliceAlen
+//go:linkname goPanicSliceAlenU
+//go:linkname goPanicSliceAcap
+//go:linkname goPanicSliceAcapU
+//go:linkname goPanicSliceB
+//go:linkname goPanicSliceBU
+//go:linkname goPanicSlice3Alen
+//go:linkname goPanicSlice3AlenU
+//go:linkname goPanicSlice3Acap
+//go:linkname goPanicSlice3AcapU
+//go:linkname goPanicSlice3B
+//go:linkname goPanicSlice3BU
+//go:linkname goPanicSlice3C
+//go:linkname goPanicSlice3CU
+//go:linkname panicmem
 // Temporary for C code to call:
-//go:linkname throw runtime.throw
+//go:linkname throw
 
 // Check to make sure we can really generate a panic. If the panic
 // was generated from the runtime, or from inside malloc, then convert
Index: libgo/go/runtime/panic32.go
===================================================================
--- libgo/go/runtime/panic32.go	(revision 275237)
+++ libgo/go/runtime/panic32.go	(working copy)
@@ -6,25 +6,24 @@  package runtime
 
 import _ "unsafe" // for go:linkname
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname goPanicExtendIndex runtime.goPanicExtendIndex
-//go:linkname goPanicExtendIndexU runtime.goPanicExtendIndexU
-//go:linkname goPanicExtendSliceAlen runtime.goPanicExtendSliceAlen
-//go:linkname goPanicExtendSliceAlenU runtime.goPanicExtendSliceAlenU
-//go:linkname goPanicExtendSliceAcap runtime.goPanicExtendSliceAcap
-//go:linkname goPanicExtendSliceAcapU runtime.goPanicExtendSliceAcapU
-//go:linkname goPanicExtendSliceB runtime.goPanicExtendSliceB
-//go:linkname goPanicExtendSliceBU runtime.goPanicExtendSliceBU
-//go:linkname goPanicExtendSlice3Alen runtime.goPanicExtendSlice3Alen
-//go:linkname goPanicExtendSlice3AlenU runtime.goPanicExtendSlice3AlenU
-//go:linkname goPanicExtendSlice3Acap runtime.goPanicExtendSlice3Acap
-//go:linkname goPanicExtendSlice3AcapU runtime.goPanicExtendSlice3AcapU
-//go:linkname goPanicExtendSlice3B runtime.goPanicExtendSlice3B
-//go:linkname goPanicExtendSlice3BU runtime.goPanicExtendSlice3BU
-//go:linkname goPanicExtendSlice3C runtime.goPanicExtendSlice3C
-//go:linkname goPanicExtendSlice3CU runtime.goPanicExtendSlice3CU
+//go:linkname goPanicExtendIndex
+//go:linkname goPanicExtendIndexU
+//go:linkname goPanicExtendSliceAlen
+//go:linkname goPanicExtendSliceAlenU
+//go:linkname goPanicExtendSliceAcap
+//go:linkname goPanicExtendSliceAcapU
+//go:linkname goPanicExtendSliceB
+//go:linkname goPanicExtendSliceBU
+//go:linkname goPanicExtendSlice3Alen
+//go:linkname goPanicExtendSlice3AlenU
+//go:linkname goPanicExtendSlice3Acap
+//go:linkname goPanicExtendSlice3AcapU
+//go:linkname goPanicExtendSlice3B
+//go:linkname goPanicExtendSlice3BU
+//go:linkname goPanicExtendSlice3C
+//go:linkname goPanicExtendSlice3CU
 
 // Additional index/slice error paths for 32-bit platforms.
 // Used when the high word of a 64-bit index is not zero.
Index: libgo/go/runtime/print.go
===================================================================
--- libgo/go/runtime/print.go	(revision 274890)
+++ libgo/go/runtime/print.go	(working copy)
@@ -9,27 +9,26 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname printbool runtime.printbool
-//go:linkname printfloat runtime.printfloat
-//go:linkname printint runtime.printint
-//go:linkname printhex runtime.printhex
-//go:linkname printuint runtime.printuint
-//go:linkname printcomplex runtime.printcomplex
-//go:linkname printstring runtime.printstring
-//go:linkname printpointer runtime.printpointer
-//go:linkname printiface runtime.printiface
-//go:linkname printeface runtime.printeface
-//go:linkname printslice runtime.printslice
-//go:linkname printnl runtime.printnl
-//go:linkname printsp runtime.printsp
-//go:linkname printlock runtime.printlock
-//go:linkname printunlock runtime.printunlock
+//go:linkname printbool
+//go:linkname printfloat
+//go:linkname printint
+//go:linkname printhex
+//go:linkname printuint
+//go:linkname printcomplex
+//go:linkname printstring
+//go:linkname printpointer
+//go:linkname printiface
+//go:linkname printeface
+//go:linkname printslice
+//go:linkname printnl
+//go:linkname printsp
+//go:linkname printlock
+//go:linkname printunlock
 // Temporary for C code to call:
-//go:linkname gwrite runtime.gwrite
-//go:linkname printhex runtime.printhex
+//go:linkname gwrite
+//go:linkname printhex
 
 // The compiler knows that a print of a value of this type
 // should use printhex instead of printuint (decimal).
Index: libgo/go/runtime/proc.go
===================================================================
--- libgo/go/runtime/proc.go	(revision 274169)
+++ libgo/go/runtime/proc.go	(working copy)
@@ -12,37 +12,37 @@  import (
 )
 
 // Functions called by C code.
-//go:linkname main runtime.main
-//go:linkname goparkunlock runtime.goparkunlock
-//go:linkname newextram runtime.newextram
-//go:linkname acquirep runtime.acquirep
-//go:linkname releasep runtime.releasep
-//go:linkname incidlelocked runtime.incidlelocked
-//go:linkname ginit runtime.ginit
-//go:linkname schedinit runtime.schedinit
-//go:linkname ready runtime.ready
-//go:linkname stopm runtime.stopm
-//go:linkname handoffp runtime.handoffp
-//go:linkname wakep runtime.wakep
-//go:linkname stoplockedm runtime.stoplockedm
-//go:linkname schedule runtime.schedule
-//go:linkname execute runtime.execute
-//go:linkname goexit1 runtime.goexit1
-//go:linkname reentersyscall runtime.reentersyscall
-//go:linkname reentersyscallblock runtime.reentersyscallblock
-//go:linkname exitsyscall runtime.exitsyscall
-//go:linkname gfget runtime.gfget
-//go:linkname kickoff runtime.kickoff
-//go:linkname mstart1 runtime.mstart1
-//go:linkname mexit runtime.mexit
-//go:linkname globrunqput runtime.globrunqput
-//go:linkname pidleget runtime.pidleget
+//go:linkname main
+//go:linkname goparkunlock
+//go:linkname newextram
+//go:linkname acquirep
+//go:linkname releasep
+//go:linkname incidlelocked
+//go:linkname ginit
+//go:linkname schedinit
+//go:linkname ready
+//go:linkname stopm
+//go:linkname handoffp
+//go:linkname wakep
+//go:linkname stoplockedm
+//go:linkname schedule
+//go:linkname execute
+//go:linkname goexit1
+//go:linkname reentersyscall
+//go:linkname reentersyscallblock
+//go:linkname exitsyscall
+//go:linkname gfget
+//go:linkname kickoff
+//go:linkname mstart1
+//go:linkname mexit
+//go:linkname globrunqput
+//go:linkname pidleget
 
 // Exported for test (see runtime/testdata/testprogcgo/dropm_stub.go).
-//go:linkname getm runtime.getm
+//go:linkname getm
 
 // Function called by misc/cgo/test.
-//go:linkname lockedOSThread runtime.lockedOSThread
+//go:linkname lockedOSThread
 
 // C functions for thread and context management.
 func newosproc(*m)
Index: libgo/go/runtime/runtime.go
===================================================================
--- libgo/go/runtime/runtime.go	(revision 274169)
+++ libgo/go/runtime/runtime.go	(working copy)
@@ -14,10 +14,9 @@  import (
 //go:generate go run mkfastlog2table.go
 
 // For gccgo, while we still have C runtime code, use go:linkname to
-// rename some functions to themselves, so that the compiler will
-// export them.
+// export some functions.
 //
-//go:linkname tickspersecond runtime.tickspersecond
+//go:linkname tickspersecond
 
 var ticksLock mutex
 var ticksVal uint64
Index: libgo/go/runtime/runtime1.go
===================================================================
--- libgo/go/runtime/runtime1.go	(revision 274678)
+++ libgo/go/runtime/runtime1.go	(working copy)
@@ -11,16 +11,15 @@  import (
 )
 
 // For gccgo, while we still have C runtime code, use go:linkname to
-// rename some functions to themselves, so that the compiler will
-// export them.
+// export some functions to themselves.
 //
-//go:linkname gotraceback runtime.gotraceback
-//go:linkname args runtime.args
-//go:linkname goargs runtime.goargs
-//go:linkname check runtime.check
-//go:linkname goenvs_unix runtime.goenvs_unix
-//go:linkname parsedebugvars runtime.parsedebugvars
-//go:linkname timediv runtime.timediv
+//go:linkname gotraceback
+//go:linkname args
+//go:linkname goargs
+//go:linkname check
+//go:linkname goenvs_unix
+//go:linkname parsedebugvars
+//go:linkname timediv
 
 // Keep a cached value to make gotraceback fast,
 // since we call it on every call to gentraceback.
Index: libgo/go/runtime/runtime2.go
===================================================================
--- libgo/go/runtime/runtime2.go	(revision 274613)
+++ libgo/go/runtime/runtime2.go	(working copy)
@@ -930,7 +930,7 @@  type sigset _sigset_t
 
 // getMemstats returns a pointer to the internal memstats variable,
 // for C code.
-//go:linkname getMemstats runtime.getMemstats
+//go:linkname getMemstats
 func getMemstats() *mstats {
 	return &memstats
 }
Index: libgo/go/runtime/select.go
===================================================================
--- libgo/go/runtime/select.go	(revision 274169)
+++ libgo/go/runtime/select.go	(working copy)
@@ -10,11 +10,10 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname selectgo runtime.selectgo
-//go:linkname block runtime.block
+//go:linkname selectgo
+//go:linkname block
 
 const debugSelect = false
 
Index: libgo/go/runtime/signal_unix.go
===================================================================
--- libgo/go/runtime/signal_unix.go	(revision 274169)
+++ libgo/go/runtime/signal_unix.go	(working copy)
@@ -12,8 +12,8 @@  import (
 )
 
 // For gccgo's C code to call:
-//go:linkname initsig runtime.initsig
-//go:linkname sigtrampgo runtime.sigtrampgo
+//go:linkname initsig
+//go:linkname sigtrampgo
 
 // sigTabT is the type of an entry in the global sigtable array.
 // sigtable is inherently system dependent, and appears in OS-specific files,
Index: libgo/go/runtime/slice.go
===================================================================
--- libgo/go/runtime/slice.go	(revision 274169)
+++ libgo/go/runtime/slice.go	(working copy)
@@ -10,14 +10,13 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname makeslice runtime.makeslice
-//go:linkname makeslice64 runtime.makeslice64
-//go:linkname growslice runtime.growslice
-//go:linkname slicecopy runtime.slicecopy
-//go:linkname slicestringcopy runtime.slicestringcopy
+//go:linkname makeslice
+//go:linkname makeslice64
+//go:linkname growslice
+//go:linkname slicecopy
+//go:linkname slicestringcopy
 
 type slice struct {
 	array unsafe.Pointer
Index: libgo/go/runtime/string.go
===================================================================
--- libgo/go/runtime/string.go	(revision 274169)
+++ libgo/go/runtime/string.go	(working copy)
@@ -9,19 +9,18 @@  import (
 	"unsafe"
 )
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname concatstrings runtime.concatstrings
-//go:linkname slicebytetostring runtime.slicebytetostring
-//go:linkname slicebytetostringtmp runtime.slicebytetostringtmp
-//go:linkname stringtoslicebyte runtime.stringtoslicebyte
-//go:linkname stringtoslicerune runtime.stringtoslicerune
-//go:linkname slicerunetostring runtime.slicerunetostring
-//go:linkname intstring runtime.intstring
+//go:linkname concatstrings
+//go:linkname slicebytetostring
+//go:linkname slicebytetostringtmp
+//go:linkname stringtoslicebyte
+//go:linkname stringtoslicerune
+//go:linkname slicerunetostring
+//go:linkname intstring
 // Temporary for C code to call:
-//go:linkname gostringnocopy runtime.gostringnocopy
-//go:linkname findnull runtime.findnull
+//go:linkname gostringnocopy
+//go:linkname findnull
 
 // The constant is known to the compiler.
 // There is no fundamental theory behind this number.
Index: libgo/go/runtime/stubs.go
===================================================================
--- libgo/go/runtime/stubs.go	(revision 275010)
+++ libgo/go/runtime/stubs.go	(working copy)
@@ -165,7 +165,6 @@  func breakpoint()
 
 func asminit() {}
 
-//go:linkname reflectcall runtime.reflectcall
 //go:noescape
 func reflectcall(fntype *functype, fn *funcval, isInterface, isMethod bool, params, results *unsafe.Pointer)
 
@@ -280,13 +279,13 @@  func osyield()
 func syscall(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) uintptr
 
 // For gccgo, to communicate from the C code to the Go code.
-//go:linkname setIsCgo runtime.setIsCgo
+//go:linkname setIsCgo
 func setIsCgo() {
 	iscgo = true
 }
 
 // For gccgo, to communicate from the C code to the Go code.
-//go:linkname setSupportAES runtime.setSupportAES
+//go:linkname setSupportAES
 func setSupportAES(v bool) {
 	support_aes = v
 }
@@ -320,7 +319,7 @@  func dumpregs(*_siginfo_t, unsafe.Pointe
 func setRandomNumber(uint32)
 
 // Called by gccgo's proc.c.
-//go:linkname allocg runtime.allocg
+//go:linkname allocg
 func allocg() *g {
 	return new(g)
 }
@@ -368,17 +367,16 @@  func abort()
 var usestackmaps bool
 
 // probestackmaps detects whether there are stack maps.
-//go:linkname probestackmaps runtime.probestackmaps
 func probestackmaps() bool
 
 // For the math/bits packages for gccgo.
-//go:linkname getDivideError runtime.getDivideError
+//go:linkname getDivideError
 func getDivideError() error {
 	return divideError
 }
 
 // For the math/bits packages for gccgo.
-//go:linkname getOverflowError runtime.getOverflowError
+//go:linkname getOverflowError
 func getOverflowError() error {
 	return overflowError
 }
Index: libgo/go/runtime/type.go
===================================================================
--- libgo/go/runtime/type.go	(revision 274169)
+++ libgo/go/runtime/type.go	(working copy)
@@ -179,7 +179,7 @@  var typelistLock mutex
 // type descriptors.
 // p points to a list of *typeDescriptorList, n is the length
 // of the list.
-//go:linkname registerTypeDescriptors runtime.registerTypeDescriptors
+//go:linkname registerTypeDescriptors
 func registerTypeDescriptors(n int, p unsafe.Pointer) {
 	*(*slice)(unsafe.Pointer(&typelist.lists)) = slice{p, n, n}
 }
Index: libgo/go/runtime/utf8.go
===================================================================
--- libgo/go/runtime/utf8.go	(revision 274169)
+++ libgo/go/runtime/utf8.go	(working copy)
@@ -6,10 +6,9 @@  package runtime
 
 import _ "unsafe" // For go:linkname.
 
-// For gccgo, use go:linkname to rename compiler-called functions to
-// themselves, so that the compiler will export them.
+// For gccgo, use go:linkname to export compiler-called functions.
 //
-//go:linkname decoderune runtime.decoderune
+//go:linkname decoderune
 
 // Numbers fundamental to the encoding.
 const (