Import go-1.

Go is an open source programming environment that makes it easy to build
simple, reliable, and efficient software.

With assistance from sthen@

ok sthen@
This commit is contained in:
jsing 2012-03-31 12:37:15 +00:00
parent 3027ee47cd
commit fe4700260e
12 changed files with 3159 additions and 0 deletions

96
lang/go/Makefile Normal file
View File

@ -0,0 +1,96 @@
# $OpenBSD: Makefile,v 1.1.1.1 2012/03/31 12:37:15 jsing Exp $
ONLY_FOR_ARCHS = amd64 i386
COMMENT = Go programming language
VERSION = 1
EXTRACT_SUFX = .src.tar.gz
DISTNAME = go.go${VERSION}
PKGNAME = go-${VERSION}
CATEGORIES = lang
HOMEPAGE = http://www.golang.org/
MAINTAINER = Joel Sing <jsing@openbsd.org>
# software: BSD, documentation: CC-BY-3.0
PERMIT_PACKAGE_CDROM = Yes
PERMIT_PACKAGE_FTP = Yes
PERMIT_DISTFILES_CDROM = Yes
PERMIT_DISTFILES_FTP = Yes
WANTLIB = c m
MASTER_SITES = http://go.googlecode.com/files/
BUILD_DEPENDS = shells/bash
SEPARATE_BUILD = simple
CONFIGURE_STYLE = None
SUBST_VARS = GOEXE GOCFG
WRKDIST = ${WRKDIR}/go
WRKSRC = ${WRKDIST}/src
GOOS = openbsd
GOARCH = unknown
GOROOT = ${PREFIX}/go
.if ${MACHINE_ARCH} == "amd64"
GOARCH = amd64
EXEPREFIX = 6
PKG_ARGS += -Damd64=1
PKG_ARGS += -Di386=0
.elif ${MACHINE_ARCH} == "i386"
GOARCH = 386
EXEPREFIX = 8
PKG_ARGS += -Damd64=0
PKG_ARGS += -Di386=1
.endif
GOCFG = /${GOOS}_${GOARCH}
GOEXE = ${GOCFG}/${EXEPREFIX}
do-configure:
. if ${GOARCH} == "unknown"
@echo "Unable to determine GOARCH for ${MACHINE_ARCH}."
@exit 1
. endif
do-build:
@cd ${WRKSRC} && \
GOROOT_FINAL=${GOROOT} ./make.bash --no-banner
do-regress:
@cd ${WRKSRC} && \
ulimit -n 256 -d 2097152 && \
PATH=${PATH}:${WRKDIST}/bin GOROOT=${WRKDIST} ./run.bash
do-install:
${INSTALL_PROGRAM} ${WRKDIST}/bin/go{,doc,fmt} ${PREFIX}/bin
${INSTALL_PROGRAM_DIR} ${GOROOT}
@cd ${WRKDIST} && \
find . ! -name .hg\* -type f -maxdepth 1 \
-exec ${INSTALL_DATA} {} \
${GOROOT} \;
. for dir in doc include lib src pkg
@cd ${WRKDIST} && \
find ${dir} -type d \
-exec ${INSTALL_DATA_DIR} \
${GOROOT}/{} \;
@cd ${WRKDIST} && \
find ${dir} ! -name \*.orig -type f \
-exec ${INSTALL_DATA} {} \
${GOROOT}/{} \;
. endfor
# These get installed via `find' however we need them to be executable
${INSTALL_PROGRAM_DIR} ${GOROOT}/pkg/tool/${GOOS}_${GOARCH}
${INSTALL_PROGRAM} ${WRKDIST}/pkg/tool/${GOOS}_${GOARCH}/* \
${GOROOT}/pkg/tool/${GOOS}_${GOARCH}
.include <bsd.port.mk>

5
lang/go/distinfo Normal file
View File

@ -0,0 +1,5 @@
MD5 (go.go1.src.tar.gz) = eYvPwjm/mC1xlWMMwLQUaw==
RMD160 (go.go1.src.tar.gz) = Rr015SaZ2zNWmPPUQFShJQRQy4U=
SHA1 (go.go1.src.tar.gz) = YCNiPQg9sZgJZTNbisT6i0KPpIQ=
SHA256 (go.go1.src.tar.gz) = RO1cFmVNAuzZGtO9jlVkG4FVYcTsKATSl1PbvO+6dt4=
SIZE (go.go1.src.tar.gz) = 9637785

View File

@ -0,0 +1,27 @@
$OpenBSD: patch-src_pkg_runtime_os_openbsd_h,v 1.1.1.1 2012/03/31 12:37:16 jsing Exp $
--- src/pkg/runtime/os_openbsd.h.orig Mon Mar 19 00:13:54 2012
+++ src/pkg/runtime/os_openbsd.h Mon Mar 19 00:13:54 2012
@@ -5,14 +5,19 @@
#define SIG_DFL ((void*)0)
#define SIG_IGN ((void*)1)
+#define SIG_BLOCK 1
+#define SIG_UNBLOCK 2
+#define SIG_SETMASK 3
+
struct sigaction;
-void runtime·sigpanic(void);
-void runtime·sigaltstack(Sigaltstack*, Sigaltstack*);
-void runtime·sigaction(int32, struct sigaction*, struct sigaction*);
+void runtime·setitimer(int32, Itimerval*, Itimerval*);
void runtime·setsig(int32, void(*)(int32, Siginfo*, void*, G*), bool);
+void runtime·sigaction(int32, struct sigaction*, struct sigaction*);
+void runtime·sigaltstack(Sigaltstack*, Sigaltstack*);
void runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp);
-void runtime·setitimer(int32, Itimerval*, Itimerval*);
+void runtime·sigpanic(void);
+Sigset runtime·sigprocmask(int32, Sigset);
int32 runtime·sysctl(uint32*, uint32, byte*, uintptr*, byte*, uintptr);
void runtime·raisesigpipe(void);

View File

@ -0,0 +1,30 @@
$OpenBSD: patch-src_pkg_runtime_signals_openbsd_h,v 1.1.1.1 2012/03/31 12:37:16 jsing Exp $
--- src/pkg/runtime/signals_openbsd.h.orig Mon Mar 19 00:13:54 2012
+++ src/pkg/runtime/signals_openbsd.h Mon Mar 19 00:13:54 2012
@@ -9,16 +9,16 @@
#define D SigDefault
SigTab runtime·sigtab[] = {
- /* 0 */ 0, "SIGNONE: no trap",
- /* 1 */ N+K, "SIGHUP: terminal line hangup",
- /* 2 */ N+K, "SIGINT: interrupt",
- /* 3 */ N+T, "SIGQUIT: quit",
- /* 4 */ T, "SIGILL: illegal instruction",
- /* 5 */ T, "SIGTRAP: trace trap",
- /* 6 */ N+T, "SIGABRT: abort",
- /* 7 */ T, "SIGEMT: emulate instruction executed",
- /* 8 */ P, "SIGFPE: floating-point exception",
- /* 9 */ 0, "SIGKILL: kill",
+ /* 0 */ 0, "SIGNONE: no trap",
+ /* 1 */ N+K, "SIGHUP: terminal line hangup",
+ /* 2 */ N+K, "SIGINT: interrupt",
+ /* 3 */ N+T, "SIGQUIT: quit",
+ /* 4 */ T, "SIGILL: illegal instruction",
+ /* 5 */ T, "SIGTRAP: trace trap",
+ /* 6 */ N+T, "SIGABRT: abort",
+ /* 7 */ T, "SIGEMT: emulate instruction executed",
+ /* 8 */ P, "SIGFPE: floating-point exception",
+ /* 9 */ 0, "SIGKILL: kill",
/* 10 */ P, "SIGBUS: bus error",
/* 11 */ P, "SIGSEGV: segmentation violation",
/* 12 */ T, "SIGSYS: bad system call",

View File

@ -0,0 +1,85 @@
$OpenBSD: patch-src_pkg_runtime_sys_openbsd_386_s,v 1.1.1.1 2012/03/31 12:37:16 jsing Exp $
--- src/pkg/runtime/sys_openbsd_386.s.orig Mon Mar 19 00:13:54 2012
+++ src/pkg/runtime/sys_openbsd_386.s Mon Mar 19 00:13:54 2012
@@ -12,14 +12,16 @@
TEXT runtime·exit(SB),7,$-4
MOVL $1, AX
INT $0x80
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
-TEXT runtime·exit1(SB),7,$-4
- MOVL $302, AX // sys_threxit
+TEXT runtime·exit1(SB),7,$8
+ MOVL $0, 0(SP)
+ MOVL $0, 4(SP) // arg 1 - notdead
+ MOVL $302, AX // sys___threxit
INT $0x80
JAE 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·write(SB),7,$-4
@@ -79,7 +81,7 @@ TEXT runtime·munmap(SB),7,$-4
MOVL $73, AX // sys_munmap
INT $0x80
JAE 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·setitimer(SB),7,$-4
@@ -132,9 +134,17 @@ TEXT runtime·sigaction(SB),7,$-4
MOVL $46, AX // sys_sigaction
INT $0x80
JAE 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
+TEXT runtime·sigprocmask(SB),7,$-4
+ MOVL $48, AX // sys_sigprocmask
+ INT $0x80
+ JAE 2(PC)
+ MOVL $0xf1, 0xf1 // crash
+ MOVL AX, oset+0(FP)
+ RET
+
TEXT runtime·sigtramp(SB),7,$44
get_tls(CX)
@@ -174,7 +184,7 @@ TEXT runtime·sigtramp(SB),7,$44
MOVL AX, 4(SP) // arg 1 - sigcontext
MOVL $103, AX // sys_sigreturn
INT $0x80
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
// int32 rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
@@ -286,7 +296,7 @@ TEXT runtime·settls(SB),7,$16
MOVL $165, AX // sys_sysarch
INT $0x80
JCC 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·osyield(SB),7,$-4
@@ -295,12 +305,12 @@ TEXT runtime·osyield(SB),7,$-4
RET
TEXT runtime·thrsleep(SB),7,$-4
- MOVL $300, AX // sys_thrsleep
+ MOVL $300, AX // sys___thrsleep
INT $0x80
RET
TEXT runtime·thrwakeup(SB),7,$-4
- MOVL $301, AX // sys_thrwakeup
+ MOVL $301, AX // sys___thrwakeup
INT $0x80
RET

