Ld reporting unrecognized options when cross compiling rclone for arm64 in buildroot

What is the problem you are having with rclone?

When trying to crosscompile the rclone executable on a debian container I run into the following error only for arm64 platforms. I have a 32 bit arm system I also build for with the exact same buildprocess the only difference is setting GOARCH=arm vs GOARCH=arm64. What's weird is that even when passing in ld arguments via -ldflags="-s -w ...", it ignores it and forces to options "-Wl,-z,now"

The exact error log is as follows:

BR2_ARCH is aarch64
rm -f /root/buildroot_flow/gen/output/build/rclone-v1.68.1/.stamp_installed
rm -f /root/buildroot_flow/gen/output/build/rclone-v1.68.1/.stamp_staging_installed
rm -f /root/buildroot_flow/gen/output/build/rclone-v1.68.1/.stamp_target_installed
rm -f /root/buildroot_flow/gen/output/build/rclone-v1.68.1/.stamp_images_installed
rm -f /root/buildroot_flow/gen/output/build/rclone-v1.68.1/.stamp_host_installed
rm -f /root/buildroot_flow/gen/output/build/rclone-v1.68.1/.stamp_built
>>> host-skeleton  Executing pre-build script /root/buildroot_flow/gen/board/pre-build.sh
This is your Pre-build script
>>> rclone v1.68.1 Building
(cd /root/buildroot_flow/gen/output/build/rclone-v1.68.1; CC="/root/buildroot_flow/gen/output/host/bin/aarch64-buildroot-linux-gnu-gcc" CXX="/root/buildroot_flow/gen/output/host/bin/aarch64-buildroot-linux-gnu-g++" CGO_ENABLED="1" GOOS=linux GOPROXY=https://proxy.golang.org GOPROXYCONNECTTIMEOUT=300s GOARCH=arm64 /root/buildroot_flow/gen/output/host/usr/bin/go build -ldflags="-s -w -extld /root/buildroot_flow/gen/output/host/bin/aarch64-buildroot-linux-gnu-ld" -o rclone .)
# github.com/rclone/rclone
/root/buildroot_flow/gen/output/host/lib/go/pkg/tool/linux_amd64/link: running /root/buildroot_flow/gen/output/host/bin/aarch64-buildroot-linux-gnu-ld failed: exit status 1
/root/buildroot_flow/gen/output/host/bin/aarch64-buildroot-linux-gnu-ld: unrecognized option '-Wl,-z,now'
/root/buildroot_flow/gen/output/host/bin/aarch64-buildroot-linux-gnu-ld: use the --help option for usage information
make[1]: *** [package/pkg-generic.mk:283: /root/buildroot_flow/gen/output/build/rclone-v1.68.1/.stamp_built] Error 1
make: *** [Makefile:23: _all] Error 2
root@fdb96333b3c6:~/buildroot_flow/gen/output#

Run the command 'rclone version' and share the full output of the command.

I ran rclone version but since I am unable to generate the executable, this command fails. I did so regardless per the instructions.

root@fdb96333b3c6:~/buildroot_flow/gen/output# rclone version
bash: rclone: command not found

From my build makefile I am pulling the latest rclone version v1.68.1

Which cloud storage system are you using? (eg Google Drive)

Not applicable, my issue is related to building the executable.

The command you were trying to run (eg rclone copy /tmp remote:tmp)

Not directly applicable but I included my full makefile since I don't have a working 64 bit rclone executable to run commands on.

################################################################################
#
# rclone
#
################################################################################

RCLONE_VERSION = v1.68.1
RCLONE_SITE = $(call github,rclone,rclone,$(RCLONE_VERSION))
RCLONE_LICENSE = MIT
RCLONE_LICENSE_FILES = LICENSE

RCLONE_DEPENDENCIES = host-go

BR2_ARCH = $(shell grep ^BR2_ARCH= $(BR2_CONFIG) | cut -d= -f2 | sed 's/"//g')

$(info BR2_ARCH is $(BR2_ARCH))

GOOS = linux

ifeq ($(BR2_ARCH),aarch64)
    GOARCH = arm64

define RCLONE_BUILD_CMDS
	(cd $(@D); \
	CC="$(TARGET_CROSS)gcc" CXX="$(TARGET_CROSS)g++" CGO_ENABLED="1" GOOS=$(GOOS) GOPROXY=https://proxy.golang.org GOPROXYCONNECTTIMEOUT=300s GOARCH=$(GOARCH) $(HOST_DIR)/usr/bin/go build -ldflags="-s -w -extld $(TARGET_CROSS)ld" -o rclone .)
endef
else ifeq ($(BR2_ARCH),arm)
    GOARCH = arm

define RCLONE_BUILD_CMDS
	(cd $(@D); \
	CC="$(TARGET_CROSS)gcc" CXX="$(TARGET_CROSS)g++" CGO_ENABLED="1" GOOS=$(GOOS) GOPROXY=https://proxy.golang.org GOPROXYCONNECTTIMEOUT=300s GOARCH=$(GOARCH) $(HOST_DIR)/usr/bin/go build -ldflags="-s -w" -o rclone .)
endef
else
    $(error Unsupported architecture: $(BR2_ARCH))
endif





define RCLONE_INSTALL_TARGET_CMDS
	$(TARGET_CROSS)strip $(@D)/rclone
	upx --best --lzma $(@D)/rclone
    $(INSTALL) -D -m 0755 $(@D)/rclone $(TARGET_DIR)/usr/bin/rclone
endef

$(eval $(generic-package))

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

As mentioned prevoiusly, I do not have a working 64 bit rclone executable and as such am unable to get an rclone config. However in the spirit of things I'll run it on my build system.

root@fdb96333b3c6:~/buildroot_flow/gen/output# rclone config redacted
bash: rclone: command not found

A log from the command that you were trying to run with the -vv flag

Not applicable, see previous responses.