On Tue, Sep 25, 2018 at 6:26 AM, Rainer Orth
<[email protected]> wrote:
>
>> /vol/gcc/src/hg/trunk/local/libgo/go/runtime/traceback_gccgo.go:151:14:
>> error: reference to undefined name 'nanotime'
>> 151 | waitfor = (nanotime() - gp.waitsince) / 60e9
>> | ^
>>
>> and many many more instances. Again, I found an implementation in
>> upstream src/runtime/os3_solaris.go, but that isn't usable since it
>> uses syscall directly.
>>
>> So I'm currently stuck on the missing nanotime.
>
> I think I found it: if I enable building go/runtime/stubs3.go by
> removing the !solaris build tag, the runtime_nanotime implementation in
> runtime/go-nanotime.c is used. At least the builds are going along
> fine, it seems. No test results yet.
Thanks for the report. I've committed this patch to fix the build on
Solaris. There are some test failures, though. I haven't looked into
them.
Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE (revision 264572)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-652fbfb7acfd81ceffe28e20984464aa7bb6024d
+e7b98cf0a380eb45791cd5c52897224a686dcdec
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
Index: libgo/go/os/executable_solaris.go
===================================================================
--- libgo/go/os/executable_solaris.go (revision 264546)
+++ libgo/go/os/executable_solaris.go (working copy)
@@ -4,14 +4,18 @@
package os
-import "syscall"
+import (
+ "syscall"
+ _ "unsafe" // for go:linkname
+)
-var executablePath string // set by sysauxv in ../runtime/os3_solaris.go
+// solarisExecutablePath is defined in the runtime package.
+func solarisExecutablePath() string
var initCwd, initCwdErr = Getwd()
func executable() (string, error) {
- path := executablePath
+ path := solarisExecutablePath()
if len(path) == 0 {
path, err := syscall.Getexecname()
if err != nil {
Index: libgo/go/runtime/os3_solaris.go
===================================================================
--- libgo/go/runtime/os3_solaris.go (nonexistent)
+++ libgo/go/runtime/os3_solaris.go (working copy)
@@ -0,0 +1,54 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package runtime
+
+import (
+ "runtime/internal/sys"
+ "unsafe"
+)
+
+var executablePath string
+
+func sysargs(argc int32, argv **byte) {
+ n := argc + 1
+
+ // skip over argv, envp to get to auxv
+ for argv_index(argv, n) != nil {
+ n++
+ }
+
+ // skip NULL separator
+ n++
+
+ // now argv+n is auxv
+ auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv),
uintptr(n)*sys.PtrSize))
+ sysauxv(auxv[:])
+}
+
+const (
+ _AT_NULL = 0 // Terminates the vector
+ _AT_PAGESZ = 6 // Page size in bytes
+ _AT_SUN_EXECNAME = 2014 // exec() path name
+)
+
+func sysauxv(auxv []uintptr) {
+ for i := 0; auxv[i] != _AT_NULL; i += 2 {
+ tag, val := auxv[i], auxv[i+1]
+ switch tag {
+ case _AT_PAGESZ:
+ physPageSize = val
+ case _AT_SUN_EXECNAME:
+ executablePath =
gostringnocopy((*byte)(unsafe.Pointer(val)))
+ }
+ }
+}
+
+//go:linkname solarisExecutablePath os.solarisExecutablePath
+
+// solarisExecutablePath is called from the os package to fetch the
+// saved executable path.
+func solarisExecutablePath() string {
+ return executablePath
+}
Index: libgo/go/runtime/stubs3.go
===================================================================
--- libgo/go/runtime/stubs3.go (revision 264546)
+++ libgo/go/runtime/stubs3.go (working copy)
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
// +build !plan9
-// +build !solaris
// +build !windows
// +build !nacl
// +build !freebsd