mirror of
https://github.com/labring/sealos.git
synced 2026-08-30 17:58:09 +08:00
fix: no longer explicitly specify cgo_enabled (#1253)
Signed-off-by: maybaby <ybyang7@iflytek.com>
This commit is contained in:
+14
-1
@@ -12,11 +12,24 @@ cd sealos
|
||||
make build
|
||||
```
|
||||
|
||||
You can scp the bin file to your linux host.
|
||||
You can scp the bin file to your linux host.
|
||||
|
||||
If you use multipaas, you can mount the bin dir to the vm:
|
||||
|
||||
```shell script
|
||||
multipass mount /your-bin-dir <name>[:<path>]
|
||||
```
|
||||
|
||||
## Notice About build and cross build
|
||||
|
||||
Since Golang CGO_ENABLED is enabled by default if it is not specified, if you compile the sealos binary of linuxos on
|
||||
macos, it is cross-compiled, and since CGO_ENABLED is not explicitly specified, go will close CGO_ENABLED by default,
|
||||
that is, CGO_ENABLED=0, and compile at this time Some functions of sealos will not be supported, such as
|
||||
'images' subcommand depends on cgo for overlay. At this time, sealos does not support overlay driver by default, and
|
||||
will report "driver not supported" error. Therefore, if you are developing or debugging images storage related
|
||||
functions, it is best to compile sealos in a linux environment such as ubuntu.
|
||||
|
||||
In addition, the final release build of sealos is based on the ubuntu environment of Github Action. The built binary
|
||||
defaults to open CGO and supports overlay driver.
|
||||
|
||||
Then test it locally.
|
||||
|
||||
@@ -48,11 +48,11 @@ go.build.%.sealos:
|
||||
$(eval PLATFORM := $(word 1,$(subst ., ,$*)))
|
||||
$(eval OS := $(word 1,$(subst _, ,$(PLATFORM))))
|
||||
$(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM))))
|
||||
$(eval GO_LDFLAGS += -linkmode external)
|
||||
$(eval GO_LDFLAGS += "")
|
||||
|
||||
@echo "===========> Building binary $(COMMAND) for $(PLATFORM)"
|
||||
@mkdir -p $(BIN_DIR)/$(PLATFORM)
|
||||
CGO_ENABLED=1 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(BIN_DIR)/$(PLATFORM)/$(COMMAND) $(ROOT_PACKAGE)/cmd/$(COMMAND)
|
||||
GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(BIN_DIR)/$(PLATFORM)/$(COMMAND) $(ROOT_PACKAGE)/cmd/$(COMMAND)
|
||||
|
||||
.PHONY: go.build.%.sealctl
|
||||
go.build.%.sealctl:
|
||||
@@ -60,10 +60,10 @@ go.build.%.sealctl:
|
||||
$(eval PLATFORM := $(word 1,$(subst ., ,$*)))
|
||||
$(eval OS := $(word 1,$(subst _, ,$(PLATFORM))))
|
||||
$(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM))))
|
||||
|
||||
@echo "===========> Building binary $(COMMAND) for $(PLATFORM)"
|
||||
@mkdir -p $(BIN_DIR)/$(PLATFORM)
|
||||
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(BIN_DIR)/$(PLATFORM)/$(COMMAND) $(ROOT_PACKAGE)/cmd/$(COMMAND)
|
||||
GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(BIN_DIR)/$(PLATFORM)/$(COMMAND) $(ROOT_PACKAGE)/cmd/$(COMMAND)
|
||||
|
||||
|
||||
.PHONY: go.build
|
||||
go.build: go.build.verify $(addprefix go.build., $(addprefix $(PLATFORM)., $(BINS)))
|
||||
|
||||
Reference in New Issue
Block a user