Bug 278953 - lang/go122: build fails on armv7 FreeBSD 13.3
Summary: lang/go122: build fails on armv7 FreeBSD 13.3
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm Any
: --- Affects Only Me
Assignee: Golang Team (Nobody)
URL: https://github.com/golang/go/issues/6...
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-13 14:47 UTC by Robert Clausecker
Modified: 2024-05-23 15:02 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (go)
fuz: merge-quarterly+


Attachments
lang/go122 armv7 FreeBSD 13.3 build log (84.16 KB, text/plain)
2024-05-13 14:47 UTC, Robert Clausecker
no flags Details
lang/go122: fix build on armv7 (2.33 KB, patch)
2024-05-13 19:01 UTC, Robert Clausecker
fuz: maintainer-approval? (go)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Clausecker freebsd_committer freebsd_triage 2024-05-13 14:47:40 UTC
Created attachment 250617 [details]
lang/go122 armv7 FreeBSD 13.3 build log

I'm trying to build lang/go 1.22.2 on armv7 FreeBSD 13.3 (specifically, in an armv7 jail on an arm64 host).  The build fails reproducably when building toolchain3:

Building Go toolchain3 using go_bootstrap and Go toolchain2.
fatal error: workbuf is not empty

runtime stack:
runtime.throw({0x4c643d, 0x14})
        /usr/local/go122/src/runtime/panic.go:1023 +0x4c fp=0x2905fefc sp=0x2905fee8 pc=0x52544
runtime.(*workbuf).checkempty(0x294d4800)
        /usr/local/go122/src/runtime/mgcwork.go:344 +0x38 fp=0x2905ff08 sp=0x2905fefc pc=0x41944
runtime.getempty()
        /usr/local/go122/src/runtime/mgcwork.go:357 +0x70 fp=0x2905ff34 sp=0x2905ff08 pc=0x419cc
runtime.handoff(0x29318000)
        /usr/local/go122/src/runtime/mgcwork.go:439 +0x14 fp=0x2905ff48 sp=0x2905ff34 pc=0x41cfc
runtime.(*gcWork).balance(0x2903bc5c)
        /usr/local/go122/src/runtime/mgcwork.go:297 +0x44 fp=0x2905ff54 sp=0x2905ff48 pc=0x41840
runtime.gcDrainN(0x2903bc5c, 0xa3c0)
        /usr/local/go122/src/runtime/mgcmark.go:1304 +0x148 fp=0x2905ff7c sp=0x2905ff54 pc=0x37fe8
runtime.gcAssistAlloc1(0x29276200, 0xa3c0)
        /usr/local/go122/src/runtime/mgcmark.go:665 +0x15c fp=0x2905ffd4 sp=0x2905ff7c pc=0x363e8
runtime.gcAssistAlloc.func1()
        /usr/local/go122/src/runtime/mgcmark.go:556 +0x2c fp=0x2905ffe4 sp=0x2905ffd4 pc=0x3627c
runtime.systemstack(0x0)
        /usr/local/go122/src/runtime/asm_arm.s:317 +0x60 fp=0x2905ffe8 sp=0x2905ffe4 pc=0x8c3bc

See attached build log for details.

The build fails on FreeBSD 14.0 in much the same way.  I'll try to bisect the change from go 1.21 to 1.22 to find where the error is.
Comment 1 Robert Clausecker freebsd_committer freebsd_triage 2024-05-13 17:08:23 UTC
Good news: this seems to be fixed in current master, I'll try to find the patch set that fixed it in my next step.

The offending commit seems to be:

commit 6ecadb4d87dafebd42fa7e810faa1bf1a0e6f35d (HEAD)
Author: Joel Sing <joel@sing.id.au>
Date:   Tue Oct 31 00:51:25 2023 +1100

    syscall: regenerate zsyscall for dragonfly/freebsd/netbsd
    
    The sysctl declaration was moved in CL 141639, however the files were
    presumably not regenerated. There is no functional change, however
    regenerating avoids unrelated noise in future diffs.
    
    Change-Id: Ifb840b5853f3f1c3c88a3f94df21b6f6d3c635d4
    Reviewed-on: https://go-review.googlesource.com/c/go/+/538118
    TryBot-Result: Gopher Robot <gobot@golang.org>
    Reviewed-by: Bryan Mills <bcmills@google.com>
    Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
    Run-TryBot: Joel Sing <joel@sing.id.au>
    Reviewed-by: Cherry Mui <cherryyz@google.com>
