Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS build fails: undefined reference to `__fprintf_chk' #2135

Closed
iameli opened this issue Feb 2, 2022 · 2 comments
Closed

macOS build fails: undefined reference to `__fprintf_chk' #2135

iameli opened this issue Feb 2, 2022 · 2 comments

Comments

@iameli
Copy link

iameli commented Feb 2, 2022

Describe the bug
This comment suggests a Darwin build of Victoria Metrics can be created like so:

GOARCH=arm64 GOOS=darwin make package-victoria-metrics

When I run that I get some C compilation errors:

APP_NAME=victoria-metrics /Library/Developer/CommandLineTools/usr/bin/make package-via-docker
(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q 'local/base:1.1.3-alpine_3.15.0-alpine_3.15.0$') \
		|| docker build \
			--build-arg root_image=alpine:3.15.0 \
			--build-arg certs_image=alpine:3.15.0 \
			--tag local/base:1.1.3-alpine_3.15.0-alpine_3.15.0 \
			deployment/docker/base
(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q 'victoriametrics/victoria-metrics:v1.72.0$') || (\
		/Library/Developer/CommandLineTools/usr/bin/make app-via-docker && \
		docker build \
			--build-arg src_binary=victoria-metrics-prod \
			--build-arg base_image=local/base:1.1.3-alpine_3.15.0-alpine_3.15.0 \
			--tag victoriametrics/victoria-metrics:v1.72.0 \
			-f app/victoria-metrics/deployment/Dockerfile bin)
(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q 'local/builder:2.0.0-golang_1.17.6-alpine$') \
		|| docker build \
			--build-arg go_builder_image=golang:1.17.6-alpine \
			--tag local/builder:2.0.0-golang_1.17.6-alpine \
			deployment/docker/builder
mkdir -p gocache-for-docker
docker run --rm \
		--user 501:20 \
		--mount type=bind,src="/Users/iameli/code/VictoriaMetrics",dst=/VictoriaMetrics \
		-w /VictoriaMetrics \
		--mount type=bind,src="/Users/iameli/code/VictoriaMetrics/gocache-for-docker",dst=/gocache \
		--env GOCACHE=/gocache \
		--env GO111MODULE=on \
		 \
		local/builder:2.0.0-golang_1.17.6-alpine \
		go build  -mod=vendor -trimpath \
			-ldflags "-extldflags '-static' -X 'github.com/VictoriaMetrics/VictoriaMetrics/lib/buildinfo.Version=victoria-metrics-20220202-062702-tags-v1.72.0-0-gd79a9155'" \
			-tags 'netgo osusergo nethttpomithttp2 musl' \
			-o bin/victoria-metrics-prod github.com/VictoriaMetrics/VictoriaMetrics/app/victoria-metrics
# github.com/valyala/gozstd
/usr/lib/gcc/aarch64-alpine-linux-musl/10.3.1/../../../../aarch64-alpine-linux-musl/bin/ld: vendor/github.com/valyala/gozstd/libzstd_linux_arm64.a(zdict.o): in function `ZDICT_analyzeEntropy':
zdict.c:(.text+0x700): undefined reference to `__fprintf_chk'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.3.1/../../../../aarch64-alpine-linux-musl/bin/ld: zdict.c:(.text+0xb14): undefined reference to `__fprintf_chk'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.3.1/../../../../aarch64-alpine-linux-musl/bin/ld: vendor/github.com/valyala/gozstd/libzstd_linux_arm64.a(zdict.o): in function `ZDICT_analyzePos':
zdict.c:(.text+0x168c): undefined reference to `__fprintf_chk'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.3.1/../../../../aarch64-alpine-linux-musl/bin/ld: zdict.c:(.text+0x16f8): undefined reference to `__fprintf_chk'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.3.1/../../../../aarch64-alpine-linux-musl/bin/ld: vendor/github.com/valyala/gozstd/libzstd_linux_arm64.a(zdict.o): in function `ZDICT_finalizeDictionary':
zdict.c:(.text+0x1a2c): undefined reference to `__fprintf_chk'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.3.1/../../../../aarch64-alpine-linux-musl/bin/ld: vendor/github.com/valyala/gozstd/libzstd_linux_arm64.a(zdict.o):zdict.c:(.text+0x1ce4): more undefined references to `__fprintf_chk' follow
collect2: error: ld returned 1 exit status
make[2]: *** [app-via-docker] Error 2
make[1]: *** [package-via-docker] Error 2
make: *** [package-victoria-metrics] Error 2
@f41gh7
Copy link
Contributor

f41gh7 commented Feb 2, 2022

Sorry, comment is misleading, actual command for local build:
make victoria-metrics - it requires golang installed at host system and it produces darwin/arm64 binary at macOS m1 system.

For production build and packaging - linux/amd64:

DOCKER_DEFAULT_PLATFORM=linux/amd64 make package-victoria-metrics

@f41gh7
Copy link
Contributor

f41gh7 commented Mar 22, 2022

Production ready builds now available for macos darwin/m1

@f41gh7 f41gh7 closed this as completed Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants