I've convinced go to build on DragonFly BSD - the toolchain runs and
produces executables, but the executables run on Linux, not DragonFly
(there's no runtime yet). I built with GOOS=linux, GOARCH=386. This
process (and this email) is a bit messy at the minute, but I hope its
of some use.
Changes required:
- Modified src/all.bash, {src,src/cmd}/make.bash, and
{src,src/cmd}/clean.bash to not require bash.
- Switch from using 'make' to 'gmake' in a number of places (primarily
{src,src/cmd}/make.bash
- Stubbed out a src/libmach/dragonfly.c
- Remove cov and prof from make.bash, as they depend on a real libmach.
- Switch from 'bison' to 'yacc' in src/cmd/cc/Makefile and
src/cmd/gc/Makefile. I was unable to get src/cmd/8a to build when I
used the system yacc instead of bison. I punted on making it work and
used Inferno's iyacc (iyacc -D1 -d a.y) instead to build a.y; using
Inferno's yacc meant I needed to remove the header comment in a.y, as
// is not a valid comment character.
- In src/pkg/runtime/linux/signals.h, there is "#define C SigCatch".
8c wasn't buying this, so I replaced C with SigCatch in the table.
What's left before running go apps natively: (possibly of interest for
anyone doing any other ports as well)
- src/libmach/dragonfly.c is currently a stub. It needs to implement
these functions: attachproc()/detachproc(), procthreadpids(),
procnotes(), ctlproc(), proctextfile(), and procstatus().
A good starting point would be
http://swtch.com/usr/local/plan9/src/libmach/FreeBSD.c. I don't know
if this is required to run programs; I doubt it. It is required for
cov and prof, however. Here is a start of one:
http://grex.org/~vsrinivas/src/libmach-dragonfly.c
- arch-neutral runtime (pkg/runtime/dragonfly/*).
thread.c will need to provide lock() / unlock(), noteclear() /
notewakeup() / notesleep(), newosproc(), and minit().
newosproc() could just wrap rfork(), though the system libthread
doesn't (it uses lwp_create() instead). minit() just needs to set up a
signal stack. signals.h and os.h look fairly ordinary; sigtab[] is
just
Maybe thread.c ought use pthreads instead of the OS-specific
threading? We can use pthread_mutex for lock/unlock, pthread_create
for newosproc...
- arch-specific runtime (pkg/runtime/dragonfly/386/*)
defs.h is autogenerated. signal.c provides the C-half of the signal
handlers, which mostly print registers & stacks in bad cases. sys.s
will have to provide wrappers for all of the system calls we use and
to provide a caught-signal handler. Oh joy.
- 8l (src/cmd/8l/obj.c) needs to learn how to generate BSD-friendly
ELF files. -H7 (currently default on Linux) produces Linux ELFs. I
have no idea what's involved with this.
- we need a src/libcgo/dragonfly_386.c, which would know where in the
TLS to stick ThreadStart.m and ThreadStart.g. This might not be
mandatory, we might need this only if we are using libcgo?
- ???
Am I missing anything?
Happy hacking,
-- vs