mock
mock copied to clipboard
macOS mockgen terminated by signal SIGKILL when built with swiftlang-6.0.0.3.300 clang-1600.0.20.10 toolchain
Actual behavior
bash-3.2$ go install go.uber.org/mock/[email protected]
bash-3.2$ mockgen --version
Killed: 9
Expected behavior
bash-3.2$ go install go.uber.org/mock/[email protected]
bash-3.2$ mockgen --version
v0.3.0
To Reproduce
Installing mockgen on macOS using go install go.uber.org/mock/[email protected], with the swift/clang toolchain set to the one that ships with Xcode 16.0.0-Beta (swift-driver version: 1.109.2 Apple Swift version 6.0 (swiftlang-6.0.0.3.300 clang-1600.0.20.10)) results in an executable that is killed when executed.
Switching back to the Xcode 15.4 toolchain (swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)), and re-installing mockgen, is sufficient to fix it.
Additional Information
go version go1.21.4 darwin/arm64
Triage Notes for the Maintainers
I realise that this is likely a toolchain issue outside of your control. The main purpose of this report is as a breadcrumb for anyone else seeing the same behaviour!
I ran into this error due to an invalid code signature. You can check if the signature is valid with codesign -v bin/mockgen (no output means valid). If it is invalid, a workaround is to re-sign it with codesign -f -s - bin/mockgen.
I ran into this error due to an invalid code signature. You can check if the signature is valid with
codesign -v bin/mockgen(no output means valid). If it is invalid, a workaround is to re-sign it withcodesign -f -s - bin/mockgen.
This fixed it for me but why is the code signature invalid? I re-install mockgen following the official instructions in the README.
Another workaround that works for me is to set CGO_ENABLED=0. For example:
CGO_ENABLED=0 go install go.uber.org/mock/mockgen@latest
If it is invalid, a workaround is to re-sign it with
codesign -f -s - bin/mockgen.
$ codesign -v $(which mockgen) [11:29:32]
/Users/<username>/go/bin/mockgen: invalid signature (code or signature have been modified)
In architecture: arm64
$ codesign -f -s $(which mockgen) [11:29:46]
error: The specified item could not be found in the keychain.
I got this error but the way @jpotterm mentioned worked for me
$ CGO_ENABLED=0 go install go.uber.org/mock/mockgen@latest
$ mockgen -version [11:30:26]
v0.4.0
I faced the same issue when we upgraded our MacOS CI hosts from Xcode version 15.1 to 16.2
I guess clang also gets updated with MacOS and Xcode.
We are at mockgen version v0.4.0
Thanks for CGO_ENABLED=0 workaround, this does fix the issue.
https://github.com/status-im/status-desktop/pull/17084/commits/0498865513c11c4349d31276c781f513cb2b073c
It is worth noting that this issue was also fixed for me after I bumped golang version in CI from 1.22.3 to 1.22.10
Maybe just upgrading golang to 1.22.10 is a simpler fix.
Upgrading from Go 1.21 to 1.23 fixed it for me!