Comment 2 Robert Clausecker freebsd_committer freebsd_triage 2024-05-13 18:36:35 UTC
Possibly related upstream issue: https://github.com/golang/go/issues/65601

However, this fix was backported to 1.22.1 and should therefore not be the cause of our trouble.

I now realise that my previous bisection might have been bogus; it's a race condition, so it might just have not triggered.

The bisection for when the race condition was fixed yields:

commit e4ebd13f7a6f216f7ddbaa1f2a3c97fd10bc3d23 (HEAD)
Author: Cherry Mui <cherryyz@google.com>
Date:   Fri Feb 9 14:17:18 2024 -0500

    cmd/dist,cmd/go: define assembly macros, handle GOARM value with soft/hardfloat
    
    CL 525637 added GOARM_x assembly macros based on GOARM value. But
    it did not define the macro in cmd/dist, so the macro is not set
    during bootstrapping. This CL defines them.
    
    With CL 514907, cfg.GOARM can also take a soft/hardfloat suffix,
    like "7,hardfloat". Handle that case.
    
    For #65601.
    
    Change-Id: I60ffe7e8b623ae693d91d6e8595067a6f76565b3
    Reviewed-on: https://go-review.googlesource.com/c/go/+/562995
    Run-TryBot: Cherry Mui <cherryyz@google.com>
    Reviewed-by: Keith Randall <khr@golang.org>
    Reviewed-by: Keith Randall <khr@google.com>
    TryBot-Result: Gopher Robot <gobot@golang.org>

This commit was not backported, but is mentioned in the same issue as the actual fix for the issue.  Perhaps we could apply it as a site patch?
Comment 3 Robert Clausecker freebsd_committer freebsd_triage 2024-05-13 19:01:36 UTC
Created attachment 250625 [details]
lang/go122: fix build on armv7

Attached patch backports the missing patch and fixes the build on armv7 for me.
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-05-23 14:57:52 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=1ec501743bd9a626af211b4cab06751227a4d703

commit 1ec501743bd9a626af211b4cab06751227a4d703
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2024-05-13 18:45:02 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2024-05-23 14:55:55 +0000

    lang/go122: fix build on armv7

    This backports a commit needed to get proper barriers during bootstrap
    when building Go with more than one job on armv7.

    Note that this only changes the behaviour when building the bootstrap
    toolchain.  Binaries generated using the toolchain are not affected
    and hence Go ports need not be bumped.

    PR:             278953
    Approved by:    portmgr (build fix blanket)
    Obtained from:  https://go-review.googlesource.com/c/go/+/562995
    See also:       https://github.com/golang/go/issues/65601
    MFH:            2024Q2

 lang/go122/Makefile                                |  3 ++-
 lang/go122/files/patch-src_cmd_dist_build.go (new) | 23 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2024-05-23 15:01:55 UTC
A commit in branch 2024Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5888c8d3e3cd2885b50ad9b230669f446c3c78e4

commit 5888c8d3e3cd2885b50ad9b230669f446c3c78e4
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2024-05-13 18:45:02 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2024-05-23 15:01:42 +0000

    lang/go122: fix build on armv7

    This backports a commit needed to get proper barriers during bootstrap
    when building Go with more than one job on armv7.

    Note that this only changes the behaviour when building the bootstrap
    toolchain.  Binaries generated using the toolchain are not affected
    and hence Go ports need not be bumped.

    PR:             278953
    Approved by:    portmgr (build fix blanket)
    Obtained from:  https://go-review.googlesource.com/c/go/+/562995
    See also:       https://github.com/golang/go/issues/65601
    MFH:            2024Q2

    (cherry picked from commit 1ec501743bd9a626af211b4cab06751227a4d703)

 lang/go122/Makefile                                |  3 ++-
 lang/go122/files/patch-src_cmd_dist_build.go (new) | 23 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
Comment 6 Robert Clausecker freebsd_committer freebsd_triage 2024-05-23 15:02:25 UTC
Fixed under build fix blanket approval.