Skip to content

Commit

Permalink
🐛 Refactor go-build option
Browse files Browse the repository at this point in the history
Signed-off-by: vankichi <[email protected]>
  • Loading branch information
vankichi committed Feb 9, 2024
1 parent 4248f8b commit a8ab4a7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile.d/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ binary/build: \
cmd/agent/core/ngt/ngt: \
ngt/install
$(eval CGO_ENABLED = 1)
$(call go-build,agent/core/ngt,-linkmode 'external',-static -fPIC -pthread -fopenmp -std=gnu++20 -lstdc++ -lm -z relro -z now $(EXTLDFLAGS), cgo,NGT-$(NGT_VERSION),$@)
$(call go-build,agent/core/ngt,-linkmode 'external',-static -fPIC -pthread -fopenmp -std=gnu++20 -lstdc++ -lm -z relro -z now $(EXTLDFLAGS), cgo,NGT-$(NGT_VERSION),$@,CC_FOR_TARGET=${TARGET CC=${CC}})

cmd/agent/core/faiss/faiss: \
faiss/install
Expand Down
1 change: 1 addition & 0 deletions Makefile.d/functions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ define go-build
GOOS=$(GOOS) \
GOPRIVATE=$(GOPRIVATE) \
GO_VERSION=$(GO_VERSION) \
$7 \
go build \
--ldflags "-w $2 \
-extldflags '$3' \
Expand Down
4 changes: 3 additions & 1 deletion dockers/agent/core/ngt/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ RUN --mount=type=cache,target="${GOPATH}/pkg",id="go-build-${TARGETARCH}" \
--mount=type=cache,target="${HOME}/.cache/go-build",id="go-build-${TARGETARCH}" \
if [ "${TARGETARCH}" = "amd64" ] ; then \
export CC=${XARCH}-${TARGETOS}-gnu-gcc; \
export TARGET=gcc-${XARCH_GCC}-${TARGETOS}-gnu ; \
elif [ "${TARGETARCH}" = "arm64" ] ; then \
export CC=${AARCH_GCC}-${TARGETOS}-gnu-gcc; \
export TARGET=gcc-${AARCH_GCC}-${TARGETOS}-gnu ; \
fi \
&& make GOARCH=${TARGETARCH} GOOS=${TARGETOS} CC_FOR_TARGET=${CC} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \
&& make GOARCH=${TARGETARCH} GOOS=${TARGETOS} REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \
&& mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}"

WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG}
Expand Down

0 comments on commit a8ab4a7

Please sign in to comment.