libgo: define SO_RCVTIMEO on 32-bit GNU/Linux

Fixes golang/go#42872

Change-Id: I509d615b2447008f0e34811c4632ef56a27ea29c
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/273892
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh
index deac5ce..b32a026 100755
--- a/libgo/mksysinfo.sh
+++ b/libgo/mksysinfo.sh
@@ -194,6 +194,7 @@
 
 # Networking constants.
 egrep '^const _(AF|ARPHRD|ETH|IN|SOCK|SOL|SO|IPPROTO|TCP|IP|IPV6)_' gen-sysinfo.go |
+  grep -v '_val =' |
   sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 grep '^const _SOMAXCONN' gen-sysinfo.go |
   sed -e 's/^\(const \)_\(SOMAXCONN[^= ]*\)\(.*\)$/\1\2 = _\2/' \
@@ -213,6 +214,14 @@
   fi
 done
 
+# On 32-bit GNU/Linux the expression for SO_RCVTIMEO is too complicated
+# for -fdump-go-spec.
+if ! grep '^const SO_RCVTIMEO ' ${OUT} >/dev/null 2>&1; then
+  if grep '^const _SO_RCVTIMEO_val' ${OUT} >/dev/null 2>&1; then
+    echo 'const SO_RCVTIMEO = _SO_RCVTIMEO_val' >> ${OUT}
+  fi
+fi
+
 # The syscall package requires AF_LOCAL.
 if ! grep '^const AF_LOCAL ' ${OUT} >/dev/null 2>&1; then
   if grep '^const AF_UNIX ' ${OUT} >/dev/null 2>&1; then
diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index 7086381..a060ea8 100644
--- a/libgo/sysinfo.c
+++ b/libgo/sysinfo.c
@@ -337,6 +337,9 @@
 #ifdef BIOCVERSION
   BIOCVERSION_val = BIOCVERSION,
 #endif
+#ifdef SO_RCVTIMEO
+  SO_RCVTIMEO_val = SO_RCVTIMEO,
+#endif
 };
 
 // SIOCGIFMTU can't be added in the above enum as it might