View File

@ -0,0 +1,124 @@
$OpenBSD: patch-src_pkg_runtime_sys_openbsd_amd64_s,v 1.1.1.1 2012/03/31 12:37:16 jsing Exp $
--- src/pkg/runtime/sys_openbsd_amd64.s.orig Mon Mar 19 00:13:54 2012
+++ src/pkg/runtime/sys_openbsd_amd64.s Mon Mar 19 00:13:54 2012
@@ -53,7 +53,8 @@ TEXT runtime·rfork_thread(SB),7,$0
CALL R12
// It shouldn't return. If it does, exit
- MOVL $302, AX // sys_threxit
+ MOVQ $0, DI // arg 1 - notdead
+ MOVL $302, AX // sys___threxit
SYSCALL
JMP -3(PC) // keep exiting
@@ -67,14 +68,15 @@ TEXT runtime·thrsleep(SB),7,$0
MOVL 16(SP), SI // arg 2 - clock_id
MOVQ 24(SP), DX // arg 3 - tp
MOVQ 32(SP), R10 // arg 4 - lock
- MOVL $300, AX // sys_thrsleep
+ MOVQ 40(SP), R8 // arg 5 - abort
+ MOVL $300, AX // sys___thrsleep
SYSCALL
RET
TEXT runtime·thrwakeup(SB),7,$0
MOVQ 8(SP), DI // arg 1 - ident
MOVL 16(SP), SI // arg 2 - n
- MOVL $301, AX // sys_thrwakeup
+ MOVL $301, AX // sys___thrwakeup
SYSCALL
RET
@@ -83,13 +85,14 @@ TEXT runtime·exit(SB),7,$-8
MOVL 8(SP), DI // arg 1 - exit status
MOVL $1, AX // sys_exit
SYSCALL
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·exit1(SB),7,$-8
- MOVL $302, AX // sys_threxit
+ MOVQ $0, DI // arg 1 - notdead
+ MOVL $302, AX // sys___threxit
SYSCALL
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·write(SB),7,$-8
@@ -140,7 +143,7 @@ TEXT time·now(SB), 7, $32
MOVL $116, AX // sys_gettimeofday
SYSCALL
MOVQ 8(SP), AX // sec
- MOVL 16(SP), DX // usec
+ MOVL 16(SP), DX // usec
// sec is in AX, usec in DX
MOVQ AX, sec+0(FP)
@@ -154,7 +157,7 @@ TEXT runtime·nanotime(SB),7,$32
MOVL $116, AX // sys_gettimeofday
SYSCALL
MOVQ 8(SP), AX // sec
- MOVL 16(SP), DX // usec
+ MOVL 16(SP), DX // usec
// sec is in AX, usec in DX
// return nsec in AX
@@ -170,9 +173,19 @@ TEXT runtime·sigaction(SB),7,$-8
MOVL $46, AX
SYSCALL
JCC 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
+TEXT runtime·sigprocmask(SB),7,$0
+ MOVL 8(SP), DI // arg 1 - how
+ MOVL 12(SP), SI // arg 2 - set
+ MOVL $48, AX // sys_sigprocmask
+ SYSCALL
+ JCC 2(PC)
+ MOVL $0xf1, 0xf1 // crash
+ MOVL AX, oset+0(FP) // Return oset
+ RET
+
TEXT runtime·sigtramp(SB),7,$64
get_tls(BX)
@@ -226,7 +239,7 @@ TEXT runtime·munmap(SB),7,$0
MOVL $73, AX // sys_munmap
SYSCALL
JCC 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·sigaltstack(SB),7,$-8
@@ -235,7 +248,7 @@ TEXT runtime·sigaltstack(SB),7,$-8
MOVQ $288, AX // sys_sigaltstack
SYSCALL
JCC 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
// set tls base to DI
@@ -248,7 +261,7 @@ TEXT runtime·settls(SB),7,$8
MOVQ $165, AX // sys_sysarch
SYSCALL
JCC 2(PC)
- MOVL $0xf1, 0xf1 // crash
+ MOVL $0xf1, 0xf1 // crash
RET
TEXT runtime·sysctl(SB),7,$0
@@ -260,7 +273,7 @@ TEXT runtime·sysctl(SB),7,$0
MOVQ 48(SP), R9 // arg 6 - newlen
MOVQ $202, AX // sys___sysctl
SYSCALL
- JCC 3(PC)
+ JCC 3(PC)
NEGL AX
RET
MOVL $0, AX

