Skip to content

Commit 99bf48e

Browse files
akerouantonthaJeztah
authored andcommitted
Makefile: set CGO_LDFLAGS=-latomic on arm/v6
Compiling with Go >= 1.22 on arm/v6 is failing with the following error message: 27.84 gcc_libinit.c:44:8: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0 bytes) [-Werror,-Watomic-alignment] For these Go versions, we need to manually link to libatomic as arm/v6 does not support atomic intrinsics and neither the CGo, nor the C toolchain automatically link to that library. Signed-off-by: Albin Kerouanton <[email protected]>
1 parent 1041211 commit 99bf48e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ ifeq "$(shell go env GOOS)" "darwin"
1515
export CGO_CFLAGS = -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
1616
endif
1717

18+
ifeq "$(shell go env GOOS)/$(shell go env GOARCH)/$(shell go env GOARM)" "linux/arm/6"
19+
# Neither the CGo compiler, nor the C toolchain automatically link to
20+
# libatomic when the architecture doesn't support atomic intrinsics, as is
21+
# the case for arm/v6.
22+
#
23+
# Here's the error we get when this is not done (see https://github.com/docker/docker-credential-helpers/pull/340#issuecomment-2437593837):
24+
#
25+
# gcc_libinit.c:44:8: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0 bytes) [-Werror,-Watomic-alignment]
26+
export CGO_LDFLAGS=-latomic
27+
endif
28+
1829
.PHONY: all
1930
all: cross
2031

0 commit comments

Comments
 (0)