Libgo had two identical copies of runtime_osinit. They set
runtime_ncpu, a variable that is no longer used. Removing that leaves
us with two lines. Inline those two lines in the two places the
function was called.  This fixes GCC PR 81451.  Bootstrapped and ran
Go testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE     (revision 250325)
+++ gcc/go/gofrontend/MERGE     (working copy)
@@ -1,4 +1,4 @@
-0036bd04d077f8bbe5aa9a62fb8830c53068209e
+c49ddc84f3ce89310585aad23ab6e51ef5523748
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/Makefile.am
===================================================================
--- libgo/Makefile.am   (revision 250217)
+++ libgo/Makefile.am   (working copy)
@@ -399,12 +399,6 @@ rtems_task_variable_add_file =
 endif
 
 if LIBGO_IS_LINUX
-runtime_thread_files = runtime/thread-linux.c
-else
-runtime_thread_files = runtime/thread-sema.c
-endif
-
-if LIBGO_IS_LINUX
 runtime_getncpu_file = runtime/getncpu-linux.c
 else
 if LIBGO_IS_DARWIN
@@ -469,7 +463,6 @@ runtime_files = \
        runtime/runtime_c.c \
        runtime/stack.c \
        runtime/thread.c \
-       $(runtime_thread_files) \
        runtime/yield.c \
        $(rtems_task_variable_add_file) \
        $(runtime_getncpu_file)
Index: libgo/go/runtime/stubs.go
===================================================================
--- libgo/go/runtime/stubs.go   (revision 249799)
+++ libgo/go/runtime/stubs.go   (working copy)
@@ -422,13 +422,13 @@ func getPanicking() uint32 {
        return panicking
 }
 
-// Temporary for gccgo until we initialize ncpu in Go.
+// Called by C code to set the number of CPUs.
 //go:linkname setncpu runtime.setncpu
 func setncpu(n int32) {
        ncpu = n
 }
 
-// Temporary for gccgo until we reliably initialize physPageSize in Go.
+// Called by C code to set the page size.
 //go:linkname setpagesize runtime.setpagesize
 func setpagesize(s uintptr) {
        if physPageSize == 0 {
Index: libgo/runtime/go-libmain.c
===================================================================
--- libgo/runtime/go-libmain.c  (revision 249799)
+++ libgo/runtime/go-libmain.c  (working copy)
@@ -105,7 +105,8 @@ gostart (void *arg)
 
   runtime_check ();
   runtime_args (a->argc, (byte **) a->argv);
-  runtime_osinit ();
+  setncpu (getproccount ());
+  setpagesize (getpagesize ());
   runtime_sched = runtime_getsched();
   runtime_schedinit ();
   __go_go (runtime_main, NULL);
Index: libgo/runtime/go-main.c
===================================================================
--- libgo/runtime/go-main.c     (revision 249799)
+++ libgo/runtime/go-main.c     (working copy)
@@ -51,7 +51,8 @@ main (int argc, char **argv)
   runtime_cpuinit ();
   runtime_check ();
   runtime_args (argc, (byte **) argv);
-  runtime_osinit ();
+  setncpu (getproccount ());
+  setpagesize (getpagesize ());
   runtime_sched = runtime_getsched();
   runtime_schedinit ();
   __go_go (runtime_main, NULL);
Index: libgo/runtime/proc.c
===================================================================
--- libgo/runtime/proc.c        (revision 249799)
+++ libgo/runtime/proc.c        (working copy)
@@ -370,7 +370,6 @@ extern G* allocg(void)
   __asm__ (GOSYM_PREFIX "runtime.allocg");
 
 Sched* runtime_sched;
-int32  runtime_ncpu;
 
 bool   runtime_isarchive;
 
Index: libgo/runtime/runtime.h
===================================================================
--- libgo/runtime/runtime.h     (revision 249799)
+++ libgo/runtime/runtime.h     (working copy)
@@ -217,7 +217,6 @@ extern      M*      runtime_getallm(void)
 extern Sched*  runtime_sched;
 extern uint32  runtime_panicking(void)
   __asm__ (GOSYM_PREFIX "runtime.getPanicking");
-extern int32   runtime_ncpu;
 extern struct debugVars runtime_debug;
 
 extern bool    runtime_isstarted;
@@ -237,7 +236,6 @@ void        runtime_gogo(G*)
 struct __go_func_type;
 void   runtime_args(int32, byte**)
   __asm__ (GOSYM_PREFIX "runtime.args");
-void   runtime_osinit();
 void   runtime_alginit(void)
   __asm__ (GOSYM_PREFIX "runtime.alginit");
 void   runtime_goargs(void)
Index: libgo/runtime/thread-linux.c
===================================================================
--- libgo/runtime/thread-linux.c        (revision 249799)
+++ libgo/runtime/thread-linux.c        (working copy)
@@ -1,20 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "runtime.h"
-#include "defs.h"
-
-// Linux futex.
-
-#include <unistd.h>
-#include <syscall.h>
-#include <linux/futex.h>
-
-void
-runtime_osinit(void)
-{
-       runtime_ncpu = getproccount();
-       setncpu(runtime_ncpu);
-       setpagesize(getpagesize());
-}
Index: libgo/runtime/thread-sema.c
===================================================================
--- libgo/runtime/thread-sema.c (revision 249799)
+++ libgo/runtime/thread-sema.c (working copy)
@@ -1,20 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "config.h"
-#include "runtime.h"
-
-#include <errno.h>
-#include <stdlib.h>
-#include <time.h>
-#include <unistd.h>
-#include <semaphore.h>
-
-void
-runtime_osinit (void)
-{
-  runtime_ncpu = getproccount();
-  setncpu(runtime_ncpu);
-  setpagesize(getpagesize());
-}

Reply via email to