View File

@ -0,0 +1,60 @@
$OpenBSD: patch-src_pkg_runtime_thread_openbsd_c,v 1.1.1.1 2012/03/31 12:37:16 jsing Exp $
--- src/pkg/runtime/thread_openbsd.c.orig Mon Mar 19 00:13:54 2012
+++ src/pkg/runtime/thread_openbsd.c Mon Mar 19 00:13:54 2012
@@ -20,8 +20,11 @@ enum
extern SigTab runtime·sigtab[];
+static Sigset sigset_all = ~(Sigset)0;
+static Sigset sigset_none;
+
extern int64 runtime·rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
-extern int32 runtime·thrsleep(void *ident, int32 clock_id, void *tsp, void *lock);
+extern int32 runtime·thrsleep(void *ident, int32 clock_id, void *tsp, void *lock, const int32 *abort);
extern int32 runtime·thrwakeup(void *ident, int32 n);
// From OpenBSD's <sys/sysctl.h>
@@ -69,12 +72,12 @@ runtime·semasleep(int64 ns)
// sleep until semaphore != 0 or timeout.
// thrsleep unlocks m->waitsemalock.
if(ns < 0)
- runtime·thrsleep(&m->waitsemacount, 0, nil, &m->waitsemalock);
+ runtime·thrsleep(&m->waitsemacount, 0, nil, &m->waitsemalock, nil);
else {
ns += runtime·nanotime();
ts.tv_sec = ns/1000000000LL;
ts.tv_nsec = ns%1000000000LL;
- runtime·thrsleep(&m->waitsemacount, CLOCK_REALTIME, &ts, &m->waitsemalock);
+ runtime·thrsleep(&m->waitsemacount, CLOCK_REALTIME, &ts, &m->waitsemalock, nil);
}
// reacquire lock
while(runtime·xchg(&m->waitsemalock, 1))
@@ -128,6 +131,7 @@ runtime·semawakeup(M *mp)
void
runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
{
+ Sigset oset;
int32 flags;
int32 ret;
@@ -141,7 +145,11 @@ runtime·newosproc(M *m, G *g, void *stk, void (*fn)(v
m->tls[0] = m->id; // so 386 asm can find it
- if((ret = runtime·rfork_thread(flags, stk, m, g, fn)) < 0) {
+ oset = runtime·sigprocmask(SIG_SETMASK, sigset_all);
+ ret = runtime·rfork_thread(flags, stk, m, g, fn);
+ runtime·sigprocmask(SIG_SETMASK, oset);
+
+ if(ret < 0) {
runtime·printf("runtime: failed to create new OS thread (have %d already; errno=%d)\n", runtime·mcount() - 1, -ret);
if (ret == -ENOTSUP)
runtime·printf("runtime: is kern.rthreads disabled?\n");
@@ -168,6 +176,7 @@ runtime·minit(void)
// Initialize signal handling
m->gsignal = runtime·malg(32*1024);
runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024);
+ runtime·sigprocmask(SIG_SETMASK, sigset_none);
}
void

9
lang/go/pkg/DESCR Normal file
View File

@ -0,0 +1,9 @@
The Go programming language is an open source project to make
programmers more productive. Go is expressive, concise, clean, and
efficient. Its concurrency mechanisms make it easy to write programs
that get the most out of multicore and networked machines, while its
novel type system enables flexible and modular program construction. Go
compiles quickly to machine code yet has the convenience of garbage
collection and the power of run-time reflection. It's a fast, statically
typed, compiled language that feels like a dynamically typed,
interpreted language.

12
lang/go/pkg/PFRAG.amd64 Normal file
View File

@ -0,0 +1,12 @@
@comment $OpenBSD: PFRAG.amd64,v 1.1.1.1 2012/03/31 12:37:16 jsing Exp $
go/src/cmd/6l/enam.c
go/src/pkg/runtime/zasm_openbsd_amd64.h
go/src/pkg/runtime/zgoarch_amd64.go
go/src/pkg/runtime/zmalloc_amd64.c
go/src/pkg/runtime/zmprof_amd64.c
go/src/pkg/runtime/zruntime1_amd64.c
go/src/pkg/runtime/zruntime_defs_openbsd_amd64.go
go/src/pkg/runtime/zsema_amd64.c
go/src/pkg/runtime/zsigqueue_amd64.c
go/src/pkg/runtime/zstring_amd64.c
go/src/pkg/runtime/ztime_amd64.c

12
lang/go/pkg/PFRAG.i386 Normal file
View File

@ -0,0 +1,12 @@
@comment $OpenBSD: PFRAG.i386,v 1.1.1.1 2012/03/31 12:37:16 jsing Exp $
go/src/cmd/8l/enam.c
go/src/pkg/runtime/zasm_openbsd_386.h
go/src/pkg/runtime/zgoarch_386.go
go/src/pkg/runtime/zmalloc_386.c
go/src/pkg/runtime/zmprof_386.c
go/src/pkg/runtime/zruntime1_386.c
go/src/pkg/runtime/zruntime_defs_openbsd_386.go
go/src/pkg/runtime/zsema_386.c
go/src/pkg/runtime/zsigqueue_386.c
go/src/pkg/runtime/zstring_386.c
go/src/pkg/runtime/ztime_386.c

2696
lang/go/pkg/PLIST Normal file

File diff suppressed because it is too large Load Diff

3
lang/go/systrace.filter Normal file
View File

@ -0,0 +1,3 @@
# $OpenBSD: systrace.filter,v 1.1.1.1 2012/03/31 12:37:16 jsing Exp $
# Go programs (including go_bootstrap) currently need sysarch().
native-sysarch: permit