Go: Unable to install runtime/cgo on Mojave 10.14.4 with go 1.12.1

Created on 30 Mar 2019  路  7Comments  路  Source: golang/go

What version of Go are you using (go version)?

$ go version
go version go1.12.1 darwin/amd64

Does this issue reproduce with the latest release?

Is Latest

What operating system and processor architecture are you using (go env)?

go env Output

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/me/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/me/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/21/lkl1rp3j3b78c8t48s898fbm0000gp/T/go-build284904960=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I have just upgraded to go 1.12 via homebrew after upgrading to Mojave (10.14.4) earlier this week. Builds seemed to be working fine, but when I attempted to run my tests they failed due to the below error. Narrowed it down to the runtime/cgo install:

$ go install -v -a runtime/cgo
runtime/cgo
# runtime/cgo
ld: malformed file
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd:4:18: error: unknown enumerated scalar
platform:        zippered
                 ^~~~~~~~
 file '/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Header of /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd (with uuid key deleted):

--- !tapi-tbd-v3
archs:           [ x86_64 ]
platform:        zippered
install-name:    /usr/lib/libSystem.B.dylib
current-version: 1252.250.1
objc-constraint: none

What did you expect to see?

I was hoping it would install and rebuild

What did you see instead?

Above error preventing install of runtime/cgo

FrozenDueToAge

Most helpful comment

FYI, If you want to stay on xcode 9.4.1, you can do the following:

If you are running on Mojave, you will need to install the MacOS headers in the base system:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

All 7 comments

Fixed by upgrading XCode to 10.2

FYI, If you want to stay on xcode 9.4.1, you can do the following:

If you are running on Mojave, you will need to install the MacOS headers in the base system:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

@ScienceIsNeato thanks for the tip! Need to stay on 9.4.1 and this fixed a similar issue I had with installing Ruby gems.

@ScienceIsNeato Thanks. I had problem while compiling rust. And found the solution here in golang.

FYI, If you want to stay on xcode 9.4.1, you can do the following:

If you are running on Mojave, you will need to install the MacOS headers in the base system:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

Hi ! This didn't work for me. It says:

installer: Package name is macOS_SDK_headers_for_macOS_10.14
installer: Installing at base path /
installer: The install failed (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.)

I checked permissions, and they seem fine. I checked on the internet, and have no clue what I could do next.

This helped me!

sudo rm -rf /Library/Developer/CommandLineTools

xcode-select --install

cd /Library/Developer/CommandLineTools/Packages/

open macOS_SDK_headers_for_macOS_10.14.pkg

Hi ! I had tried that already, I had tried soooo many potential solutions found on the internet haha.
In the end, there seemed to be a problem with the export CC. Normally, you would just have to point to a directory where clang is, which I did. But it didn't work, so I added clang to the path, like this

export CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"

And that fixed it... Weird.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ianlancetaylor picture ianlancetaylor  路  138Comments

bradfitz picture bradfitz  路  147Comments

jessfraz picture jessfraz  路  154Comments

miekg picture miekg  路  314Comments

derekperkins picture derekperkins  路  180Comments