Skip to content
Snippets Groups Projects
Unverified Commit 06bd8d98 authored by Oliver Smith's avatar Oliver Smith
Browse files

cross-native2: set CGO_CFLAGS, CGO_LDFLAGS (MR 2565)

Cross compiling go programs with cross-native2 fails for armv7, riscv64
and armhf unless we use CGO_ENABLED=1 in the APKBUILD (see related
aports issue).

Add --sysroot to CGO_CFLAGS, so cgo can find the includes and doesn't
fail with:

  go build -buildmode=pie -modcacherw -trimpath -buildvcs=false -ldflags "-s -w -X main.Version=2.6.1" -o mkinitfs ./cmd/mkinitfs
  # runtime/cgo
  _cgo_export.c:3:10: fatal error: stdlib.h: No such file or directory

Add it to LDFLAGS too for linking against libraries from the sysroot.

Related: https://gitlab.alpinelinux.org/alpine/aports/-/issues/15809
Related: https://stackoverflow.com/a/38835938
parent 32389415
No related branches found
No related tags found
1 merge request!2565cross-native2: set CGO_CFLAGS, CGO_LDFLAGS
Pipeline #216921 passed
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment