Skip to content

fix(build): overrides without specifying goarm64 et al #5298

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

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

caarlos0
Copy link
Member

this will use the default value for GOMIPS, GOARM, GO386, and etc in build overrides if they are not specified.

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@caarlos0 caarlos0 added the bug Something isn't working label Nov 19, 2024
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 19, 2024
@caarlos0
Copy link
Member Author

@caarlos0 caarlos0 merged commit 10ab79f into main Nov 22, 2024
18 checks passed
@caarlos0 caarlos0 deleted the build-overrides branch November 22, 2024 00:10
andrew-farries added a commit to xataio/pgroll that referenced this pull request Dec 11, 2024
Building `pgroll` now requires a functioning C toolchain on each
platform we aim to support, due to taking a dependency on
[pg_query_go](https://github.com/pganalyze/pg_query_go) for the
`sql2pgroll` package:
[pg_query_go](https://github.com/pganalyze/pg_query_go) requires
`CGO_ENABLED` to build.

This PR adds a new `cross-build` job in the CI workflow to build
`pgroll` binaries for each of our supported platforms:

* `linux/amd64`
* `linux/arm64`
* `darwin/amd64`
* `darwin/arm64`
* `windows/amd64`

The job runs in a
[goreleaser/goreleaser-cross](https://github.com/goreleaser/goreleaser-cross)
container in order to have access to a functioning C toolchain for each
of the above platforms. The `builds` section of the`.goreleaser.yaml`
config file is extended with an `overrides` section to configure the C
compiler for each platform build:

```yaml
      - goos: windows
        goarch: amd64
        env:
          - CC=x86_64-w64-mingw32-gcc
          - CGO_LDFLAGS=-lssp -static
      - goos: linux
        goarch: amd64
        env:
          - CC=x86_64-linux-gnu-gcc
      - goos: linux
        goarch: arm64
        env:
          - CC=aarch64-linux-gnu-gcc
      - goos: darwin
        goarch: amd64
        env:
          - CC=o64-clang
      - goos: darwin
        goarch: arm64
        env:
          - CC=oa64-clang
```

The values for the `CC` env var set the C compiler to use for each
OS/Arch target and are taken from the [goreleaser-cross
docs](https://github.com/goreleaser/goreleaser-cross?tab=readme-ov-file#supported-toolchainsplatforms).
The Windows build requires extra linker flags:

```
CGO_LDFLAGS=-lssp -static
```

due to having to link to the libssp stack-protection library and
statically link to avoid the runtime dependency on that library.

The job runs in a `surjection/goreleaser-cross:v1.23-v2.4.8` container,
which is NOT an official
[goreleaser/goreleaser-cross](https://hub.docker.com/r/goreleaser/goreleaser-cross/tags)
image. This image was built with this `Dockerfile`:

```dockerfile
FROM goreleaser/goreleaser-cross:v1.23-v2.4.4

WORKDIR /tmp

RUN wget https://github.com/goreleaser/goreleaser/releases/download/v2.4.8/goreleaser_Linux_x86_64.tar.gz \
  && tar -xvzf goreleaser_Linux_x86_64.tar.gz \
  && mv goreleaser /usr/bin/goreleaser

WORKDIR /
```

ie it installs the latest version Goreleaser `2.4.8` into the most
recent `goreleaser/goreleaser-cross` image. Once a
`goreleaser/goreleaser-cross` image using `goreleaser` `2.4.8` is
released we can switch back to the official images. Version `2.4.8` is
required due to a bug in earlier `goreleaser` versions that prevents the
`overrides` section in the `.goreleaser.yaml` file from working
(goreleaser/goreleaser#5298).

A `.zip` file containing the binaries for each supported platform is
uploaded as an artifact at the end of the job.
andrew-farries added a commit to xataio/pgroll that referenced this pull request Jan 17, 2025
Stop using the custom image that was built as part of #525 and use an
offcial `gorelaser-cross` image instead. The image is used as the
container in which to build the project for multiple platforms. The
image provides C toolchains for all the platforms supported by `pgroll`.

The official image now uses `goreleaser` `v2.4.8` which contains the fix
for the bug (goreleaser/goreleaser#5298) that we
  were using the custom image to work around.
andrew-farries added a commit to xataio/pgroll that referenced this pull request Jan 17, 2025
…uilds (#604)

Stop using the custom `goreleaser-cross` image that was built as part of
#525 and use an official `gorelaser-cross` image instead. The image is
used as the container in which to build the project for multiple
platforms. The image provides C toolchains for all the platforms
supported by `pgroll`.

The official image now uses `goreleaser` `v2.4.8` which contains the fix
for the bug (goreleaser/goreleaser#5298) that we
were using the custom image to work around.
andrew-farries added a commit to xataio/pgroll that referenced this pull request Jan 22, 2025
Stop using the custom `goreleaser-cross` image that was built as part of
used as the container in which to build the project for multiple
platforms. The image provides C toolchains for all the platforms
supported by `pgroll`.

The official image now uses `goreleaser` `v2.4.8` which contains the fix
for the bug (goreleaser/goreleaser#5298) that we
were using the custom image to work around.
andrew-farries added a commit to xataio/pgroll that referenced this pull request Jan 22, 2025
Stop using the custom `goreleaser-cross` image that was built as part of
used as the container in which to build the project for multiple
platforms. The image provides C toolchains for all the platforms
supported by `pgroll`.

The official image now uses `goreleaser` `v2.4.8` which contains the fix
for the bug (goreleaser/goreleaser#5298) that we
were using the custom image to work around.
andrew-farries added a commit to xataio/pgroll that referenced this pull request Jan 22, 2025
Stop using the custom `goreleaser-cross` image that was built as part of
used as the container in which to build the project for multiple
platforms. The image provides C toolchains for all the platforms
supported by `pgroll`.

The official image now uses `goreleaser` `v2.4.8` which contains the fix
for the bug (goreleaser/goreleaser#5298) that we
were using the custom image to work around.

Follow up to #604 that updated the image elsewhere in the workflow but
forgot to update this one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant