misc: disable cgo by default (#20423)

* misc: disable cgo by default

* fix(host): container isolated device skip get numa node
This commit is contained in:
wanyaoqi
2024-05-31 19:00:37 +08:00
committed by GitHub
parent c2a302e2f8
commit b29390d0e6
3 changed files with 28 additions and 10 deletions

View File

@@ -89,11 +89,14 @@ vet:
# cmd/esxi-agent: prepare_dir
# CGO_ENABLED=0 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@
cmd/fetcherfs: prepare_dir
CGO_ENABLED=0 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@
cmd/host: prepare_dir
CGO_ENABLED=1 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@
cmd/host-image: prepare_dir
CGO_ENABLED=1 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@
cmd/%: prepare_dir
$(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@
CGO_ENABLED=0 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@
rpm/%: cmd/%
$(BUILD_SCRIPT) $*

View File

@@ -64,6 +64,10 @@ func (c BaseDevice) GetNvidiaMpsThreadPercentage() int {
return -1
}
func (c BaseDevice) GetNumaNode() (int, error) {
return -1, nil
}
func CheckVirtualNumber(dev *isolated_device.ContainerDevice) error {
if dev.VirtualNumber <= 0 {
return errors.Errorf("virtual_number must > 0")

View File

@@ -157,6 +157,16 @@ build_process() {
local arch=$2
local is_all_arch=$3
local img_name=$(get_image_name $component $arch $is_all_arch)
local build_env=""
case "$component" in
host | host-image)
build_env="$build_env CGO_ENABLED=1"
;;
*)
build_env="$build_env CGO_ENABLED=0"
;;
esac
build_bin $component
if [[ "$DRY_RUN" == "true" ]]; then
@@ -174,13 +184,14 @@ build_process_with_buildx() {
local is_all_arch=$3
local img_name=$(get_image_name $component $arch $is_all_arch)
build_env="GOARCH=$arch"
if [[ "$arch" == arm64 ]]; then
build_env="$build_env"
if [[ $component == host ]]; then
build_env="$build_env CGO_ENABLED=1"
fi
fi
case "$component" in
host | host-image)
build_env="$build_env CGO_ENABLED=1"
;;
*)
build_env="$build_env CGO_ENABLED=0"
;;
esac
case "$component" in
host | torrent)