https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78172
--- Comment #6 from Tony Reix <tony.reix at atos dot net> --- Created attachment 39946 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39946&action=edit Original sysinfo.go file Hi Ian Here is the sysinfo.go file that was generated at first. The previous sysinfo.go file provided in this bug was the result of a patch in order to fix some issue and go further. The faulty line is: type Ucred struct { Cr_ref int32; Cr_ruid uint32; Cr_uid uint32; Cr_suid uint32; Cr_luid uint32; Cr_acctid uint32; Cr_gid uint32; Cr_rgid uint32; Cr_sgid uint32; Cr_ngrps int16; Cr_caps int16; Cr_groupset _groupset_t; Cr_mpriv _priv_t; Cr_ipriv _priv_t; Cr_epriv _priv_t; Cr_bpriv _priv_t; Cr_pag int32; } type _ucred_43 struct { ocr_ref int32; Ocr_ruid uint32; Ocr_uid uint32; Ocr_suid uint32; Ocr_luid uint32; Ocr_acctid uint32; Ocr_gid uint32; Ocr_rgid uint32; Ocr_sgid uint32; Ocr_ngrps int16; Ocr_groups [31+1]uint32; Ocr_mpriv _priv_t; Ocr_ipriv _priv_t; Ocr_epriv _priv_t; Ocr_bpriv _priv_t; Ocr_pag int32; } type _ucred_ext struct { crx_ruid uint32; Crx_uid uint32; Crx_suid uint32; Crx_luid uint32; Crx_acctid uint32; Crx_gid uint32; Crx_rgid uint32; Crx_sgid uint32; Crx_ngrps int32; Crx_groups [127+1]uint32; Crx_reserved_1 int32; Crx_caps ___cap_t; Crx_mpriv _priv_t; Crx_ipriv _priv_t; Crx_epriv _priv_t; Crx_bpriv _priv_t; Crx_npags int32; Crx_pagids [15+1]uint8; Crx_pags [15+1]int32; Crx_reserved_2 int32; Crx_roles [7+1]uint32; Crx_nroles int16; Crx_reserved_3 int16; Crx_flags uint32; Crx_effpriv _privg_t; Crx_maxpriv _privg_t; Crx_inhpriv _privg_t; Crx_limpriv _privg_t; Crx_usedpriv _privg_t; Crx_pad [31+1]int32; } type _ucred_ext2_t struct { crx2_labels _sec_labels_t; Crx_pad [147+1]int32; } This line contains several definitions, like: type Ucred struct { ... } type _ucred_43 struct { ... } type _ucred_ext struct { ... } type _ucred_ext2_t struct { ... } It appears that, on AIX, there are several ucred* definitions and the tool does not handle them correctly. I've written the following patch for working-around the issue: --- old/libgo/mksysinfo.sh 2016-10-21 10:45:35 +0200 +++ new/libgo/mksysinfo.sh 2016-10-21 11:03:34 +0200 @@ -532,7 +532,8 @@ field="$f$r" nfields="$nfields $field;" done - echo "${prefix} {$nfields }" +# AIX: For ucred case, split joined lines "...} type ..." into several lines + echo "${prefix} {$nfields }" | sed -e "s/} type/}\\ntype/g" fi } @@ -816,7 +817,12 @@ sed -e 's/^\(const \)_\(SCM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} # The ucred struct. -upcase_fields "_ucred" "Ucred" >> ${OUT} || true +# AIX: In addition to: _ucred , -fdump-go-spec finds also: _ucred_43 _ucred_ext _ucred_ext2 +# AIX: For ucred, several types after first one are duplicated. Print only first one. +upcase_fields "_ucred" "Ucred" | awk '{print $0; exit}' >> ${OUT} || true +upcase_fields "_ucred_43" "Ucred_43" | awk '{print $0; exit}' >> ${OUT} || true +upcase_fields "_ucred_ext" "Ucred_ext" | awk '{print $0; exit}' >> ${OUT} || true +upcase_fields "_ucred_ext2" "Ucred_ext2" | awk '{print $0; exit}' >> ${OUT} || true # The ip_mreq struct. grep '^type _ip_mreq ' gen-sysinfo.go | \ @@ -1466,6 +1472,7 @@ fi # Struct sizes. +# AIX: This generates several ucred lines set cmsghdr Cmsghdr ip_mreq IPMreq ip_mreqn IPMreqn ipv6_mreq IPv6Mreq \ ifaddrmsg IfAddrmsg ifinfomsg IfInfomsg in_pktinfo Inet4Pktinfo \ in6_pktinfo Inet6Pktinfo inotify_event InotifyEvent linger Linger \ I've found also another issue within mksysinfo.sh on AIX: The "grep -v 'in6_addr'" command removes definition that seem useful. --- old/libgo/mksysinfo.sh 2016-10-21 10:45:35 +0200 +++ new/libgo/mksysinfo.sh 2016-10-21 11:03:34 +0200 @@ -299,6 +299,15 @@ -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \ >> ${OUT} +# AIX: The _arpcom struct, removed by previous "grep -v 'in6_addr'" +grep '^type _arpcom ' gen-sysinfo.go | \ + sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \ + -e 's/_in6_addr/[16]byte/' \ + >> ${OUT} + # The errno constants. These get type Errno. echo '#include <errno.h>' | ${CC} -x c - -E -dM | \ egrep '#define E[A-Z0-9_]+ ' | \