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

Question about compiling for multiple architectures #336

Open
danprince opened this issue Aug 10, 2022 · 1 comment
Open

Question about compiling for multiple architectures #336

danprince opened this issue Aug 10, 2022 · 1 comment

Comments

@danprince
Copy link

Hey folks, I'm trying build binaries (for multiple architectures) in a project that uses v8go and not having much luck. I haven't compiled projects with CGO enabled before, so it's possible that there are important gaps in my understanding.

Everything builds fine for my own architecture (Darwin arm64) but as soon as I try to build for another architecture or OS, I start seeing C compiler errors/warnings (usually about JSError, although not sure that's relevant).

In theory, should it be possible for me to build my project for, say Intel Macs, or Linux/arm, on this machine? I'm assuming that cross compilation is going to be limited to the vendored builds of V8 in the deps folder, but do I also need to be building on the targeted OS/architecture too?

A rough rundown of how to tackle this kind of cross compilation would be great. Thanks for the project!

@alixander
Copy link

v8go has a dependency on your system's libc. When you compile for your own architecture, your machine's libc gets bundled in. When you compile for a different architecture, it doesn't have the other architecture's libc (and can't use your architecture's), so it won't work.

The way we get around this is by having all the different architectures as remote servers that a build script builds on.

Example here: https://github.com/terrastruct/d2/blob/master/ci/release/build.sh

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