Symbol not found: _clock_getime when compiling Go1.16 from source on a Mac

Hi - my first time on the forum. I’ve been programming in Go for a few years now, on a Macbook, a Dell Windows machine, even a Raspberry Pi 3 and 4. Seems my Mac is the one letting me down of late.

I recently did a clean install of MacOS 10.11.6 (el Capitan) on my MacbookPro5,5. Since Home Brew no longer supports 10.11.6 I decided to try and compile Go from source. I downloaded and installed Go1.14.6 with no problem. Downloaded Go1.16 source tarzip.
When I ran ./all.bash I got the following output:

BJD:src brent$ ./all.bash
Building Go cmd/dist using /usr/local/go. (go1.14.15 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
dyld: Symbol not found: _clock_gettime
  Referenced from: /Users/brent/go/pkg/tool/darwin_amd64/go_bootstrap
  Expected in: flat namespace

go tool dist: FAILED: /Users/brent/go/pkg/tool/darwin_amd64/go_bootstrap install -gcflags=all= -ldflags=all= -i cmd/asm cmd/cgo cmd/compile cmd/link: signal: trace/BPT trap

My Go env is:

BJD:src brent$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/brent/Library/Caches/go-build"
GOENV="/Users/brent/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/brent/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/brent/go/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/p_/kcmsl1yx7xv5xmwmgm7fmrmm0000gn/T/go-build855851525=/tmp/go-build -gno-record-gcc-switches -fno-common"

How can I fix this?

I’m not sure why this should happen. Using Go1.14.15 to compile Go1.16 and it’s telling me it still depends on some OS library? I don’t get it. Why isn’t it self-contained? I’m not seeing any Go code dependency issues.

Go doesn’t need to link to shared libraries but it does need an OS. Go 1.14 is the last version to support el Capitan according to the Go release notes. Versions of Go since then require functionality from MacOS that don’t exist in el Capitan.


El Capitan:] Unsupported as of September 2018

Wikipedia: OS X El Capitan


Go 1.14 is the last release that will run on macOS 10.11 El Capitan.

Go 1.14 Release Notes (February 2020)

As announced in the Go 1.14 release notes, Go 1.15 requires macOS 10.12 Sierra or later; support for previous versions has been discontinued.

Go 1.15 Release Notes (August 2020)

Go 1.16 is the last release that will run on macOS 10.12 Sierra.

Go 1.16 Release Notes (February 2021)


(Feb 26, 2021)

For El Capitan, install Go 1.14.

Why are you compiling from source? Why not download and install an official Go version?

Go: Download and install

Apple uses libc for system calls. In Go 1.16, I see:

runtime/sys_darwin_amd64.s:	 CALL  libc_clock_gettime

x/sys/unix/zsyscall_darwin_amd64.go:	_, _, e1 := syscall_syscall(funcPC(libc_clock_gettime_trampoline), uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
x/sys/unix/zsyscall_darwin_amd64.go:func libc_clock_gettime_trampoline()
x/sys/unix/zsyscall_darwin_amd64.go://go:cgo_import_dynamic libc_clock_gettime clock_gettime "/usr/lib/libSystem.B.dylib"

To install Go from source, read the instructions carefully: Installing Go from source.

To build without cgo, set the environment variable CGO_ENABLED=0 before running all.bash or make.bash.

Thanks for the clue about runtime/sys_darwin_amd64.s

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.