-
Notifications
You must be signed in to change notification settings - Fork 71
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
Allow to statically link Go programs, even with cgo #207
Conversation
Looks like a couple of AppImages get built successfully, but then:
Seems like there are some leftovers from earlier runs? |
So, we can build static binaries but currently only for the host architecture. |
Possibly use https://dev.to/kristoff/zig-makes-go-cross-compilation-just-work-29ho Looks like it can be used with musl libc: |
[ci skip]
[ci skip]
You can use this approach to deal with the outer directory from the Zig tarball: https://github.com/ziglang/www.ziglang.org/blob/master/.github/workflows/build.yml#L30 |
Are you sure you need |
For this arch we error out.
|
No, it was a wild guess. |
You probably do need to use a different musl version for 32bit arm though. I'm not familiar enough but IIRC you need to know a bit more about your target. @MasterQ32 where can one find a concise guide that explains how to select the correct ABI for |
[
"aarch64_be-linux-gnu",
"aarch64_be-linux-musl",
"aarch64_be-windows-gnu",
"aarch64-linux-gnu",
"aarch64-linux-musl",
"aarch64-windows-gnu",
"aarch64-macos-gnu",
"aarch64-macos-gnu",
"armeb-linux-gnueabi",
"armeb-linux-gnueabihf",
"armeb-linux-musleabi",
"armeb-linux-musleabihf",
"armeb-windows-gnu",
"arm-linux-gnueabi",
"arm-linux-gnueabihf",
"arm-linux-musleabi",
"arm-linux-musleabihf",
"thumb-linux-gnueabi",
"thumb-linux-gnueabihf",
"thumb-linux-musleabi",
"thumb-linux-musleabihf",
"arm-windows-gnu",
"csky-linux-gnueabi",
"csky-linux-gnueabihf",
"i386-linux-gnu",
"i386-linux-musl",
"i386-windows-gnu",
"m68k-linux-gnu",
"m68k-linux-musl",
"mips64el-linux-gnuabi64",
"mips64el-linux-gnuabin32",
"mips64el-linux-musl",
"mips64-linux-gnuabi64",
"mips64-linux-gnuabin32",
"mips64-linux-musl",
"mipsel-linux-gnueabi",
"mipsel-linux-gnueabihf",
"mipsel-linux-musl",
"mips-linux-gnueabi",
"mips-linux-gnueabihf",
"mips-linux-musl",
"powerpc64le-linux-gnu",
"powerpc64le-linux-musl",
"powerpc64-linux-gnu",
"powerpc64-linux-musl",
"powerpc-linux-gnueabi",
"powerpc-linux-gnueabihf",
"powerpc-linux-musl",
"riscv64-linux-gnu",
"riscv64-linux-musl",
"s390x-linux-gnu",
"s390x-linux-musl",
"sparc-linux-gnu",
"sparcv9-linux-gnu",
"wasm32-freestanding-musl",
"wasm32-wasi-musl",
"x86_64-linux-gnu",
"x86_64-linux-gnux32",
"x86_64-linux-musl",
"x86_64-windows-gnu",
"x86_64-macos-gnu",
"x86_64-macos-gnu",
"x86_64-macos-gnu"
] |
It built something, which is good. But the binaries are neither static nor stripped it seems:
|
Can you run |
It just executes it, no ldd output. So it seems "semi-static"? |
|
note that those flags that you added in the last commit ( |
ed62251 behaves best so far.
But it is still not stripped... |
What the *
|
What got built is looking good now. Next step: Functionality testing on a Linux client machine. |
First quick tests looking good! @kristoff-it @andrewrk thank you very, very much for your help. |
Re. stripping: what about passing |
Use zig as a cc substitute to statically link Go programs, even with cgo, using musl libc. Doing it this way has the advantage that no Docker container or chroots are needed for building multiple architectures.
Continuation of #203