Bug 46986 - Go is not supported on Darwin
Summary: Go is not supported on Darwin
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: go (show other bugs)
Version: 4.5.4
: P3 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
: 55969 77861 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-12-17 00:59 UTC by Xiyue Deng
Modified: 2023-10-08 05:33 UTC (History)
12 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-01-05 05:36:57


Attachments
hacky patch that should be split up (6.28 KB, patch)
2011-02-26 23:28 UTC, comexk
Details | Diff
updated patch for 4.6.1 (6.48 KB, patch)
2011-09-01 18:09 UTC, Anders F Björklund
Details | Diff
import-export.diff (683 bytes, patch)
2011-09-02 11:10 UTC, Anders F Björklund
Details | Diff
import-export.diff (1.39 KB, patch)
2011-09-05 14:01 UTC, Anders F Björklund
Details | Diff
updated patch for trunk (706 bytes, patch)
2012-02-15 22:10 UTC, Anders F Björklund
Details | Diff
gcc-go_export.diff (640 bytes, patch)
2012-02-15 22:12 UTC, Anders F Björklund
Details | Diff
gcc-ucontext.diff (662 bytes, patch)
2012-02-15 22:16 UTC, Anders F Björklund
Details | Diff
gcc-gox_import.diff (351 bytes, patch)
2012-02-16 19:22 UTC, Anders F Björklund
Details | Diff
gcc-darwin_goc2c.patch (387 bytes, patch)
2012-02-16 19:22 UTC, Anders F Björklund
Details | Diff
gcc-darwin_libgo.patch (1.36 KB, patch)
2012-02-18 14:07 UTC, Anders F Björklund
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xiyue Deng 2010-12-17 00:59:09 UTC
Building latest trunk with go enabled fails with -Werror, even with --disable-werror specified. Relevant build log:


libtool: compile:  /tmp/gcc-build/./gcc/xgcc -B/tmp/gcc-build/./gcc/ -B/usr/local/x86_64-apple-darwin10.5.0/bin/ -B/usr/local/x86_64-apple-darwin10.5.0/lib/ -isystem /usr/local/x86_64-apple-darwin10.5.0/include -isystem /usr/local/x86_64-apple-darwin10.5.0/sys-include -DHAVE_CONFIG_H -I. -I/Users/dxy/VCS/GIT/gcc/libgo -I /Users/dxy/VCS/GIT/gcc/libgo/runtime -I/Users/dxy/VCS/GIT/gcc/libgo/../libffi/include -I../libffi/include -pthread -fexceptions -fplan9-extensions -Wall -Wextra -Wwrite-strings -Wcast-qual -Werror -minline-all-stringops -I /Users/dxy/VCS/GIT/gcc/libgo/../gcc -I ../../gcc/include -g -O2 -MT go-go.lo -MD -MP -MF .deps/go-go.Tpo -c /Users/dxy/VCS/GIT/gcc/libgo/runtime/go-go.c  -fno-common -DPIC -o .libs/go-go.o
/Users/dxy/VCS/GIT/gcc/libgo/runtime/go-go.c: In function 'runtime_stoptheworld':
/Users/dxy/VCS/GIT/gcc/libgo/runtime/go-go.c:378:29: error: 'SIGRTMIN' undeclared (first use in this function)
/Users/dxy/VCS/GIT/gcc/libgo/runtime/go-go.c:378:29: note: each undeclared identifier is reported only once for each function it appears in
/Users/dxy/VCS/GIT/gcc/libgo/runtime/go-go.c: In function 'runtime_starttheworld':
/Users/dxy/VCS/GIT/gcc/libgo/runtime/go-go.c:559:29: error: 'SIGRTMIN' undeclared (first use in this function)
/Users/dxy/VCS/GIT/gcc/libgo/runtime/go-go.c: In function '__go_gc_goroutine_init':
/Users/dxy/VCS/GIT/gcc/libgo/runtime/go-go.c:611:7: error: 'SIGRTMIN' undeclared (first use in this function)
/Users/dxy/VCS/GIT/gcc/libgo/runtime/go-go.c:611:7: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
/Users/dxy/VCS/GIT/gcc/libgo/runtime/go-go.c:613:7: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
/Users/dxy/VCS/GIT/gcc/libgo/runtime/go-go.c:620:7: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
/Users/dxy/VCS/GIT/gcc/libgo/runtime/go-go.c:622:7: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
cc1: all warnings being treated as errors

