Skip to content

Conversation

@yosifkit
Copy link
Member

Disable cgo to fix build failure on GHA windows-2022

Example failure from PRs to official-images:

go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
# github.com/docker-library/bashbrew/cmd/bashbrew
C:\hostedtoolcache\windows\go\1.18.10\x64\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\RUNNER~1\AppData\Local\Temp\go-link-3224421645\000008.o: in function `_cgo_preinit_init':
\\_\_\runtime\cgo/gcc_libinit_windows.c:30: undefined reference to `__imp___iob_func'
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\RUNNER~1\AppData\Local\Temp\go-link-3224421645\000008.o: in function `x_cgo_sys_thread_create':
\\_\_\runtime\cgo/gcc_libinit_windows.c:60: undefined reference to `__imp___iob_func'
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\RUNNER~1\AppData\Local\Temp\go-link-3224421645\000008.o: in function `x_cgo_notify_runtime_init_done':
\\_\_\runtime\cgo/gcc_libinit_windows.c:101: undefined reference to `__imp___iob_func'
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\RUNNER~1\AppData\Local\Temp\go-link-3224421645\000009.o: in function `x_cgo_thread_start':
\\_\_\runtime\cgo/gcc_util.c:18: undefined reference to `__imp___iob_func'
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\RUNNER~1\AppData\Local\Temp\go-link-3224421645\000010.o: in function `_cgo_sys_thread_start':
\\_\_\runtime\cgo/gcc_windows_amd64.c:31: undefined reference to `__imp___iob_func'
collect2.exe: error: ld returned 1 exit status

@codecov-commenter
Copy link

codecov-commenter commented Sep 25, 2023

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.10%. Comparing base (6334a4f) to head (c4273aa).
Report is 65 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #83   +/-   ##
=======================================
  Coverage   73.10%   73.10%           
=======================================
  Files           7        7           
  Lines         714      714           
=======================================
  Hits          522      522           
  Misses        162      162           
  Partials       30       30           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

action.yml Outdated
with:
go-version-file: '${{ github.action_path }}/go.mod'
env:
CGO_ENABLED: 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we instead add this to

export GO111MODULE=on
?

(with : "${CGO_ENABLED:=0}")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think that makes sense.

$ git grep -i cgo
Dockerfile:RUN CGO_ENABLED=0 ./bashbrew.sh --version; \
Dockerfile.release:ENV CGO_ENABLED 0
action.yml:        CGO_ENABLED: 0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now moved to bashbrew.sh. We could drop it from the Dockerfile but it seems fine to be explicit there and in the Dockerfile.release.

$ git grep -i cgo
Dockerfile:RUN CGO_ENABLED=0 ./bashbrew.sh --version; \
Dockerfile.release:ENV CGO_ENABLED 0
bashbrew.sh:: "${CGO_ENABLED:=0}"
bashbrew.sh:export GO111MODULE=on CGO_ENABLED

Disable cgo to fix build failure on GHA windows-2022
@tianon tianon merged commit a226be9 into master Sep 26, 2023
@tianon tianon deleted the windows-workflow branch September 26, 2023 01:12
@whalelines
Copy link

Is there a reason to disable for all rather than just for windows?

@yosifkit
Copy link
Member Author

Just for consistency across OS, architecture, and build pipeline. It was already disabled for the builds using Dockerfile or Dockerfile.release, just not the script directly on a host like GitHub Actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants