From 9bac66390c0c838594e42877f938bca441665937 Mon Sep 17 00:00:00 2001 From: Nikhil Benesch Date: Wed, 16 Dec 2020 08:41:20 -0500 Subject: [PATCH] libgo: adjust sysinfo scripts for changed -fdump-go-spec The -fdump-go-spec flag to GCC recently changed to be more fastidious about handling incomplete types. This caused some breakage in mk[r]sysinfo.sh on Solaris. This commit adjusts for the new behavior. Specifically: * Types that refer to _in6_addr may be hidden behind a typedef and can no longer be filtered out with `grep -v in6_addr`. Instead just rewrite the definition of _in6_addr to [16]byte wherever it appears. * timestruc_t is now (correctly) emitted as an alias for timespec, so this case is handled specially. * stdio.h is included in sysinfo.c to avoid emitting an incomplete definition of the FILE type. * Dummy definitions for _u?pad128_t are now emitted automatically, which conflict with the definitions installed by mk[r]sysinfo.sh. These definitions were actually dead code, so just remove them. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/278672 --- gcc/go/gofrontend/MERGE | 2 +- libgo/mkrsysinfo.sh | 53 ++++++------------------------------- libgo/mksysinfo.sh | 58 +++++++++-------------------------------- libgo/sysinfo.c | 1 + 4 files changed, 22 insertions(+), 92 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 40242cc6a3f..81deef2cb79 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -1317de50147304a226b3ec5c4d81376470c358e5 +f9e44c6e510df9f047dbe28eb5fa19642e350f8f The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/mkrsysinfo.sh b/libgo/mkrsysinfo.sh index e016ca4dc59..18643370645 100755 --- a/libgo/mkrsysinfo.sh +++ b/libgo/mkrsysinfo.sh @@ -24,12 +24,19 @@ grep -v '^// ' gen-sysinfo.go | \ grep -v '^type _timespec ' | \ grep -v '^type _epoll_' | \ grep -v '^type _*locale[_ ]' | \ - grep -v 'in6_addr' | \ + grep -v '^type _in6_addr' | \ grep -v 'sockaddr_in6' | \ egrep -v '^const _*FLT(64|128)_(NORM_)?MAX' | \ sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1timeval\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_timeval$/\1timeval/g' \ -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1timespec\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_timespec_t$/\1timespec_t/g' \ -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1timespec\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_timespec$/\1timespec/g' \ + -e 's/\([^a-zA-Z0-9_]\)_in6_addr\([^a-zA-Z0-9_]\)/\1[16]byte\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_in6_addr$/\1[16]byte/g' \ + -e 's/\([^a-zA-Z0-9_]\)_in6_addr_t\([^a-zA-Z0-9_]\)/\1[16]byte\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_in6_addr_t$/\1[16]byte/g' \ >> ${OUT} # The C long type, needed because that is the type that ptrace returns. @@ -45,16 +52,6 @@ else exit 1 fi -# On AIX, the _arpcom struct, is filtered by the above grep sequence, as it as -# a field of type _in6_addr, but other types depend on _arpcom, so we need to -# put it back. -grep '^type _arpcom ' gen-sysinfo.go | \ - sed -e 's/_in6_addr/[16]byte/' >> ${OUT} - -# Same on Solaris for _mld_hdr_t. -grep '^type _mld_hdr_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr/[16]byte/' >> ${OUT} - # The time structures need special handling: we need to name the # types, so that we can cast integers to the right types when # assigning to the structures. @@ -166,40 +163,6 @@ fi grep '^type _sem_t ' gen-sysinfo.go | \ sed -e 's/_sem_t/semt/' >> ${OUT} -# Solaris 2 needs _u?pad128_t, but its default definition in terms of long -# double is commented by -fdump-go-spec. -if grep "^// type _pad128_t" gen-sysinfo.go > /dev/null 2>&1; then - echo "type _pad128_t struct { _l [4]int32; }" >> ${OUT} -fi -if grep "^// type _upad128_t" gen-sysinfo.go > /dev/null 2>&1; then - echo "type _upad128_t struct { _l [4]uint32; }" >> ${OUT} -fi - -# The Solaris 11 Update 1 _zone_net_addr_t struct. -grep '^type _zone_net_addr_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr/[16]byte/' \ - >> ${OUT} - -# The Solaris 11.4 _flow_arp_desc_t struct. -grep '^type _flow_arp_desc_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr_t/[16]byte/g' \ - >> ${OUT} - -# The Solaris 11.4 _flow_l3_desc_t struct. -grep '^type _flow_l3_desc_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr_t/[16]byte/g' \ - >> ${OUT} - -# The Solaris 11.3 _mac_ipaddr_t struct. -grep '^type _mac_ipaddr_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr_t/[16]byte/g' \ - >> ${OUT} - -# The Solaris 11.3 _mactun_info_t struct. -grep '^type _mactun_info_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr_t/[16]byte/g' \ - >> ${OUT} - # The Solaris port_event_t struct. grep '^type _port_event_t ' gen-sysinfo.go | \ sed -e s'/_port_event_t/portevent/' \ diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh index 24d4ce2df6b..0c52ea5d71a 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh @@ -36,25 +36,23 @@ grep -v '^// ' gen-sysinfo.go | \ grep -v '^type _timestruc_t ' | \ grep -v '^type _epoll_' | \ grep -v '^type _*locale[_ ]' | \ - grep -v 'in6_addr' | \ + grep -v '^type _in6_addr' | \ grep -v 'sockaddr_in6' | \ egrep -v '^const _*FLT(64|128)_(NORM_)?MAX' | \ sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_timeval$/\1Timeval/g' \ -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_timespec_t$/\1Timespec/g' \ -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_timespec$/\1Timespec/g' \ -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_timestruc_t$/\1Timestruc/g' \ + -e 's/\([^a-zA-Z0-9_]\)_in6_addr\([^a-zA-Z0-9_]\)/\1[16]byte\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_in6_addr$/\1[16]byte/g' \ + -e 's/\([^a-zA-Z0-9_]\)_in6_addr_t\([^a-zA-Z0-9_]\)/\1[16]byte\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_in6_addr_t$/\1[16]byte/g' \ >> ${OUT} -# On AIX, the _arpcom struct, is filtered by the above grep sequence, as it as -# a field of type _in6_addr, but other types depend on _arpcom, so we need to -# put it back. -grep '^type _arpcom ' gen-sysinfo.go | \ - sed -e 's/_in6_addr/[16]byte/' >> ${OUT} - -# Same on Solaris for _mld_hdr_t. -grep '^type _mld_hdr_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr/[16]byte/' >> ${OUT} - # The errno constants. These get type Errno. egrep '#define E[A-Z0-9_]+ [0-9E]' errno.i | \ sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/' >> ${OUT} @@ -442,15 +440,6 @@ else exit 1 fi -# Solaris 2 needs _u?pad128_t, but its default definition in terms of long -# double is commented by -fdump-go-spec. -if grep "^// type _pad128_t" gen-sysinfo.go > /dev/null 2>&1; then - echo "type _pad128_t struct { _l [4]int32; }" >> ${OUT} -fi -if grep "^// type _upad128_t" gen-sysinfo.go > /dev/null 2>&1; then - echo "type _upad128_t struct { _l [4]uint32; }" >> ${OUT} -fi - # The time_t type. if grep '^type _time_t ' gen-sysinfo.go > /dev/null 2>&1; then echo 'type Time_t _time_t' >> ${OUT} @@ -484,7 +473,9 @@ echo $timespec | \ -e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timespec_nsec_t/' >> ${OUT} timestruc=`grep '^type _timestruc_t ' gen-sysinfo.go || true` -if test "$timestruc" != ""; then +if test "$timestruc" = "type _timestruc_t _timespec"; then + echo "type Timestruc Timespec" >> ${OUT} +elif test "$timestruc" != ""; then timestruc_sec=`echo $timestruc | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'` timestruc_nsec=`echo $timestruc | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'` echo "type Timestruc_sec_t = $timestruc_sec" >> ${OUT} @@ -1524,31 +1515,6 @@ if ! grep 'const SizeofICMPv6Filter ' ${OUT} >/dev/null 2>&1; then echo 'const SizeofICMPv6Filter = 32' >> ${OUT} fi -# The Solaris 11 Update 1 _zone_net_addr_t struct. -grep '^type _zone_net_addr_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr/[16]byte/' \ - >> ${OUT} - -# The Solaris 11.4 _flow_arp_desc_t struct. -grep '^type _flow_arp_desc_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr_t/[16]byte/g' \ - >> ${OUT} - -# The Solaris 11.4 _flow_l3_desc_t struct. -grep '^type _flow_l3_desc_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr_t/[16]byte/g' \ - >> ${OUT} - -# The Solaris 11.3 _mac_ipaddr_t struct. -grep '^type _mac_ipaddr_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr_t/[16]byte/g' \ - >> ${OUT} - -# The Solaris 11.3 _mactun_info_t struct. -grep '^type _mactun_info_t ' gen-sysinfo.go | \ - sed -e 's/_in6_addr_t/[16]byte/g' \ - >> ${OUT} - # Type 'uint128' is needed in a couple of type definitions on arm64,such # as _user_fpsimd_struct, _elf_fpregset_t, etc. if ! grep '^type uint128' ${OUT} > /dev/null 2>&1; then diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c index a060ea867a5..8ce061e2f5f 100644 --- a/libgo/sysinfo.c +++ b/libgo/sysinfo.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include -- 2.30.2