labring / sealos

Sealos is a production-ready Kubernetes distribution. You can run any Docker image on sealos, start high availability databases like mysql/pgsql/redis/mongo, develop applications using any Programming language.
https://cloud.sealos.io
Apache License 2.0
14.08k stars 2.08k forks source link

BUG: build failed on macos #1342

Closed fanux closed 2 years ago

fanux commented 2 years ago

➜ 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

SignorMercurio commented 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 for x86_64-linux-gnu-gcc on x64 platforms and aarch64-linux-gnu-gcc on ARM64 platforms. It used to look for gcc 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 build lvscare, just type make build BINS=lvscare.

fanux commented 2 years ago

seems the makefile auto check macos and disable cgo?

SignorMercurio commented 2 years ago

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.

idevz commented 2 years ago

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
fanux commented 2 years ago

brew install filosottile/musl-cross/musl-cross

zouchengli commented 3 months ago

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

yacki commented 3 months ago

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?