make[4]: *** [go-go.lo] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-target-libgo] Error 2
make: *** [all] Error 2


Informations:
GCC version: trunk r167954
System: Mac OS X 10.6.5
Configure options: $PATH/configure \
    --prefix=${PREFIX} \
    --with-gmp=${PREFIX} \
    --with-mpfr=${PREFIX} \
    --with-mpc=${PREFIX} \
    --with-ppl=${PREFIX} \
    --with-cloog=${PREFIX} \
    --program-suffix=-4.6 \
    --enable-languages=c,c++,fortran,go \
    --disable-nls \
    --disable-werror \
    --disable-bootstrap \
    --enable-shared \
    --enable-threads \
    --enable-__cxa_init \
    --enable-version-specific-runtime-libs \
    --enable-decimal-float \
    --enable-plugin \
    --enable-lto \
    --enable-full-dynamic-string \
    --enable-concept-checks \
    --enable-libstdcxx-debug \
    --enable-libstdcxx-time


HTH.

Also, it seems bug#46958 and #46965 is related: both failed with -Werror
Comment 2 Ian Lance Taylor 2011-01-05 05:36:57 UTC
This is going to require some work from somebody familiar with Darwin.
Comment 3 comexk 2011-02-26 23:25:36 UTC
I was able to get gcc to compile, and compile and run a trivial Go program on OS X with the attached patch.  Since I know little about gcc, the patch is just a hack, but maybe it can help.

The issues it addresses are:

- some of the stuff that mksysinfo.sh generates doesn't compile.

- The frontend hardcodes ".go_export" both in the C++ code and in the argument to objcopy, but Darwin wants both a segment and section name.

- A lot of code relies on asm() for symbol names, but Darwin wants an underscore at the beginning (hardcode the underscore; obviously not a good plan).

- SIGRTMIN is not defined (use SIGUSR1/2).

- xnu doesn't support sem_init() (use pthreads).

- the compiler seems to want an explicit -o with -c, but compiler_c_o in libtool somehow gets defined as no.

- syscall.Sysctl isn't defined (I didn't bother to fix this but just commented out the only use).

- a typo in libgo/runtime/go-new-map.c which is probably unrelated and belongs in another bug.

GCC version: gcc-4.6-20110219 
System: Mac OS X 10.6.6 (with MacPorts installed)
Configuration: ./configure --prefix=/opt/gccgo --with-boot-ldflags="/opt/local/lib/libiconv.dylib /usr/lib/libiconv.dylib" --disable-bootstrap --with-ppl=/opt/local --with-cloog=/opt/local --with-mpfr=/opt/local --enable-gold=no --enable-ld=no --enable-languages=c,c++,go LDFLAGS="/opt/local/lib/libiconv.dylib /usr/lib/libiconv.dylib"
Comment 4 comexk 2011-02-26 23:28:09 UTC
Created attachment 23482 [details]
hacky patch that should be split up
Comment 5 Ian Lance Taylor 2011-04-21 00:19:10 UTC
See also http://code.google.com/p/go/issues/detail?id=463 .
Comment 6 Anders F Björklund 2011-09-01 18:09:02 UTC
Created attachment 25168 [details]
updated patch for 4.6.1

hello world tests OK on Snow Leopard, with patch
Comment 7 Anders F Björklund 2011-09-01 18:11:32 UTC
Another problem is that the -static-libgo flag doesn't work, because the static library has the same name and location as the dynamic lib and therefore darwin will always prefer the dynamic library. It probably needs to be renamed (to something like libgo_static.a), since otherwise the -Wl,-search_paths_first flag is needed to avoid picking up libgo.dylib even if it comes later in the paths...
Comment 8 Jack Howarth 2011-09-01 22:48:23 UTC
(In reply to comment #6)
> Created attachment 25168 [details]
> updated patch for 4.6.1
> 
> hello world tests OK on Snow Leopard, with patch

This patch fails on darwin11 when applied to gcc-4_6-branch...


f=`echo sort/sort.lo | sed -e 's/.lo$/.o/'`; missing-objcopy -j __GNU_GO.__go_export $f sort.gox.tmp && mv -f sort.gox.tmp sort.gox
/bin/sh: missing-objcopy: command not found
make[4]: *** [sort.gox] Error 127
make[4]: *** Waiting for unfinished jobs....

It seems to required binutils to be installed (which we really want to avoid).
Comment 9 Anders F Björklund 2011-09-02 06:40:28 UTC
(In reply to comment #8)
> > hello world tests OK on Snow Leopard, with patch
> 
> This patch fails on darwin11 when applied to gcc-4_6-branch...

Seems like the patch worked (= didn't fail to apply),
but that the build failed due to missing dependencies ?
 
> f=`echo sort/sort.lo | sed -e 's/.lo$/.o/'`; missing-objcopy -j
> __GNU_GO.__go_export $f sort.gox.tmp && mv -f sort.gox.tmp sort.gox
> /bin/sh: missing-objcopy: command not found
> make[4]: *** [sort.gox] Error 127
> make[4]: *** Waiting for unfinished jobs....
> 
> It seems to required binutils to be installed (which we really want to avoid).

Yes, it requires OBJCOPY=gobjcopy. Maybe this requirement
should be replaced with some custom "gox-extract" tool ?

Since the .go_export section name had to be changed, anyway:
http://golang.org/doc/gccgo_install.html#Imports
Comment 10 Anders F Björklund 2011-09-02 08:45:22 UTC
Here's my attempt at a native version.
(of that "gox-extract" shell script)

Instead of the default variant:
OBJCOPY=${OBJCOPY:-objcopy}
$OBJCOPY -j .go_export $1 $2

The Darwin version could be this:
OTOOL=${OTOOL:-otool}
$OTOOL -s __GNU_GO __go_export $1 |
grep -v "^$1:" | grep -v "Contents of (__GNU_GO,__go_export) section" |
cut -f 2- | tr -d ' ' | xxd -r -p - $2

It doesn't include the objcopy header,
but I believe that is skipped anyway ?
Comment 11 Anders F Björklund 2011-09-02 09:06:25 UTC
> OTOOL=${OTOOL:-otool}
> $OTOOL -s __GNU_GO __go_export $1 |
> grep -v "^$1:" | grep -v "Contents of (__GNU_GO,__go_export) section" |
> cut -f 2- | tr -d ' ' | xxd -r -p - $2

Apparently -X avoids that header text:
$OTOOL -s __GNU_GO __go_export -X $1 | cut -f 2- | tr -d ' ' | xxd -r -p - $2
Comment 12 Anders F Björklund 2011-09-02 11:07:33 UTC
> It doesn't include the objcopy header,
> but I believe that is skipped anyway ?

Or at least it was *supposed* to ignore it,
but the Stream_from_file was horribly buggy.
(apparently has a dyslectic problem with
comparisons, aggrevated by copy/paste ?)

It always returned "" instead of any data,
so failed to provide the required magic...
(or any other data beyond that, if asked)
Fixing that class, and it works just fine:

Index: gcc/go/gofrontend/import.cc
===================================================================
--- gcc/go/gofrontend/import.cc	(revision 178444)
+++ gcc/go/gofrontend/import.cc	(working copy)
@@ -836,7 +836,7 @@
 bool
 Stream_from_file::do_peek(size_t length, const char** bytes)
 {
-  if (this->data_.length() <= length)
+  if (this->data_.length() >= length)
     {
       *bytes = this->data_.data();
       return true;
@@ -854,7 +854,7 @@
       return false;
     }
 
-  if (lseek(this->fd_, - got, SEEK_CUR) != 0)
+  if (lseek(this->fd_, - got, SEEK_CUR) < 0)
     {
       if (!this->saw_error())
 	error("lseek failed: %m");
@@ -876,7 +876,7 @@
 void
 Stream_from_file::do_advance(size_t skip)
 {
-  if (lseek(this->fd_, skip, SEEK_CUR) != 0)
+  if (lseek(this->fd_, skip, SEEK_CUR) < 0)
     {
       if (!this->saw_error())
 	error("lseek failed: %m");

That bug should affect any other platform too,
if trying to use "naked" .gox (without object) ?
Comment 13 Anders F Björklund 2011-09-02 11:10:51 UTC
Created attachment 25177 [details]
import-export.diff

Just the import/export changes, i.e. outside "libgo" directory.
Comment 14 Jack Howarth 2011-09-04 17:29:37 UTC
(In reply to comment #13)
> Created attachment 25177 [details]
> import-export.diff
> 
> Just the import/export changes, i.e. outside "libgo" directory.

This change is darwin-centric. Peter O'Gorman suggests something along the lines of...

>> just use a gnu make conditional, since gcc requires gnu make to build anyway, check if $OTOOL is != "" e.g. ifeq($(OTOOL),) ... use objcopy else .. use otool ..endif
Comment 15 Anders F Björklund 2011-09-04 18:14:48 UTC
The whole patch is Darwin-centric, in that it's only applied on Darwin.
You are right that it first needs to be conditionalized to go upstream.

afaik, $(OTOOL) would be something like "missing-otool" on e.g. Linux ?
(just as we now get $(OBJCOPY) set to "missing-objcopy" on Mac OS X...)
Comment 16 Anders F Björklund 2011-09-05 14:01:36 UTC
Created attachment 25196 [details]
import-export.diff

Here's an updated portable version. Using otool "if LIBGO_IS_DARWIN".

Used a shell function instead of a shell script, for "gengox" tool...
Comment 17 Ian Lance Taylor 2011-12-14 01:43:11 UTC
The most recent patch is against gcc 4.6, and mainline is different.

I have just moved the support for reading export data out of the Go frontend proper.  The purpose of this move is to permit the control for where the data lives to be entirely in gcc, including gcc/config/darwin.h.

I think that now the only thing which will need to change in the Go frontend proper is using otool instead of objcopy in libgo/Makefile.am.

Can you set up a new patch against mainline?

Thanks.
Comment 18 Ian Lance Taylor 2012-02-14 19:59:03 UTC
Somebody will have to work on this but I don't have the time.
Comment 19 Anders F Björklund 2012-02-15 22:08:59 UTC
(In reply to comment #17)
> I think that now the only thing which will need to change in the Go frontend
> proper is using otool instead of objcopy in libgo/Makefile.am.

The otool was simple enough, but the other go_export issues still remain.
And there are some new issues with ucontext being deprecated on Mac OS X.
Comment 20 Anders F Björklund 2012-02-15 22:10:09 UTC
Created attachment 26668 [details]
updated patch for trunk
Comment 21 Anders F Björklund 2012-02-15 22:12:24 UTC
Created attachment 26669 [details]
gcc-go_export.diff

Need to give both segment and section for export on Darwin:

/var/folders/SU/SU8yve9tFP4OXneVoY+KsU+++TI/-Tmp-//ccWicBIX.s:3:Expected comma after segment-name
/var/folders/SU/SU8yve9tFP4OXneVoY+KsU+++TI/-Tmp-//ccWicBIX.s:3:Rest of line ignored. 1st junk character valued 32 ( ).
/var/folders/SU/SU8yve9tFP4OXneVoY+KsU+++TI/-Tmp-//ccWicBIX.s:3:Junk character 92 (\).
/var/folders/SU/SU8yve9tFP4OXneVoY+KsU+++TI/-Tmp-//ccWicBIX.s:3:Rest of line ignored. 1st junk character valued 49 (1).
Comment 22 Anders F Björklund 2012-02-15 22:16:41 UTC
Created attachment 26670 [details]
gcc-ucontext.diff

ucontext is deprecated on Mac OS X 10.5-10.6, including ucontext.h gives error:

In file included from ../../../gcc/libgo/runtime/runtime.h:20:0,
                 from ../../../gcc/libgo/runtime/go-main.c:21:
/usr/include/ucontext.h:42:2: error: #error ucontext routines are deprecated, and require _XOPEN_SOURCE to be defined

ucontext is missing altogether from Mac OS X 10.7, but there is no TLS either:

error: thread-local storage not supported for this target
Comment 23 mrs@gcc.gnu.org 2012-02-15 22:41:37 UTC
I'm fine with the last patch, though, I think it needs Ian to approve.
Comment 24 Jack Howarth 2012-02-16 03:47:05 UTC
(In reply to comment #22)
> 
> ucontext is missing altogether from Mac OS X 10.7, but there is no TLS either:
> 
> error: thread-local storage not supported for this target

There is tis support within clang in Xcode 4.2 (see radar:10291355, "Xcode 4.2 miscompiles tls support in
MPFR 3.1.0" which was fixed in Xcode 4.2.1), however FSF gcc currently doesn't generate the required assembly for tis support.
Comment 25 Jack Howarth 2012-02-16 14:22:33 UTC
(In reply to comment #23)
> I'm fine with the last patch, though, I think it needs Ian to approve.

Wouldn't it make more sense to file a joint PR with the OpenBSD folks in order to have the use of ucontext purged from libgo (considering that neither BSD should have it now and that feature has been deprecated from POSIX)?
Comment 26 Ian Lance Taylor 2012-02-16 15:48:18 UTC
I think it would be great if somebody would tell me something I can used instead of makecontext/getcontext/setcontext.  Unless somebody can come up with one, then I think the only alternative is to write our own processor-specific versions and distribute them with libgo.

The functions were removed from POSIX not because there was any adequate replacement, but because they suffer from some design deficiencies.
Comment 27 Jack Howarth 2012-02-16 16:22:02 UTC
(In reply to comment #26)
> I think it would be great if somebody would tell me something I can used
> instead of makecontext/getcontext/setcontext.  Unless somebody can come up with
> one, then I think the only alternative is to write our own processor-specific
> versions and distribute them with libgo.
> 
> The functions were removed from POSIX not because there was any adequate
> replacement, but because they suffer from some design deficiencies.

Would implementing "cooperative threading" with pthreads, perhaps with conditional variables, as described in...

http://stackoverflow.com/questions/4298986/is-there-something-to-replace-the-ucontext-h-functions

be appropriate?
Comment 28 Ian Lance Taylor 2012-02-16 16:50:13 UTC
Using pthreads will be much less efficient than the current code using getcontext/setcontext.  Writing machine-specific replacement code would be a much better idea than that.
Comment 29 Anders F Björklund 2012-02-16 19:21:45 UTC
It still needs to generate the extra underscore for Darwin,
and it still needs to fix the bug mentioned in Comment #12.
Comment 30 Anders F Björklund 2012-02-16 19:22:25 UTC
Created attachment 26682 [details]
gcc-gox_import.diff
Comment 31 Anders F Björklund 2012-02-16 19:22:52 UTC
Created attachment 26683 [details]
gcc-darwin_goc2c.patch
Comment 32 Anders F Björklund 2012-02-16 19:28:22 UTC
Then it's more about fixing library issues, like the macros used
for TIOCNOTTY/TIOCSCTTY or st_atime/st_mtime/st_ctime and sysctl.
Comment 33 Anders F Björklund 2012-02-18 14:07:03 UTC
Created attachment 26699 [details]
gcc-darwin_libgo.patch
Comment 34 Anders F Björklund 2012-02-18 14:08:26 UTC
There is the other big change needed, which is to prefix all the asm names
with USER_LABEL_PREFIX (_) so that they will actually link properly later.
Comment 35 Anders F Björklund 2012-02-18 14:15:28 UTC
At least it compiles again, after adding asm prefix and ptrace/sysctl...
Hacked it in for now, but needs a better patch for runtime and syscall.

Still fails to actually run, but I guess that is due to something else:
"panic: runtime error: invalid memory address or nil pointer dereference"
Comment 36 ian@gcc.gnu.org 2013-01-24 18:12:41 UTC
Author: ian
Date: Thu Jan 24 18:12:23 2013
New Revision: 195436

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195436
Log:
	PR go/46986
libgo/Makefile, libgo/go/os/stat_atimespec.go: fix typos

Modified:
    trunk/libgo/Makefile.am
    trunk/libgo/Makefile.in
    trunk/libgo/go/os/stat_atimespec.go
Comment 37 ian@gcc.gnu.org 2013-01-24 19:44:31 UTC
Author: ian
Date: Thu Jan 24 19:44:23 2013
New Revision: 195438

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195438
Log:
	PR go/46986
all: prepend #__USER_LABEL_PREFIX__ to mangled Go symbols
For old-fashioned Darwin.

Modified:
    trunk/libgo/go/bytes/indexbyte.c
    trunk/libgo/go/log/syslog/syslog_c.c
    trunk/libgo/go/sync/atomic/atomic.c
    trunk/libgo/go/sync/cas.c
    trunk/libgo/go/syscall/errno.c
    trunk/libgo/go/syscall/signame.c
    trunk/libgo/go/syscall/wait.c
    trunk/libgo/runtime/chan.c
    trunk/libgo/runtime/cpuprof.c
    trunk/libgo/runtime/env_posix.c
    trunk/libgo/runtime/go-breakpoint.c
    trunk/libgo/runtime/go-caller.c
    trunk/libgo/runtime/go-callers.c
    trunk/libgo/runtime/go-cgo.c
    trunk/libgo/runtime/go-fieldtrack.c
    trunk/libgo/runtime/go-getgoroot.c
    trunk/libgo/runtime/go-now.c
    trunk/libgo/runtime/go-reflect-map.c
    trunk/libgo/runtime/go-setenv.c
    trunk/libgo/runtime/go-signal.c
    trunk/libgo/runtime/go-typestring.c
    trunk/libgo/runtime/go-unsafe-new.c
    trunk/libgo/runtime/go-unsafe-newarray.c
    trunk/libgo/runtime/go-unsafe-pointer.c
    trunk/libgo/runtime/goc2c.c
    trunk/libgo/runtime/lfstack.c
    trunk/libgo/runtime/malloc.goc
    trunk/libgo/runtime/malloc.h
    trunk/libgo/runtime/mgc0.c
    trunk/libgo/runtime/mprof.goc
    trunk/libgo/runtime/panic.c
    trunk/libgo/runtime/parfor.c
    trunk/libgo/runtime/proc.c
    trunk/libgo/runtime/runtime.c
    trunk/libgo/runtime/runtime.h
Comment 38 Ian Lance Taylor 2013-02-05 22:37:42 UTC
*** Bug 55969 has been marked as a duplicate of this bug. ***
Comment 39 Ian Lance Taylor 2016-10-05 12:39:10 UTC
*** Bug 77861 has been marked as a duplicate of this bug. ***
Comment 40 Eric Gallager 2018-07-01 04:44:43 UTC
(In reply to Jack Howarth from comment #24)
> (In reply to comment #22)
> > 
> > ucontext is missing altogether from Mac OS X 10.7, but there is no TLS either:
> > 
> > error: thread-local storage not supported for this target
> 
> There is tis support within clang in Xcode 4.2 (see radar:10291355, "Xcode
> 4.2 miscompiles tls support in
> MPFR 3.1.0" which was fixed in Xcode 4.2.1), however FSF gcc currently
> doesn't generate the required assembly for tis support.

This is bug 52268, for reference
Comment 41 Eric Gallager 2021-07-24 05:09:06 UTC
Would this package help at all? https://github.com/blacktop/go-macho
Comment 42 Ian Lance Taylor 2021-07-24 23:40:17 UTC
No, the go-macho package is irrelevant here.
Comment 43 Sergey Fedorov 2022-10-30 07:14:16 UTC
What is the current status of gccgo on Darwin?
Comment 44 Ian Lance Taylor 2022-10-30 17:15:51 UTC
gccgo still does not work on Darwin.
Comment 45 Iain Sandoe 2022-10-30 17:19:13 UTC
(In reply to Ian Lance Taylor from comment #44)
> gccgo still does not work on Darwin.

is work needed on the runtime, or on code-gen (or both)?
If there was someone who had some spare time to work on it...
Comment 46 Ian Lance Taylor 2022-10-30 17:25:42 UTC
A small bit of work is needed on the codegen, to read and write the export data.  And some work is required on the runtime, to clean it up to support Darwin.  It has to be done by someone with access to a modern Darwin system.
Comment 47 Sergey Fedorov 2022-10-30 17:41:57 UTC
(In reply to Ian Lance Taylor from comment #46)
> A small bit of work is needed on the codegen, to read and write the export
> data.  And some work is required on the runtime, to clean it up to support
> Darwin.  It has to be done by someone with access to a modern Darwin system.

I could do something on this, perhaps, provided it is not overly demanding in terms of expertise. Or do those parts which are such :)

While I have more interest in Darwin PPC, since Go is broken there (ppc32 support exists in out-of-tree branch of Go 1.9, though not for Darwin, however the only Go bootstrappable from C, 1.4, is x86-only), access to modern x86_64 Darwin is there.
Comment 48 Iain Sandoe 2022-10-30 18:14:11 UTC
(In reply to Sergey Fedorov from comment #47)
> (In reply to Ian Lance Taylor from comment #46)
> > A small bit of work is needed on the codegen, to read and write the export
> > data.  And some work is required on the runtime, to clean it up to support
> > Darwin.  It has to be done by someone with access to a modern Darwin system.
> 
> I could do something on this, perhaps, provided it is not overly demanding
> in terms of expertise. Or do those parts which are such :)
> 
> While I have more interest in Darwin PPC, since Go is broken there (ppc32
> support exists in out-of-tree branch of Go 1.9, though not for Darwin,
> however the only Go bootstrappable from C, 1.4, is x86-only), access to
> modern x86_64 Darwin is there.

with care, most of the time, FE stuff tends to be quite neutral about the eventual Darwin target (generic Mach-O constraints are similar between the sub-targets***).  The runtime, of course, is likely to be more specific.   I'd recommend starting on x86_64 since that's pretty stable, and then we can look at i686 ... and when that works, ppc is likely to be quite easy.

Arm64 is still pretty experimental, and there are known TODOs for ABI compliance, so I'd avoid that sub-platform initially (despite that it's the most modern).

*** aarch64/arm64 Darwin has some much tighter constraints security-wise - in particular stack-based trampolines are not allowed - but we have a draft of a heap-based scheme in the devt. branch .. you'd just need to look at what has been done for C, Fortran and Ada.
Comment 49 Sergey Fedorov 2023-10-08 05:33:06 UTC
If someone happens to have some WIP on this, more recent than 2012, please share, if possible.