]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: support for NetBSD/ARM
authorShenghou Ma <minux.ma@gmail.com>
Sat, 2 Mar 2013 22:50:17 +0000 (06:50 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Sat, 2 Mar 2013 22:50:17 +0000 (06:50 +0800)
1. when executing a unsupported VFP instruction, the NetBSD kernel somehow
doesn't report SIGILL, and instead just spin and spin, we add a alarm(2)
to detect this case (albeit this is a kernel bug).
2. NetBSD/ARM's VFP11 support is not complete, so temporarily disable it.
3. The default gcc shipped with NetBSD-current mis-optimizes our code
at -O2, so lower the optimization level to -O1 on NetBSD/ARM.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/7286044

src/cmd/dist/arm.c
src/cmd/dist/build.c
src/cmd/dist/unix.c

index eabf97b9ea24c5ba5749efa9b442cf716eb7f7bf..dafc5c1c256722c4a8fad9e17e3c0288ff630e34 100644 (file)
@@ -17,6 +17,18 @@ static void useVFPv1(void);
 char *
 xgetgoarm(void)
 {
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+       // NetBSD has buggy support for VFPv2 (incorrect inexact, 
+       // denormial, and NaN handling). When GOARM=6, some of our
+       // math tests fails on Raspberry Pi.
+       // Thus we return "5" here for safety, the user is free
+       // to override.
+       // Note: using GOARM=6 with cgo can trigger a kernel assertion
+       // failure and crash NetBSD/evbarm kernel.
+       // FreeBSD also have broken VFP support, so disable VFP also
+       // on FreeBSD.
+       return "5";
+#endif
        if(xtryexecfunc(useVFPv3))
                return "7";
        else if(xtryexecfunc(useVFPv1))
index cf754a4103794220789b9c90358288b7f4739764..dda45ca6258cd05d02429fcfc039b48ac7f3c7a9 100644 (file)
@@ -411,7 +411,13 @@ static char *proto_gccargs[] = {
        "-fno-common",
        "-ggdb",
        "-pipe",
+#if defined(__NetBSD__) && defined(__arm__)
+       // GCC 4.5.4 (NetBSD nb1 20120916) on ARM is known to mis-optimize gc/mparith3.c
+       // Fix available at http://patchwork.ozlabs.org/patch/64562/.
+       "-O1",
+#else
        "-O2",
+#endif
 };
 
 static Vec gccargs;
index d8b88893c91e4172d5b85f78295ae0a7e1e91c03..e4e2dcc9fca8edd4167b36ea3acade9cc6d32321 100644 (file)
@@ -745,17 +745,24 @@ static void sigillhand(int);
 // xtryexecfunc tries to execute function f, if any illegal instruction
 // signal received in the course of executing that function, it will
 // return 0, otherwise it will return 1.
+// Some systems (notably NetBSD) will spin and spin when executing VFPv3
+// instructions on VFPv2 system (e.g. Raspberry Pi) without ever triggering
+// SIGILL, so we set a 1-second alarm to catch that case.
 int
 xtryexecfunc(void (*f)(void))
 {
        int r;
        r = 0;
        signal(SIGILL, sigillhand);
+       signal(SIGALRM, sigillhand);
+       alarm(1);
        if(sigsetjmp(sigill_jmpbuf, 1) == 0) {
                f();
                r = 1;
        }
        signal(SIGILL, SIG_DFL);
+       alarm(0);
+       signal(SIGALRM, SIG_DFL);
        return r;
 }