#1151040 dh-golang: Set GOAMD64 based on DEB_HOST_ARCH_VARIANT for microarchitecture builds

#1151040#5
Date:
2026-10-16 10:58:49 UTC
From:
To:
Dear Maintainer,

[Goal]
Enable microarchitecture variant support (like amd64v3) for Go packages built in the archive.

[Problem]
Currently, if a build is triggered with DEB_HOST_ARCH_VARIANT=amd64v3, dpkg-buildflags correctly translates this for bundled C/C++ code.
However, the native Go compiler ignores this and continues to build at the baseline amd64 level.
To actually utilize these optimizations, Go (since 1.18) requires the GOAMD64 environment variable to be set.

[Proposed Solution]
We need dh-golang to act as the bridge. dh-golang should read the DEB_HOST_ARCH_VARIANT environment variable provided by dpkg and explicitly export GOAMD64.

For example, if $ENV{DEB_HOST_ARCH} is amd64 and $ENV{DEB_HOST_ARCH_VARIANT} is amd64v3, dh-golang should extract the v3 and set GOAMD64=v3 in the build environment (provided the package maintainer hasn't already explicitly overridden it).

I am currently putting together a patch for lib/Debian/Debhelper/Buildsystem/golang.pm to implement this and will attach it to this bug report shortly.

#1151040#10
Date:
2026-10-21 11:11:35 UTC
From:
To:
Hello,

Just a quick update. Instead of attaching a patch file here, I have opened
a merge request on Salsa with the implemented subroutine.

You can review the changes here:
https://salsa.debian.org/go-team/packages/dh-golang/-/merge_requests/31

Let me know if any adjustments are needed.

Thanks,
Sumit