-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] CGO_ENABLED on macos amd64 is not correct #477
Comments
Hello @timandy, zthank you for creating this issue and we will look into it :) |
I suspect this might be something to do with those versions of Go being built differently/in such a way that they don't support cross compilation. Possibly related to #181 EDIT: digging a bit more I see
files take from:
Indeed I see the same output in the upstream download from https://go.dev/dl/#go1.20.14 🤔 I wonder if those are meant to be there (via |
Hi @timandy, When GOOS and GOARCH are manually specified, the Go compiler typically enters cross-compilation mode and defaults CGO_ENABLED to '0', effectively disabling cgo. Exceptions exist for certain platforms, notably Linux and Windows. Even with GOOS and GOARCH manually set, CGO_ENABLED remains '1', leaving cgo enabled. This is attributed to Go's reliable support for these platforms. These are default behaviors and can be overridden if necessary. For example, if macOS builds necessitate cgo, CGO_ENABLED can be manually set to '1'. However, the build environment must be capable of cross-compiling C code for macOS.
|
@gowridurgad Thanks for your detailed answer, I will close this issue now. |
@gowridurgad Sorry for reopen this issue. https://github.com/timandy/routine/actions/runs/9475193593/job/26106126731 # darwin
- name: 'Test on [darwin] arch [amd64]'
if: ${{ matrix.os == 'darwin' && contains(fromJson('["amd64"]'), matrix.arch) }}
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 1
run: |
echo ${CGO_ENABLED}
go env CGO_ENABLED
go test -v -race -coverprofile="coverage.txt" -covermode=atomic ./... |
Following from what I found above, I believe this is due to a change in how Go is built upstream, given the errors you see look to be similar to those in golang/go#42382 (i.e. missing
based on the above, I suspect that if you also tried to build on Go 1.17 (or older) you'd see the issue there too |
@matthewhughes934 Thanks a lot. I found that github has upgrade macos-lastest to M1 CPU. That cause my amd64 race test work flow runs on arm64. |
Hi @timandy, Starting from Go version 1.20, the dependency on cgo for the race detector has been removed on macOS. This allows for the building and running of programs with the race detector enabled without the requirement of Xcode. So From Go version 1.20 onwards, the race test can be executed successfully, regardless of whether CGO_ENABLED is set to '0' or '1'.. It's important to note that for Linux, other Unix systems, and Windows, a host C toolchain remains necessary to use the race The build failure, even with CGO enabled (CGO_ENABLED=1), is due to a mismatch between the build and target architectures. In this case, the build architecture is ARM64, while the target architecture is AMD64. However, by disabling the race detector, the workflow runs successfully. Her's the screenshots for your reference. |
Description:
A clear and concise description of what the bug is.
Action version:
actions/setup-go@v5
Platform:
Runner type:
Tools version:
go 1.18
go 1.19
Repro steps:
Expected behavior:
go env CGO_ENABLED //should be 1
Actual behavior:
printed 0, On windows and linux print 1
mac
https://github.com/timandy/routine/actions/runs/8965563348/job/24619393933#step:4:11
linux
https://github.com/timandy/routine/actions/runs/8965563348/job/24619398442#step:6:11
The text was updated successfully, but these errors were encountered: