Skip to content

feat(ms-golang): add Microsoft build of Go as a golang-providing package - #18256

Draft
liunan-ms wants to merge 1 commit into
4.0from
liunan/ms-golang
Draft

feat(ms-golang): add Microsoft build of Go as a golang-providing package#18256
liunan-ms wants to merge 1 commit into
4.0from
liunan/ms-golang

Conversation

@liunan-ms

Copy link
Copy Markdown
Contributor

Description

Adds ms-golang to the Azure Linux 4.0 branch: the Microsoft build of Go, packaged from a local spec ported from the 3.0-dev golang.spec.

Azure Linux 4.0 already ships Fedora's upstream golang. This introduces the Microsoft build alongside it as a distinct package that:

  • builds as ms-golang (rather than golang),
  • keeps Provides: golang so it can satisfy golang dependencies, and
  • declares Conflicts: golang so it cannot be co-installed with the Fedora golang package.

It is maintained as a local spec (not available in Fedora) with release.calculation = "manual" (static Release: + hand-written %changelog). The six Go source tarballs are referenced directly from the public github.com/microsoft/go releases.

Spec adjustments for AzL 4.0

The 3.0-dev spec assumed an older RPM and a root build environment; the following changes make it build under AzL 4.0's RPM 4.20 + unprivileged mock:

  • Bootstrap tree paths — reference the unpacked bootstrap trees via %{_builddir} instead of %{_topdir}/BUILD, since RPM ≥ 4.20 builds inside a per-package subdirectory.
  • go1.4 C bootstrap — compile stage 00 with -std=gnu17; modern gcc defaults to -std=gnu23 where bool is a keyword, which breaks go1.4's typedef int bool; under -Werror.
  • Rolling bootstrap staging — stage the intermediate toolchain under %{_builddir} instead of %{_libdir}/golang; unprivileged mock builds cannot write to /usr/lib64.
  • BuildRequires — add gcc and glibc-devel, which the minimal AzL 4.0 buildroot does not provide implicitly.
  • Provides hygiene — disable automatic find-provides so Go's test-data shared objects (e.g. libtiffxx.so.6) are not exposed as package SONAME Provides; the real interfaces are declared explicitly.

Validation

Build succeeds and produces ms-golang-1.26.5-3.azl4.x86_64.rpm.

Package metadata:

$ rpm -qp --provides  ms-golang-1.26.5-3.azl4.x86_64.rpm
go = 1.26.5-3.azl4
golang = 1.26.5-3.azl4
ms-golang = 1.26.5
ms-golang = 1.26.5-3.azl4
ms-golang(x86-64) = 1.26.5-3.azl4
msft-golang = 1.26.5-3.azl4

$ rpm -qp --conflicts ms-golang-1.26.5-3.azl4.x86_64.rpm
golang

Functional smoke test in a mock chroot:

liunan@CPC-liuna-DKVIY:~/Fedora/azurelinux$ azldev adv mock shell --add-package base/out/rpms/rpm-sdk/ms-golang-1.26.5-3.azl4.x86_64.rpm
<mock-chroot> sh-5.3# go version
go version go1.26.5 linux/amd64
<mock-chroot> sh-5.3# rpm -q --whatprovides golang
ms-golang-1.26.5-3.azl4.x86_64
<mock-chroot> sh-5.3# cd /tmp && printf 'package main\nimport "fmt"\nfunc main(){fmt.Println("ok")}\n' > h.go
<mock-chroot> sh-5.3# go build -o h h.go && ./h
ok

Introduce ms-golang for Azure Linux 4.0 using a local spec ported from the
3.0-dev golang.spec (the Microsoft build of Go). It Provides golang and
Conflicts with the Fedora upstream golang package so the two cannot be
co-installed.

Spec adjustments for AzL 4.0:
- Reference bootstrap trees via %{_builddir} (RPM >= 4.20 per-package build subdir).
- Build the go1.4 C bootstrap with -std=gnu17 (C23 'bool' keyword breaks -Werror).
- Stage the rolling bootstrap under %{_builddir} (unprivileged mock cannot write /usr/lib64).
- Add BuildRequires: gcc, glibc-devel (minimal buildroot).
- Disable auto find-provides to drop spurious test-data SONAMEs (e.g. libtiffxx.so.6).
Copilot AI review requested due to automatic review settings July 30, 2026 00:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Microsoft’s Go build as an alternative golang provider for Azure Linux 4.0.

Changes:

  • Adds the local ms-golang component and six source archives.
  • Builds a rolling bootstrap toolchain for x86_64 and AArch64.
  • Provides golang while conflicting with Fedora’s package.

Reviewed changes

Copilot reviewed 6 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
base/comps/ms-golang/ms-golang.comp.toml Defines the component and sources.
base/comps/ms-golang/ms-golang.spec Packages and builds Microsoft Go.
base/comps/ms-golang/go14_bootstrap_aarch64.patch Enables AArch64 bootstrap detection.
locks/ms-golang.lock Records the component fingerprint.
specs/m/ms-golang/ms-golang.spec Contains the rendered RPM spec.
specs/m/ms-golang/go14_bootstrap_aarch64.patch Contains the rendered bootstrap patch.
specs/m/ms-golang/sources Records rendered source checksums.

# and a hand-written %changelog, so release.calculation is "manual".
[components.ms-golang]
spec = { type = "local", path = "ms-golang.spec" }
release = { calculation = "manual" }
Comment on lines +177 to +183
%postun
/sbin/ldconfig
if [ $1 -eq 0 ]; then
# This is uninstall
rm -rf /opt/go
exit 0
fi

export GOROOT="`pwd`"
export GOPATH=%{gopath}
export GOROOT_FINAL=%{_bindir}/go
rm -f %{gopath}/src/runtime/*.c
(
cd src
./make.bash --no-clean
Comment on lines +53 to +54
BuildRequires: gcc
BuildRequires: glibc-devel
Name: ms-golang
Version: 1.26.5
Release: 3%{?dist}
License: BSD-3-Clause
# - build as `ms-golang` (instead of `golang`),
# - keep `Provides: golang` so it can satisfy golang dependencies, and
# - `Conflicts: golang` so it cannot be installed alongside the Fedora golang package.
# Maintained as a local spec (not available upstream in Fedora); uses a static Release

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liunan-ms What's the trade-off you see of maintaining it locally vs. trying to adapt the upstream Feodora spec to build the MSFT sources/config? (Are they that different that it necessitates diverging?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants