https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86535

--- Comment #45 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot 
Uni-Bielefeld.DE> ---
> --- Comment #44 from Rainer Orth <ro at gcc dot gnu.org> ---
> Created attachment 64977
>   --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64977&action=edit
> Initial patch

The attached patch is a first cut at fixing the libgo build on
FreeBSD/amd64.  It's still rough and unfinished, but it allows the build
to complete and a considerable part of the libgo tests to PASS:

               === libgo Summary for unix ===

# of expected passes            129
# of unexpected failures        67

It is built on top of the NetBSD patch in PR go/126144 and addresses
several issues:

* It removes a couple of constants the are now in the generated
  sysinfo.go and runtime_sysinfo.go.

* It fixes a couple of typos in the FreeBSD code.

* It provides several missing functions from upstream go1.18.

* It provides missing function, type, and constant declarations:

** The umtx_op related ones need to include <sys/umtx.h> in sysinfo.c.
   configure.ac is adjusted to test for that.

** Some of the existing configure tests need additional headers to
   actually compile on FreeBSD.

** Some constants were still missing and not used anywere else, like
   syscall.AI_MASK.

* I'm currently cheating on wait6 by falling back to os/wait_unimp.go.
  To fix this, there should be a libcall version of wait6 instead of the
  current syscall one.  The patch includes a first cut that needs
  further fixes to actually compile.

* Like the rest of libgo, VDSO isn't used on FreeBSD, so the support is
  commented out.

* There's an ugly issue about _NSIG and sigtab.go: the generated sigTabT
  includes an entry for

        _SIGTHR: {_SigNotify, "SIGTHR: reserved"},

  where <sys/signal.h> has

#define SIGTHR          32      /* reserved by thread library. */

  However, _NSIG is 32, not counting this, so tests fail with

  runtime: len(sigtable)=33 _NSIG=32
  fatal error: bad sigtable len

  at runtime.

  To avoid this and to match upstream runtime/signal_freebsd.go, this
  patch overrides _NSIG in mkrsysinfo.sh, mksysinfo.sh, and mksigtab.sh.

  Simultaneously, sigaction fails with

  fatal error: sigaction read failure

  in runtime/signal_gccgo.go, so the signal is skipped like several
  others on Linux.

* The resulting libgo.so failed to load:

  libgo.so: undefined reference to `paccept'

  This differs from NetBSD where accept(2) documents

  The accept4() function is equivalent to paccept() with NULL as the
  argument for sigmask.

  However, the sigmask arg syscall/libcall_bsd.go already *is* nil, so
  there seems to be no reason to user paccept rather than the
  POSIX.1-2024 accept4.

With this patch, I get the test results mentioned above which seem not
too best for a first cut.

All but one of the remaining 67 failures are like

umtx_wait addr=0x823c095b0 val=0 ret=-1
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x1005 pc=0x823138a7a]

I've not yet started to investigate more closely, but wanted to get this
out for now to get comments and suggestions.

Reply via email to