Skip to content

gccgo: fix NetBSD support #38538

Closed
Closed
@bsiegert

Description

@bsiegert

What version of Go are you using (go version)?

gcc-9.3.0 with --enable-languages=c,c++,go

Does this issue reproduce with the latest release?

gcc HEAD from git has the same issue.

What operating system and processor architecture are you using (go env)?

NetBSD 9.0 / amd64

What did you do?

I tried to compile gccgo using the GCC 9.3.0 release. NetBSD is nominally supported by gccgo. I did this using the OS packaging setup:

$ cd /usr/pkgsrc/lang/gcc9
$ make package-install PKG_OPTIONS.gcc9="-gcc-objc -gcc-objc++ -nls gcc-go"

What did you expect to see?

I expected a working gccgo compiler.

What did you see instead?

Compilation fails when compiling the runtime package. I have a candidate CL (against gcc HEAD) to fix this, but now there are a lot of errors when compiling the syscall package:

libtool: compile:  /usr/pkgsrc/lang/gcc9/work/build/./gcc/gccgo -B/usr/pkgsrc/lang/gcc9/work/build/./gcc/ -B/usr/pkg/gcc9/x86_64--net
bsd/bin/ -B/usr/pkg/gcc9/x86_64--netbsd/lib/ -isystem /usr/pkg/gcc9/x86_64--netbsd/include -isystem /usr/pkg/gcc9/x86_64--netbsd/sys-
include -fchecking=1 -minline-all-stringops -O2 -g -I . -c -fgo-pkgpath=syscall ../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go ../../
../gcc-9.3.0/libgo/go/syscall/dirent.go ../../../gcc-9.3.0/libgo/go/syscall/endian_little.go ../../../gcc-9.3.0/libgo/go/syscall/env_
unix.go ../../../gcc-9.3.0/libgo/go/syscall/errstr.go ../../../gcc-9.3.0/libgo/go/syscall/exec_bsd.go ../../../gcc-9.3.0/libgo/go/sys
call/exec_unix.go ../../../gcc-9.3.0/libgo/go/syscall/forkpipe2.go ../../../gcc-9.3.0/libgo/go/syscall/libcall_bsd.go ../../../gcc-9.
3.0/libgo/go/syscall/libcall_bsd_regfile.go ../../../gcc-9.3.0/libgo/go/syscall/libcall_posix.go ../../../gcc-9.3.0/libgo/go/syscall/
libcall_posix_nonhurd.go ../../../gcc-9.3.0/libgo/go/syscall/libcall_posix_regfile.go ../../../gcc-9.3.0/libgo/go/syscall/libcall_pos
ix_utimesnano.go ../../../gcc-9.3.0/libgo/go/syscall/libcall_support.go ../../../gcc-9.3.0/libgo/go/syscall/libcall_uname.go ../../..
/gcc-9.3.0/libgo/go/syscall/libcall_wait4.go ../../../gcc-9.3.0/libgo/go/syscall/msan0.go ../../../gcc-9.3.0/libgo/go/syscall/net.go
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go ../../../gcc-9.3.0/libgo/go/syscall/route_netbsd.go ../../../gcc-9.3.0/libgo/go/sysc
all/sleep_select.go ../../../gcc-9.3.0/libgo/go/syscall/sockcmsg_unix.go ../../../gcc-9.3.0/libgo/go/syscall/socket.go ../../../gcc-9
.3.0/libgo/go/syscall/socket_bsd.go ../../../gcc-9.3.0/libgo/go/syscall/socket_posix.go ../../../gcc-9.3.0/libgo/go/syscall/str.go ..
/../../gcc-9.3.0/libgo/go/syscall/syscall.go ../../../gcc-9.3.0/libgo/go/syscall/syscall_errno.go ../../../gcc-9.3.0/libgo/go/syscall
/syscall_funcs.go ../../../gcc-9.3.0/libgo/go/syscall/syscall_netbsd.go ../../../gcc-9.3.0/libgo/go/syscall/syscall_unix.go ../../../
gcc-9.3.0/libgo/go/syscall/timestruct.go libcalls.go sysinfo.go syscall_arch.go  -fPIC -o .libs/syscall.o                           
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:16:28: error: use of undefined type 'BpfInsn'     
   16 | func BpfStmt(code, k int) *BpfInsn {                                                                                        
      |                            ^                                                                  
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:16:28: error: use of undefined type 'BpfInsn'                                  
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:28:47: error: reference to undefined name 'BIOCGBLEN'
   28 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCGBLEN, uintptr(unsafe.Pointer(&l)))                                      
      |                                               ^                                                                         
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:37:47: error: reference to undefined name 'BIOCSBLEN'
   37 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCSBLEN, uintptr(unsafe.Pointer(&l)))                                       
      |                                               ^                                            
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:47:47: error: reference to undefined name 'BIOCGDLT'
   47 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCGDLT, uintptr(unsafe.Pointer(&t)))                                       
      |                                               ^                                                         
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:56:47: error: reference to undefined name 'BIOCSDLT'
   56 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCSDLT, uintptr(unsafe.Pointer(&t)))
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:65:47: error: reference to undefined name 'BIOCPROMISC'
   65 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCPROMISC, uintptr(unsafe.Pointer(&m)))
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:74:47: error: reference to undefined name 'BIOCFLUSH'
   74 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCFLUSH, 0)
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:89:47: error: reference to undefined name 'BIOCGETIF'
   89 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCGETIF, uintptr(unsafe.Pointer(&iv)))
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:100:47: error: reference to undefined name 'BIOCSETIF'
  100 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCSETIF, uintptr(unsafe.Pointer(&iv)))
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:110:47: error: reference to undefined name 'BIOCGRTIMEOUT'
  110 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCGRTIMEOUT, uintptr(unsafe.Pointer(&tv)))
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:119:47: error: reference to undefined name 'BIOCSRTIMEOUT'
  119 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCSRTIMEOUT, uintptr(unsafe.Pointer(tv)))
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:129:47: error: reference to undefined name 'BIOCGSTATS'
  129 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCGSTATS, uintptr(unsafe.Pointer(&s)))
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:138:47: error: reference to undefined name 'BIOCIMMEDIATE'
  138 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCIMMEDIATE, uintptr(unsafe.Pointer(&m)))
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:147:8: error: use of undefined type 'BpfProgram'
  147 |  var p BpfProgram
      |        ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:148:3: error: reference to field 'Len' in object which has no fields or methods
  148 |  p.Len = uint32(len(i))
      |   ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:149:3: error: reference to field 'Insns' in object which has no fields or methods
  149 |  p.Insns = (*BpfInsn)(unsafe.Pointer(&i[0]))
      |   ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:149:14: error: reference to undefined name 'BpfInsn'
  149 |  p.Insns = (*BpfInsn)(unsafe.Pointer(&i[0]))
      |              ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:149:13: error: expected pointer
  149 |  p.Insns = (*BpfInsn)(unsafe.Pointer(&i[0]))
      |             ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:150:47: error: reference to undefined name 'BIOCSETF'
  150 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCSETF, uintptr(unsafe.Pointer(&p)))
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:160:47: error: reference to undefined name 'BIOCVERSION'
  160 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCVERSION, uintptr(unsafe.Pointer(&v)))
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:159:8: error: use of undefined type 'BpfVersion'
  159 |  var v BpfVersion
      |        ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:164:6: error: reference to field 'Major' in object which has no fields or methods
  164 |  if v.Major != BPF_MAJOR_VERSION || v.Minor != BPF_MINOR_VERSION {
      |      ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:164:16: error: reference to undefined name 'BPF_MAJOR_VERSION'
  164 |  if v.Major != BPF_MAJOR_VERSION || v.Minor != BPF_MINOR_VERSION { 
      |                ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:164:38: error: reference to field 'Minor' in object which has no fields or methods
  164 |  if v.Major != BPF_MAJOR_VERSION || v.Minor != BPF_MINOR_VERSION { 
      |                                      ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:164:48: error: reference to undefined name 'BPF_MINOR_VERSION'
  164 |  if v.Major != BPF_MAJOR_VERSION || v.Minor != BPF_MINOR_VERSION { 
      |                                                ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:173:47: error: reference to undefined name 'BIOCGHDRCMPLT'
  173 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCGHDRCMPLT, uintptr(unsafe.Pointer(&f)))
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:182:47: error: reference to undefined name 'BIOCSHDRCMPLT'
  182 |  _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCSHDRCMPLT, uintptr(unsafe.Pointer(&f)))
      |                                               ^
../../../gcc-9.3.0/libgo/go/syscall/exec_bsd.go:85:10: error: reference to undefined name 'raw_ptrace'
   85 |   err1 = raw_ptrace(_PTRACE_TRACEME, 0, nil, nil)
      |          ^
../../../gcc-9.3.0/libgo/go/syscall/forkpipe2.go:10:9: error: reference to undefined name 'Pipe2'
   10 |  return Pipe2(p, O_CLOEXEC)
      |         ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:40:10: error: incompatible type for return value 1 (cannot use type uintptr as type
int)
   40 |   return salign
      |          ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:54:11: error: reference to undefined name 'RawSockaddrDatalink'
   54 |  rsa := (*RawSockaddrDatalink)(unsafe.Pointer(&b[0]))
      |           ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:54:10: error: expected pointer
   54 |  rsa := (*RawSockaddrDatalink)(unsafe.Pointer(&b[0]))
      |          ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:46:36: error: use of undefined type 'SockaddrDatalink'
   46 | func parseSockaddrLink(b []byte) (*SockaddrDatalink, error) { 
      |                                    ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:55:4: error: reference to field 'Len' in object which has no fields or methods
   55 |  sa.Len = rsa.Len
      |    ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:56:4: error: reference to field 'Family' in object which has no fields or methods
   56 |  sa.Family = rsa.Family
      |    ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:57:4: error: reference to field 'Index' in object which has no fields or methods
   57 |  sa.Index = rsa.Index
      |    ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:46:36: error: use of undefined type 'SockaddrDatalink'
   46 | func parseSockaddrLink(b []byte) (*SockaddrDatalink, error) { 
      |                                    ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:182:18: error: reference to undefined name 'CTL_NET'
  182 |  mib := []_C_int{CTL_NET, AF_ROUTE, 0, 0, _C_int(facility), _C_int(param)}
      |                  ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:185:12: error: reference to undefined name 'sysctl'
  185 |  if err := sysctl(mib, nil, &n, nil, 0); err != nil {
      |            ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:192:12: error: reference to undefined name 'sysctl'
  192 |  if err := sysctl(mib, &tab[0], &n, nil, 0); err != nil {
      |            ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:218:9: error: use of undefined type 'RtMsghdr'
  218 |  Header RtMsghdr
      |         ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:227:14: error: reference to field 'Addrs' in object which has no fields or methods
  227 |   if m.Header.Addrs&(1<<i) == 0 {
      |              ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:264:9: error: use of undefined type 'IfMsghdr'
  264 |  Header IfMsghdr
      |         ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:270:13: error: reference to field 'Addrs' in object which has no fields or methods
  270 |  if m.Header.Addrs&RTA_IFP == 0 {
      |             ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:286:9: error: use of undefined type 'IfaMsghdr'
  286 |  Header IfaMsghdr
      |         ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:295:14: error: reference to field 'Addrs' in object which has no fields or methods
  295 |   if m.Header.Addrs&(1<<i) == 0 {
      |              ^
../../../gcc-9.3.0/libgo/go/syscall/route_netbsd.go:11:95: error: reference to undefined name 'RTM_RESOLVE'
   11 |  case RTM_ADD, RTM_DELETE, RTM_CHANGE, RTM_GET, RTM_LOSING, RTM_REDIRECT, RTM_MISS, RTM_LOCK, RTM_RESOLVE:
      |                                                                                               ^
../../../gcc-9.3.0/libgo/go/syscall/route_netbsd.go:14:11: error: reference to field 'Addrs' in object which has no fields or methods
   14 |   p.Header.Addrs &= RTA_DST | RTA_GATEWAY | RTA_NETMASK | RTA_GENMASK | RTA_IFA | RTA_IFP | RTA_BRD | RTA_AUTHOR
      |           ^
../../../gcc-9.3.0/libgo/go/syscall/route_netbsd.go:15:50: error: reference to undefined name 'SizeofRtMsghdr'
   15 |   return &RouteMessage{Header: p.Header, Data: b[SizeofRtMsghdr:any.Msglen]}
      |                                                  ^
../../../gcc-9.3.0/libgo/go/syscall/route_netbsd.go:18:54: error: reference to undefined name 'SizeofIfMsghdr'
   18 |   return &InterfaceMessage{Header: p.Header, Data: b[SizeofIfMsghdr:any.Msglen]} 
      |                                                      ^
../../../gcc-9.3.0/libgo/go/syscall/route_netbsd.go:24:58: error: reference to undefined name 'SizeofIfaMsghdr'
   24 |   return &InterfaceAddrMessage{Header: p.Header, Data: b[SizeofIfaMsghdr:any.Msglen]} 
      |                                                          ^
../../../gcc-9.3.0/libgo/go/syscall/syscall_netbsd.go:10:46: error: reference to undefined field or method 'Fileno'
   10 |  return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno))
../../../gcc-9.3.0/libgo/go/syscall/syscall_netbsd.go:10:78: error: reference to undefined field or method 'Fileno'
   10 |  return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno))
      |                                                                              ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:16:28: error: use of undefined type 'BpfInsn'
   16 | func BpfStmt(code, k int) *BpfInsn {
      |                            ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:16:28: error: use of undefined type 'BpfInsn'
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:127:25: error: use of undefined type 'BpfStat'
  127 | func BpfStats(fd int) (*BpfStat, error) {
      |                         ^
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:127:25: error: use of undefined type 'BpfStat'
../../../gcc-9.3.0/libgo/go/syscall/bpf_bsd.go:16:28: error: use of undefined type 'BpfInsn'
   16 | func BpfStmt(code, k int) *BpfInsn {
      |                            ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:46:36: error: use of undefined type 'SockaddrDatalink'
   46 | func parseSockaddrLink(b []byte) (*SockaddrDatalink, error) { 
      |                                    ^
../../../gcc-9.3.0/libgo/go/syscall/route_netbsd.go:34:9: error: use of undefined type 'IfAnnounceMsghdr'
   34 |  Header IfAnnounceMsghdr
      |         ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:227:23: error: invalid context-determined non-integer type for left operand of shift
  227 |   if m.Header.Addrs&(1<<i) == 0 {
      |                       ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:295:23: error: invalid context-determined non-integer type for left operand of shift
  295 |   if m.Header.Addrs&(1<<i) == 0 {
      |                       ^
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:42:16: error: incompatible types in binary expression
   42 |  return (salen + salign - 1) & ^(salign - 1)
      |                ^ 
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:237:11: error: incompatible types in assignment (type has no methods)
  237 |    sas[i] = sa
      |           ^ 
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:277:16: error: incompatible types in assignment (type has no methods)
  277 |  sas[RTAX_IFP] = sa
      |                ^ 
../../../gcc-9.3.0/libgo/go/syscall/route_bsd.go:305:11: error: incompatible types in assignment (type has no methods)
  305 |    sas[i] = sa
      |           ^ 
gmake[4]: *** [Makefile:2838: syscall.lo] Error 1

As far as I can tell, there are no z* files per os in the syscall package. I would appreciate a hint about where these missing definitions are supposed to come from.

/cc @ianlancetaylor @tklauser

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions