Re: [patch] libgo - fix build errors and add ARM bits

2012-12-03 Thread Ian Lance Taylor
On Mon, Nov 19, 2012 at 8:27 AM, Matthias Klose d...@ubuntu.com wrote:
 libgo-fix-arm.diff: Work around parse error of struct timex_ on ARM (both 
 trunk
 and 4.7 branch).

 libgo-hardening.diff: Avoid compiler warnings in libgo with 
 -D_FORTIFY_SOURCE=2,
 which let the build fail with -Werror. first chunk for the trunk and 4.7, 
 second
 chunk for trunk only.

 libgo-mksysinfo.diff: Fix TIOCNOTTY and TIOCSCTTY definitions, afaicr needed 
 for
 ARM as well. for trunk and 4.7.

Thanks.  I committed the libgo-hardening and libgo-mksysinfo patches
to mainline and 4.7 branch.


Can you tell me more about the libgo-fix-arm patch?  The patch adds
these lines to mksysinfo.sh:

+# ARM
+sed -i '/type _timex/s/INVALID-bit-field/int32/g;/type _timex/s,^//
,,' gen-sysinfo.go

I don't understand why there would an INVALID-bit-field on ARM.  This
struct comes from the sys/timex.h, which as far as I can see should
be the same on every glibc system.

What does struct timex look like in your sys/timex.h file?  What
does the line look like in gen-sysinfo.go before the sed script above
is run?

Ian


Re: [patch] libgo - fix build errors and add ARM bits

2012-12-03 Thread Matthias Klose
Am 04.12.2012 07:26, schrieb Ian Lance Taylor:
 On Mon, Nov 19, 2012 at 8:27 AM, Matthias Klose d...@ubuntu.com wrote:
 libgo-fix-arm.diff: Work around parse error of struct timex_ on ARM (both 
 trunk
 and 4.7 branch).

 libgo-hardening.diff: Avoid compiler warnings in libgo with 
 -D_FORTIFY_SOURCE=2,
 which let the build fail with -Werror. first chunk for the trunk and 4.7, 
 second
 chunk for trunk only.

 libgo-mksysinfo.diff: Fix TIOCNOTTY and TIOCSCTTY definitions, afaicr needed 
 for
 ARM as well. for trunk and 4.7.
 
 Thanks.  I committed the libgo-hardening and libgo-mksysinfo patches
 to mainline and 4.7 branch.
 
 
 Can you tell me more about the libgo-fix-arm patch?  The patch adds
 these lines to mksysinfo.sh:
 
 +# ARM
 +sed -i '/type _timex/s/INVALID-bit-field/int32/g;/type _timex/s,^//
 ,,' gen-sysinfo.go
 
 I don't understand why there would an INVALID-bit-field on ARM.  This
 struct comes from the sys/timex.h, which as far as I can see should
 be the same on every glibc system.
 
 What does struct timex look like in your sys/timex.h file?  What
 does the line look like in gen-sysinfo.go before the sed script above
 is run?

defined in bits/timex.h

struct timex
{
  unsigned int modes;   /* mode selector */
  __syscall_slong_t offset; /* time offset (usec) */
  __syscall_slong_t freq;   /* frequency offset (scaled ppm) */
  __syscall_slong_t maxerror;   /* maximum error (usec) */
  __syscall_slong_t esterror;   /* estimated error (usec) */
  int status;   /* clock command/status */
  __syscall_slong_t constant;   /* pll time constant */
  __syscall_slong_t precision;  /* clock precision (usec) (ro) */
  __syscall_slong_t tolerance;  /* clock frequency tolerance (ppm) (ro) */
  struct timeval time;  /* (read only) */
  __syscall_slong_t tick;   /* (modified) usecs between clock ticks */
  __syscall_slong_t ppsfreq;/* pps frequency (scaled ppm) (ro) */
  __syscall_slong_t jitter; /* pps jitter (us) (ro) */
  int shift;/* interval duration (s) (shift) (ro) */
  __syscall_slong_t stabil; /* pps stability (scaled ppm) (ro) */
  __syscall_slong_t jitcnt; /* jitter limit exceeded (ro) */
  __syscall_slong_t calcnt; /* calibration intervals (ro) */
  __syscall_slong_t errcnt; /* calibration errors (ro) */
  __syscall_slong_t stbcnt; /* stability limit exceeded (ro) */

  int tai;  /* TAI offset (ro) */

  /* ??? */
  int  :32; int  :32; int  :32; int  :32;
  int  :32; int  :32; int  :32; int  :32;
  int  :32; int  :32; int  :32;
};


I'll have to re-run the build with out the patch, but this replaces just the
32bit bit fields with an int32.

  Matthias



Re: [patch] libgo - fix build errors and add ARM bits

2012-12-03 Thread Ian Lance Taylor
On Mon, Dec 3, 2012 at 10:47 PM, Matthias Klose d...@ubuntu.com wrote:
 Am 04.12.2012 07:26, schrieb Ian Lance Taylor:
 On Mon, Nov 19, 2012 at 8:27 AM, Matthias Klose d...@ubuntu.com wrote:
 libgo-fix-arm.diff: Work around parse error of struct timex_ on ARM (both 
 trunk
 and 4.7 branch).

 libgo-hardening.diff: Avoid compiler warnings in libgo with 
 -D_FORTIFY_SOURCE=2,
 which let the build fail with -Werror. first chunk for the trunk and 4.7, 
 second
 chunk for trunk only.

 libgo-mksysinfo.diff: Fix TIOCNOTTY and TIOCSCTTY definitions, afaicr 
 needed for
 ARM as well. for trunk and 4.7.

 Thanks.  I committed the libgo-hardening and libgo-mksysinfo patches
 to mainline and 4.7 branch.


 Can you tell me more about the libgo-fix-arm patch?  The patch adds
 these lines to mksysinfo.sh:

 +# ARM
 +sed -i '/type _timex/s/INVALID-bit-field/int32/g;/type _timex/s,^//
 ,,' gen-sysinfo.go

 I don't understand why there would an INVALID-bit-field on ARM.  This
 struct comes from the sys/timex.h, which as far as I can see should
 be the same on every glibc system.

 What does struct timex look like in your sys/timex.h file?  What
 does the line look like in gen-sysinfo.go before the sed script above
 is run?

 defined in bits/timex.h

 struct timex
 {
   unsigned int modes;   /* mode selector */
   __syscall_slong_t offset; /* time offset (usec) */
   __syscall_slong_t freq;   /* frequency offset (scaled ppm) */
   __syscall_slong_t maxerror;   /* maximum error (usec) */
   __syscall_slong_t esterror;   /* estimated error (usec) */
   int status;   /* clock command/status */
   __syscall_slong_t constant;   /* pll time constant */
   __syscall_slong_t precision;  /* clock precision (usec) (ro) */
   __syscall_slong_t tolerance;  /* clock frequency tolerance (ppm) (ro) */
   struct timeval time;  /* (read only) */
   __syscall_slong_t tick;   /* (modified) usecs between clock ticks */
   __syscall_slong_t ppsfreq;/* pps frequency (scaled ppm) (ro) */
   __syscall_slong_t jitter; /* pps jitter (us) (ro) */
   int shift;/* interval duration (s) (shift) (ro) */
   __syscall_slong_t stabil; /* pps stability (scaled ppm) (ro) */
   __syscall_slong_t jitcnt; /* jitter limit exceeded (ro) */
   __syscall_slong_t calcnt; /* calibration intervals (ro) */
   __syscall_slong_t errcnt; /* calibration errors (ro) */
   __syscall_slong_t stbcnt; /* stability limit exceeded (ro) */

   int tai;  /* TAI offset (ro) */

   /* ??? */
   int  :32; int  :32; int  :32; int  :32;
   int  :32; int  :32; int  :32; int  :32;
   int  :32; int  :32; int  :32;
 };


 I'll have to re-run the build with out the patch, but this replaces just the
 32bit bit fields with an int32.

