Skip to content
Snippets Groups Projects

cross-native2: set CGO_CFLAGS, CGO_LDFLAGS

Merged Oliver Smith requested to merge ollieparanoid/pmbootstrap:fix-crossnative2-go into master

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

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading