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

How to build for arm64 #237

Closed
cwegener opened this issue Apr 22, 2021 · 2 comments
Closed

How to build for arm64 #237

cwegener opened this issue Apr 22, 2021 · 2 comments

Comments

@cwegener
Copy link

I've tried to cross-compile for GOARCH=arm64 but the resulting build fails to execute on arm64 when using dynamic CGO linking due to GLIBC version mismatches of my build host and the target host.

And with static CC compiler flags, the resulting binary segfaults with

usql: dl-call-libc-early-init.c:37: _dl_call_libc_early_init: Assertion `sym != NULL' failed.
SIGABRT: abort
PC=0xa60894 m=0 sigcode=18446744073709551610
signal arrived during cgo execution

Is there a supported cross-compile procedure?

NOTE: The target platform is Ubuntu 20.04 on arm64 (Neoverse / Graviton)

@cwegener
Copy link
Author

Update - building natively with go build on Ubuntu 20.04 arm64 results in a perfectly usable binary.

@kenshaw
Copy link
Member

kenshaw commented Apr 22, 2021

Great to know you were able to build it. While Go is pretty good at cross-compilation, one of the main drivers that are enabled by default (sqlite3) requires CGO. As such, cross-compilation is probably non-trivial if building the default set of drivers.

However, this was able to work:

ken@ken-desktop:~/src/go/src/github.com/xo/usql$ GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags 'most no_sqlite3 no_adodb'
ken@ken-desktop:~/src/go/src/github.com/xo/usql$ file usql 
usql: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=aUHBc2_VPTSSDPrtiy9X/qE4C7u031VTFQmW6gyLF/FN56j3I978g4cr_78aMY/rkoEMBaBIhyGPHFT7PQd, not stripped
ken@ken-desktop:~/src/go/src/github.com/xo/usql$ 

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

No branches or pull requests

2 participants