Thanks.  That's more or less what timex.h looks like on my system, but
I don't see the bitfields.  GCC treats the :32 fields as int32, in
both 32-bit and 64-bit mode.

Ian


Re: [patch] libgo - fix build errors and add ARM bits

2012-12-03 Thread Matthias Klose
Am 04.12.2012 08:03, schrieb Ian Lance Taylor:
 On Mon, Dec 3, 2012 at 10:47 PM, Matthias Klose d...@ubuntu.com wrote:
 Am 04.12.2012 07:26, schrieb Ian Lance Taylor:
 On Mon, Nov 19, 2012 at 8:27 AM, Matthias Klose d...@ubuntu.com wrote:
 libgo-fix-arm.diff: Work around parse error of struct timex_ on ARM (both 
 trunk
 and 4.7 branch).

 libgo-hardening.diff: Avoid compiler warnings in libgo with 
 -D_FORTIFY_SOURCE=2,
 which let the build fail with -Werror. first chunk for the trunk and 4.7, 
 second
 chunk for trunk only.

 libgo-mksysinfo.diff: Fix TIOCNOTTY and TIOCSCTTY definitions, afaicr 
 needed for
 ARM as well. for trunk and 4.7.

 Thanks.  I committed the libgo-hardening and libgo-mksysinfo patches
 to mainline and 4.7 branch.


 Can you tell me more about the libgo-fix-arm patch?  The patch adds
 these lines to mksysinfo.sh:

 +# ARM
 +sed -i '/type _timex/s/INVALID-bit-field/int32/g;/type _timex/s,^//
 ,,' gen-sysinfo.go

 I don't understand why there would an INVALID-bit-field on ARM.  This
 struct comes from the sys/timex.h, which as far as I can see should
 be the same on every glibc system.

 What does struct timex look like in your sys/timex.h file?  What
 does the line look like in gen-sysinfo.go before the sed script above
 is run?

 defined in bits/timex.h

 struct timex
 {
   unsigned int modes;   /* mode selector */
   __syscall_slong_t offset; /* time offset (usec) */
   __syscall_slong_t freq;   /* frequency offset (scaled ppm) */
   __syscall_slong_t maxerror;   /* maximum error (usec) */
   __syscall_slong_t esterror;   /* estimated error (usec) */
   int status;   /* clock command/status */
   __syscall_slong_t constant;   /* pll time constant */
   __syscall_slong_t precision;  /* clock precision (usec) (ro) */
   __syscall_slong_t tolerance;  /* clock frequency tolerance (ppm) (ro) */
   struct timeval time;  /* (read only) */
   __syscall_slong_t tick;   /* (modified) usecs between clock ticks */
   __syscall_slong_t ppsfreq;/* pps frequency (scaled ppm) (ro) */
   __syscall_slong_t jitter; /* pps jitter (us) (ro) */
   int shift;/* interval duration (s) (shift) (ro) */
   __syscall_slong_t stabil; /* pps stability (scaled ppm) (ro) */
   __syscall_slong_t jitcnt; /* jitter limit exceeded (ro) */
   __syscall_slong_t calcnt; /* calibration intervals (ro) */
   __syscall_slong_t errcnt; /* calibration errors (ro) */
   __syscall_slong_t stbcnt; /* stability limit exceeded (ro) */

   int tai;  /* TAI offset (ro) */

   /* ??? */
   int  :32; int  :32; int  :32; int  :32;
   int  :32; int  :32; int  :32; int  :32;
   int  :32; int  :32; int  :32;
 };


 I'll have to re-run the build with out the patch, but this replaces just the
 32bit bit fields with an int32.
 
 Thanks.  That's more or less what timex.h looks like on my system, but
 I don't see the bitfields.  GCC treats the :32 fields as int32, in
 both 32-bit and 64-bit mode.

sorry, this was fixed with the patch for PR52557.



Re: [patch] libgo - fix build errors and add ARM bits

2012-12-03 Thread Ian Lance Taylor
On Mon, Dec 3, 2012 at 11:38 PM, Matthias Klose d...@ubuntu.com wrote:
 Am 04.12.2012 08:03, schrieb Ian Lance Taylor:
 On Mon, Dec 3, 2012 at 10:47 PM, Matthias Klose d...@ubuntu.com wrote:
 Am 04.12.2012 07:26, schrieb Ian Lance Taylor:
 On Mon, Nov 19, 2012 at 8:27 AM, Matthias Klose d...@ubuntu.com wrote:
 libgo-fix-arm.diff: Work around parse error of struct timex_ on ARM (both 
 trunk
 and 4.7 branch).

 libgo-hardening.diff: Avoid compiler warnings in libgo with 
 -D_FORTIFY_SOURCE=2,
 which let the build fail with -Werror. first chunk for the trunk and 4.7, 
 second
 chunk for trunk only.

 libgo-mksysinfo.diff: Fix TIOCNOTTY and TIOCSCTTY definitions, afaicr 
 needed for
 ARM as well. for trunk and 4.7.

 Thanks.  I committed the libgo-hardening and libgo-mksysinfo patches
 to mainline and 4.7 branch.


 Can you tell me more about the libgo-fix-arm patch?  The patch adds
 these lines to mksysinfo.sh:

 +# ARM
 +sed -i '/type _timex/s/INVALID-bit-field/int32/g;/type _timex/s,^//
 ,,' gen-sysinfo.go

 I don't understand why there would an INVALID-bit-field on ARM.  This
 struct comes from the sys/timex.h, which as far as I can see should
 be the same on every glibc system.

 What does struct timex look like in your sys/timex.h file?  What
 does the line look like in gen-sysinfo.go before the sed script above
 is run?

 defined in bits/timex.h

 struct timex
 {
   unsigned int modes;   /* mode selector */
   __syscall_slong_t offset; /* time offset (usec) */
   __syscall_slong_t freq;   /* frequency offset (scaled ppm) */
   __syscall_slong_t maxerror;   /* maximum error (usec) */
   __syscall_slong_t esterror;   /* estimated error (usec) */
   int status;   /* clock command/status */
   __syscall_slong_t constant;   /* pll time constant */
   __syscall_slong_t precision;  /* clock precision (usec) (ro) */
   __syscall_slong_t tolerance;  /* clock frequency tolerance (ppm) (ro) */
   struct timeval time;  /* (read only) */
   __syscall_slong_t tick;   /* (modified) usecs between clock ticks */
   __syscall_slong_t ppsfreq;/* pps frequency (scaled ppm) (ro) */
   __syscall_slong_t jitter; /* pps jitter (us) (ro) */
   int shift;/* interval duration (s) (shift) (ro) */
   __syscall_slong_t stabil; /* pps stability (scaled ppm) (ro) */
   __syscall_slong_t jitcnt; /* jitter limit exceeded (ro) */
   __syscall_slong_t calcnt; /* calibration intervals (ro) */
   __syscall_slong_t errcnt; /* calibration errors (ro) */
   __syscall_slong_t stbcnt; /* stability limit exceeded (ro) */

   int tai;  /* TAI offset (ro) */

   /* ??? */
   int  :32; int  :32; int  :32; int  :32;
   int  :32; int  :32; int  :32; int  :32;
   int  :32; int  :32; int  :32;
 };


 I'll have to re-run the build with out the patch, but this replaces just the
 32bit bit fields with an int32.

 Thanks.  That's more or less what timex.h looks like on my system, but
 I don't see the bitfields.  GCC treats the :32 fields as int32, in
 both 32-bit and 64-bit mode.

 sorry, this was fixed with the patch for PR52557.

Oh yeah.  Thanks for looking into it.

Ian


[patch] libgo - fix build errors and add ARM bits

2012-11-19 Thread Matthias Klose
libgo-fix-arm.diff: Work around parse error of struct timex_ on ARM (both trunk
and 4.7 branch).

libgo-hardening.diff: Avoid compiler warnings in libgo with -D_FORTIFY_SOURCE=2,
which let the build fail with -Werror. first chunk for the trunk and 4.7, second
chunk for trunk only.

libgo-mksysinfo.diff: Fix TIOCNOTTY and TIOCSCTTY definitions, afaicr needed for
ARM as well. for trunk and 4.7.

I did sign the contributors agreement at
http://golang.org/doc/contribute.html#copyright, however I didn't get any
feedback or acknowledgement yet.

  Matthias
# DP: libgo: Work around parse error of struct timex_ on ARM

Index: b/src/libgo/mksysinfo.sh
===
--- a/src/libgo/mksysinfo.sh
+++ b/src/libgo/mksysinfo.sh
@@ -173,6 +173,9 @@
 
 ${CC} -fdump-go-spec=gen-sysinfo.go -std=gnu99 -S -o sysinfo.s sysinfo.c
 
+# ARM
+sed -i '/type _timex/s/INVALID-bit-field/int32/g;/type _timex/s,^// ,,' gen-sysinfo.go
+
 echo 'package syscall'  ${OUT}
 echo 'import unsafe'  ${OUT}
 echo 'type _ unsafe.Pointer'  ${OUT}
# DP: Avoid compiler warnings in libgo with -D_FORTIFY_SOURCE=2

Index: b/src/libgo/runtime/print.c
===
--- a/src/libgo/runtime/print.c
+++ b/src/libgo/runtime/print.c
@@ -18,7 +18,7 @@
 	G* g = runtime_g();
 
 	if(g == nil || g-writebuf == nil) {
-		runtime_write(2, v, n);
+		ssize_t rv __attribute((unused)) = runtime_write(2, v, n);
 		return;
 	}
 
# DP: Fix build failure in libgo with -Werror -D_FORTIFY_SOURCE=2

--- a/src/libgo/runtime/go-signal.c
+++ b/src/libgo/runtime/go-signal.c
@@ -144,10 +144,12 @@
 static void
 runtime_badsignal(int32 sig)
 {
+	ssize_t rv __attribute__((unused));
+
 	if (sig == SIGPROF) {
 		return;  // Ignore SIGPROFs intended for a non-Go thread.
 	}
-	runtime_write(2, badsignal, sizeof badsignal - 1);
+	rv = runtime_write(2, badsignal, sizeof badsignal - 1);
 	runtime_exit(1);
 }
 
# DP: libgo: Fix TIOCNOTTY and TIOCSCTTY definitions

Index: b/src/libgo/mksysinfo.sh
===
--- a/src/libgo/mksysinfo.sh
+++ b/src/libgo/mksysinfo.sh
@@ -168,6 +168,12 @@
 #ifdef TIOCGWINSZ
   TIOCGWINSZ_val = TIOCGWINSZ,
 #endif
+#ifdef TIOCNOTTY
+  TIOCNOTTY_val = TIOCNOTTY,
+#endif
+#ifdef TIOCSCTTY
+  TIOCSCTTY_val = TIOCSCTTY,
+#endif
 };
 EOF
 
@@ -728,6 +734,16 @@
 echo 'const TIOCGWINSZ = _TIOCGWINSZ_val'  ${OUT}
   fi
 fi
+if ! grep '^const TIOCNOTTY' ${OUT} /dev/null 21; then
+  if grep '^const _TIOCNOTTY_val' ${OUT} /dev/null 21; then
+echo 'const TIOCNOTTY = _TIOCNOTTY_val'  ${OUT}
+  fi
+fi
+if ! grep '^const TIOCSCTTY' ${OUT} /dev/null 21; then
+  if grep '^const _TIOCSCTTY_val' ${OUT} /dev/null 21; then
+echo 'const TIOCSCTTY = _TIOCSCTTY_val'  ${OUT}
+  fi
+fi
 
 # The ioctl flags for terminal control
 grep '^const _TC[GS]ET' gen-sysinfo.go | \