why cgo is not supported? #2757
-
Hello! What is main reason why cgo is not supported? |
Beta Was this translation helpful? Give feedback.
Answered by
hugelgupf
Feb 20, 2024
Replies: 1 comment
-
It's possible that cgo could work, but the way gobusybox works involves some rewriting of source, and creating a bunch of stuff in temporary directories as described here. It'd presumably break cgo compilations. We don't plan to support it ourselves as the mixing of Go and C using cgo bloats binary size (e.g. not that easy to do dead code elimination). Downstream users that need to use C in their initramfs images tend to build a small, statically linked C binary and call it from Go instead. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hugelgupf
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's possible that cgo could work, but the way gobusybox works involves some rewriting of source, and creating a bunch of stuff in temporary directories as described here. It'd presumably break cgo compilations.
We don't plan to support it ourselves as the mixing of Go and C using cgo bloats binary size (e.g. not that easy to do dead code elimination). Downstream users that need to use C in their initramfs images tend to build a small, statically linked C binary and call it from Go instead.