Skip to content

Commit

Permalink
Disable CGO
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjinx committed Jan 18, 2024
1 parent bbbf3c2 commit e9925c7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ endif
# Safe, since this code isn't performance critical.
export CGO_CFLAGS := -O1

# Disable CGO explicitly
export CGO_ENABLED=0

# build the vitess binaries with dynamic dependency on libc
build-dyn:
ifndef NOBANNER
echo $$(date): Building source tree
endif
bash ./build.env
CGO_ENABLED=0 go install -trimpath $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) -ldflags "$(shell tools/build_version_flags.sh)" ./go/...
go install -trimpath $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) -ldflags "$(shell tools/build_version_flags.sh)" ./go/...

# build the vitess binaries statically
build:
Expand All @@ -63,7 +66,7 @@ ifndef NOBANNER
endif
bash ./build.env
# build all the binaries by default with CGO disabled.
CGO_ENABLED=0 go install -trimpath $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) -ldflags "$(shell tools/build_version_flags.sh)" ./go/...
go install -trimpath $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) -ldflags "$(shell tools/build_version_flags.sh)" ./go/...

# cross-build can be used to cross-compile Vitess client binaries
# Outside of select client binaries (namely vtctlclient & vtexplain), cross-compiled Vitess Binaries are not recommended for production deployments
Expand All @@ -76,7 +79,7 @@ endif
# In order to cross-compile, go install requires GOBIN to be unset
export GOBIN=""
# For the specified GOOS + GOARCH, build all the binaries by default with CGO disabled
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go install -trimpath $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) -ldflags "$(shell tools/build_version_flags.sh)" ./go/...
GOOS=${GOOS} GOARCH=${GOARCH} go install -trimpath $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) -ldflags "$(shell tools/build_version_flags.sh)" ./go/...

if [ ! -x "${HOME}/go/bin/${GOOS}_${GOARCH}/vttablet" ]; then \
echo "Missing vttablet at: ${HOME}/go/bin/${GOOS}_${GOARCH}/vttablet" && exit; \
Expand Down

0 comments on commit e9925c7

Please sign in to comment.