Skip to content
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

Disable cgo by default? #29

Closed
bewuethr opened this issue Dec 20, 2022 · 1 comment · Fixed by #31
Closed

Disable cgo by default? #29

bewuethr opened this issue Dec 20, 2022 · 1 comment · Fixed by #31

Comments

@bewuethr
Copy link
Contributor

bewuethr commented Dec 20, 2022

When running this on an Ubuntu runner, the binaries for linux-amd64 use CGO_ENABLED=1:

GOOS="$goos" GOARCH="$goarch" go build -trimpath -ldflags="-s -w" -o "dist/${p}${ext}"

builds without setting it, so (as far as I know) cgo is disabled for cross-compilation, but enabled when building for the target architecture of the runner.

As a result, if I use an ubuntu-22.04 runner, but then install the extension on an older Ubuntu such as 20.04, I get glibc.so mismatches like this:

/home/benjamin/.local/share/gh/extensions/gh-myextension/gh-myextension: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /home/benjamin/.local/share/gh/extensions/gh-myextension/gh-myextension)
/home/benjamin/.local/share/gh/extensions/gh-myextension/gh-myextension: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /home/benjamin/.local/share/gh/extensions/gh-myextension/gh-myextension)

This can be fixed by explicitly disabling cgo:

      - name: Publish CLI extension
        uses: cli/[email protected]
        env:
          CGO_ENABLED: 0

Maybe this should be the default, or at least documented in the README?

@mislav
Copy link
Contributor

mislav commented Dec 21, 2022

Agreed about disabled being the default. We do it for the gh codebase: https://github.com/cli/cli/blob/1f85a92463d766c7ea6fa4fba2e7c08a37f5f5ab/.goreleaser.yml#L29

You're welcome to send a PR 👍

cschleiden added a commit to cschleiden/gh-effective-workflow that referenced this issue Jan 13, 2023
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 a pull request may close this issue.

2 participants