diff mbox

libgo patch committed: For c-archive, install signal handler synchronously

Message ID CAOyqgcXhXo3w5Y4HmUhd8ViamZhJrZhNjQyTMNSak4SJ+KsZ1Q@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Feb. 12, 2016, 10:10 p.m. UTC
This patch to libgo ports https://golang.org/cl/18150 from the master
library to the gccgo runtime.  This installs signal handlers
synchronously when building a Go archive, rather than potentially
racing against the main program.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 233290)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-28a9dfbc3cda0bf7fd4f3fb1506c547f6cdf41a5
+22278c6e8ce3982b09111183bc6addf0184bef1f
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/runtime/go-libmain.c
===================================================================
--- libgo/runtime/go-libmain.c	(revision 232239)
+++ libgo/runtime/go-libmain.c	(working copy)
@@ -59,6 +59,10 @@  initfn (int argc, char **argv, char** en
   struct args *a;
   pthread_t tid;
 
+  runtime_isarchive = true;
+
+  runtime_initsig(true);
+
   a = (struct args *) malloc (sizeof *a);
   if (a == NULL)
     die ("malloc", errno);
@@ -88,8 +92,6 @@  gostart (void *arg)
 {
   struct args *a = (struct args *) arg;
 
-  runtime_isarchive = true;
-
   if (runtime_isstarted)
     return NULL;
   runtime_isstarted = true;
Index: libgo/runtime/proc.c
===================================================================
--- libgo/runtime/proc.c	(revision 233260)
+++ libgo/runtime/proc.c	(working copy)
@@ -1093,7 +1093,7 @@  runtime_mstart(void* mp)
 			runtime_newextram();
 			runtime_needextram = 0;
 		}
-		runtime_initsig();
+		runtime_initsig(false);
 	}
 	
 	if(m->mstartfn)
Index: libgo/runtime/runtime.h
===================================================================
--- libgo/runtime/runtime.h	(revision 233260)
+++ libgo/runtime/runtime.h	(working copy)
@@ -550,7 +550,7 @@  void*	runtime_mal(uintptr);
 String	runtime_gostring(const byte*);
 String	runtime_gostringnocopy(const byte*);
 void	runtime_schedinit(void);
-void	runtime_initsig(void);
+void	runtime_initsig(bool);
 void	runtime_sigenable(uint32 sig);
 void	runtime_sigdisable(uint32 sig);
 void	runtime_sigignore(uint32 sig);
Index: libgo/runtime/signal_unix.c
===================================================================
--- libgo/runtime/signal_unix.c	(revision 233110)
+++ libgo/runtime/signal_unix.c	(working copy)
@@ -13,11 +13,16 @@ 
 extern SigTab runtime_sigtab[];
 
 void
-runtime_initsig(void)
+runtime_initsig(bool preinit)
 {
 	int32 i;
 	SigTab *t;
 
+	// For c-archive/c-shared this is called by go-libmain.c with
+	// preinit == true.
+	if(runtime_isarchive && !preinit)
+		return;
+
 	// First call: basic setup.
 	for(i = 0; runtime_sigtab[i].sig != -1; i++) {
 		t = &runtime_sigtab[i];
@@ -37,6 +42,9 @@  runtime_initsig(void)
 			}
 		}
 
+		if(runtime_isarchive && (t->flags&SigPanic) == 0)
+			continue;
+
 		t->flags |= SigHandling;
 		runtime_setsig(i, runtime_sighandler, true);
 	}