diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk index a3421af288..bdf8de4d66 100644 --- a/package/pkg-golang.mk +++ b/package/pkg-golang.mk @@ -118,6 +118,16 @@ $(2)_EXTLDFLAGS += -static $(2)_TAGS += osusergo netgo endif +ifeq ($(BR2_aarch64),y) +# Go forces use of the Gold linker on aarch64 due to a bug in BFD that +# is fixed in Binutils >= 2.41 (that includes all versions provided by +# Buildroot). Forcing Gold will break with toolchains that don't +# provide it (like the Buildroot toolchains), so override the flag and +# use BFD. +# See: https://github.com/golang/go/issues/22040 +$(2)_EXTLDFLAGS += -fuse-ld=bfd +endif + ifneq ($$($(2)_EXTLDFLAGS),) $(2)_LDFLAGS += -extldflags '$$($(2)_EXTLDFLAGS)' endif