Closed fanux closed 2 years ago
Since CGO_ENABLED=1
is required for sealos now, it's no long possible to build Linux binaries on macOS. This is expected behavior.
More info:
In the latest version
make build
looks forx86_64-linux-gnu-gcc
on x64 platforms andaarch64-linux-gnu-gcc
on ARM64 platforms. It used to look forgcc
on all platforms, which is why building on macOS didn't fail. However,gcc
on macOS is of Apple clang version, rather than GNU version on Linux, which is not expected to produce working binaries on Linux when CGO is enabled.Fortunately, you can build other binaries (
desktop
,image-cri-shim
,lvscare
,sealctl
) anywhere because CGO is disabled for them. For example, if you only want to buildlvscare
, just typemake build BINS=lvscare
.
seems the makefile auto check macos and disable cgo?
makefile auto check macos and disable cgo
Makefile does not do this at present, but it's possible. However, disabling CGO on macOS will make sealos subcommands like images
unusable.
I have also met this issue,and fix it like this:
brew install musl-cross
ln -sf /usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/x86_64-linux-musl-gcc /usr/local/bin/x86_64-linux-gnu-gcc
brew install filosottile/musl-cross/musl-cross
I have also met this issue,and fix it like this:
brew install musl-cross ln -sf /usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/x86_64-linux-musl-gcc /usr/local/bin/x86_64-linux-gnu-gcc
❯ make build ===========> Building binary image-cri-shim v5.0.0.dirty for linux_arm64 ===========> Building binary lvscare v5.0.0.dirty for linux_arm64 ===========> Building binary sealctl v5.0.0.dirty for linux_arm64
../../../go/pkg/mod/github.com/containers/storage@v1.46.1/drivers/quota/projectquota.go:18:10: fatal error: linux/fs.h: No such file or directory
18 | #include <linux/fs.h>
| ^~~~
compilation terminated.
unshare.c:20:10: fatal error: linux/limits.h: No such file or directory
20 | #include <linux/limits.h>
| ^~~~
compilation terminated.
make[1]: [go.build.linux_arm64.sealctl] Error 1
make: [build] Error 2
I have also met this issue,and fix it like this:
brew install musl-cross ln -sf /usr/local/Cellar/musl-cross/0.9.9_1/libexec/bin/x86_64-linux-musl-gcc /usr/local/bin/x86_64-linux-gnu-gcc
❯ make build ===========> Building binary image-cri-shim v5.0.0.dirty for linux_arm64 ===========> Building binary lvscare v5.0.0.dirty for linux_arm64 ===========> Building binary sealctl v5.0.0.dirty for linux_arm64
github.com/containers/storage/drivers/quota
../../../go/pkg/mod/github.com/containers/storage@v1.46.1/drivers/quota/projectquota.go:18:10: fatal error: linux/fs.h: No such file or directory 18 | #include <linux/fs.h> | ^
~~~ compilation terminated.github.com/containers/storage/pkg/unshare
unshare.c:20:10: fatal error: linux/limits.h: No such file or directory 20 | #include <linux/limits.h> | ^
~~~compilation terminated. make[1]: [go.build.linux_arm64.sealctl] Error 1 make: [build] Error 2
same problem, did you resolve it?
➜ sealos git:(feature/infra) ✗ make build ===========> Building binary desktop v4.0.0.alpha.8.dirty for linux_amd64 ===========> Building binary image-cri-shim v4.0.0.alpha.8.dirty for linux_amd64 ===========> Building binary lvscare v4.0.0.alpha.8.dirty for linux_amd64 ===========> Building binary sealctl v4.0.0.alpha.8.dirty for linux_amd64 ===========> Building binary sealos v4.0.0.alpha.8.dirty for linux_amd64
runtime/cgo
cgo: C compiler "x86_64-linux-gnu-gcc" not found: exec: "x86_64-linux-gnu-gcc": executable file not found in $PATH make[1]: [go.build.linux_amd64.sealos] Error 2 make: [build] Error 2