Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccgo: fix NetBSD support #38538

Open
bsiegert opened this issue Apr 20, 2020 · 7 comments
Open

gccgo: fix NetBSD support #38538

bsiegert opened this issue Apr 20, 2020 · 7 comments
Labels
Milestone

Comments

@bsiegert
Copy link
Contributor

@bsiegert bsiegert commented Apr 20, 2020

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

@gopherbot gopherbot added this to the Gccgo milestone Apr 20, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Apr 20, 2020

Change https://golang.org/cl/228918 mentions this issue: gccgo: fix runtime compilation on NetBSD

@andybons andybons added the NeedsFix label Apr 20, 2020
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Apr 20, 2020
This fixes the build of the "runtime" package, now the compilation is
stuck in the "syscall" package instead.

Submitted upstream as https://go-review.googlesource.com/c/gofrontend/+/228918/.
Upstream bug report at golang/go#38538.
gopherbot pushed a commit to golang/gofrontend that referenced this issue Apr 21, 2020
si_code in siginfo_t is a macro on NetBSD, not a member of the
struct itself, so add a C trampoline for receiving its value.

Also replace references to mos.waitsemacount with the replacement and
add some helpers from os_netbsd.go in the GC repository.

Update golang/go#38538.

Change-Id: I818069de3eea8f3d33479542a798c729c9efd042
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/228918
Reviewed-by: Ian Lance Taylor <iant@golang.org>
kraj pushed a commit to kraj/gcc that referenced this issue Apr 21, 2020
si_code in siginfo_t is a macro on NetBSD, not a member of the
struct itself, so add a C trampoline for receiving its value.

Also replace references to mos.waitsemacount with the replacement and
add some helpers from os_netbsd.go in the GC repository.

Update golang/go#38538.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/228918
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 22, 2020

Sorry for the slow reply. The missing definitions are supposed to come from the mksysinfo.sh script. Make sure that sysinfo.c #include's any required header files, and that mksysinfo.sh exposes any constants or types that the Go code requires.

@benesch
Copy link
Contributor

@benesch benesch commented Oct 8, 2020

I'm going to look into this, as it seems like a useful step towards Darwin support.

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 10, 2020

Change https://golang.org/cl/261137 mentions this issue: libgo: fix compilation on netbsd

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 13, 2020

Change https://golang.org/cl/261739 mentions this issue: libgo: export NetBSD-specific types in mksysinfo.sh

gopherbot pushed a commit to golang/gofrontend that referenced this issue Oct 14, 2020
The syscall package depends on many NetBSD-specific types on NetBSD.
Teach mksysinfo.sh to export these types.

This alone is not sufficient to get the syscall package to compile on
NetBSD, but it's a start.

Note that the IfMsgHdr type is recapitalized to IfMsghdr, which requires
changes in the AIX port. The new capitalization is what's used by
upstream in existing NetBSD-specific code and is more consistent with
the capitalization of other C structs with the "hdr" suffix.

Updates golang/go#38538.

Change-Id: I56d8d8d887b293d5a9195114cc7f7b44a5b738cb
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/261739
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Trust: Than McIntosh <thanm@google.com>
kraj pushed a commit to kraj/gcc that referenced this issue Oct 14, 2020
The syscall package depends on many NetBSD-specific types on NetBSD.
Teach mksysinfo.sh to export these types.

This alone is not sufficient to get the syscall package to compile on
NetBSD, but it's a start.

Note that the IfMsgHdr type is recapitalized to IfMsghdr, which requires
changes in the AIX port. The new capitalization is what's used by
upstream in existing NetBSD-specific code and is more consistent with
the capitalization of other C structs with the "hdr" suffix.

Updates golang/go#38538.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/261739
@bsiegert
Copy link
Contributor Author

@bsiegert bsiegert commented Oct 16, 2020

@benesch Thanks for looking into this! I tried building gccgo from gcc HEAD just now on NetBSD-9, and I still see errors in the syscall package:

libtool: compile:  /home/bsiegert/src/gcc-bis/host-x86_64-unknown-netbsd9.0/gcc/gccgo -B/home/bsiegert/src/gcc-bis/host-x86_64-unknown-netbsd9.0/gcc/ -B/usr/local/x86_64-unknown-netbsd9.0/bin/ -B/usr/local/x86_64-unknown-netbsd9.0/lib/ -isystem /usr/local/x86_64-unknown-netbsd9.0/include -isystem /usr/local/x86_64-unknown-netbsd9.0/sys-include -fchecking=1 -minline-all-stringops -O2 -g -I . -c -fgo-pkgpath=syscall ../.././libgo/go/syscall/bpf_bsd.go ../.././libgo/go/syscall/dirent.go ../.././libgo/go/syscall/endian_little.go ../.././libgo/go/syscall/env_unix.go ../.././libgo/go/syscall/errstr.go ../.././libgo/go/syscall/exec_bsd.go ../.././libgo/go/syscall/exec_unix.go ../.././libgo/go/syscall/forkpipe2.go ../.././libgo/go/syscall/libcall_bsd.go ../.././libgo/go/syscall/libcall_bsd_regfile.go ../.././libgo/go/syscall/libcall_posix.go ../.././libgo/go/syscall/libcall_posix_nonhurd.go ../.././libgo/go/syscall/libcall_posix_regfile.go ../.././libgo/go/syscall/libcall_posix_utimesnano.go ../.././libgo/go/syscall/libcall_support.go ../.././libgo/go/syscall/libcall_uname.go ../.././libgo/go/syscall/libcall_wait4.go ../.././libgo/go/syscall/msan0.go ../.././libgo/go/syscall/net.go ../.././libgo/go/syscall/route_bsd.go ../.././libgo/go/syscall/route_netbsd.go ../.././libgo/go/syscall/sleep_select.go ../.././libgo/go/syscall/sockcmsg_unix.go ../.././libgo/go/syscall/sockcmsg_unix_other.go ../.././libgo/go/syscall/socket.go ../.././libgo/go/syscall/socket_bsd.go ../.././libgo/go/syscall/socket_posix.go ../.././libgo/go/syscall/str.go ../.././libgo/go/syscall/syscall.go ../.././libgo/go/syscall/syscall_errno.go ../.././libgo/go/syscall/syscall_funcs.go ../.././libgo/go/syscall/syscall_netbsd.go ../.././libgo/go/syscall/syscall_unix.go ../.././libgo/go/syscall/time_nofake.go ../.././libgo/go/syscall/timestruct.go libcalls.go sysinfo.go syscall_arch.go  -fPIC -o .libs/syscall.o
../.././libgo/go/syscall/route_bsd.go:46:36: error: use of undefined type ‘SockaddrDatalink’
   46 | func parseSockaddrLink(b []byte) (*SockaddrDatalink, error) {
      |                                    ^
../.././libgo/go/syscall/exec_bsd.go:96:24: error: reference to undefined name ‘raw_ptrace’
   96 |                 err1 = raw_ptrace(_PTRACE_TRACEME, 0, nil, nil)
      |                        ^
../.././libgo/go/syscall/forkpipe2.go:10:16: error: reference to undefined name ‘Pipe2’
   10 |         return Pipe2(p, O_CLOEXEC)
      |                ^
../.././libgo/go/syscall/route_bsd.go:40:24: error: incompatible type for return value 1 (cannot use type uintptr as type int)
   40 |                 return salign
      |                        ^
../.././libgo/go/syscall/route_bsd.go:54:18: error: reference to undefined name ‘RawSockaddrDatalink’
   54 |         rsa := (*RawSockaddrDatalink)(unsafe.Pointer(&b[0]))
      |                  ^
../.././libgo/go/syscall/route_bsd.go:54:17: error: expected pointer
   54 |         rsa := (*RawSockaddrDatalink)(unsafe.Pointer(&b[0]))
      |                 ^
../.././libgo/go/syscall/route_bsd.go:46:36: error: use of undefined type ‘SockaddrDatalink’
   46 | func parseSockaddrLink(b []byte) (*SockaddrDatalink, error) {
      |                                    ^
../.././libgo/go/syscall/route_bsd.go:55:11: error: reference to field ‘Len’ in object which has no fields or methods
   55 |         sa.Len = rsa.Len
      |           ^
../.././libgo/go/syscall/route_bsd.go:56:11: error: reference to field ‘Family’ in object which has no fields or methods
   56 |         sa.Family = rsa.Family
      |           ^
../.././libgo/go/syscall/route_bsd.go:57:11: error: reference to field ‘Index’ in object which has no fields or methods
   57 |         sa.Index = rsa.Index
      |           ^
../.././libgo/go/syscall/route_bsd.go:88:33: error: reference to undefined name ‘Type’
   88 |         sa := &SockaddrDatalink{Type: lla.Type, Nlen: lla.Nlen, Alen: lla.Alen, Slen: lla.Slen}
      |                                 ^
../.././libgo/go/syscall/route_bsd.go:88:49: error: reference to undefined name ‘Nlen’
   88 |         sa := &SockaddrDatalink{Type: lla.Type, Nlen: lla.Nlen, Alen: lla.Alen, Slen: lla.Slen}
      |                                                 ^
../.././libgo/go/syscall/route_bsd.go:88:65: error: reference to undefined name ‘Alen’
   88 |         sa := &SockaddrDatalink{Type: lla.Type, Nlen: lla.Nlen, Alen: lla.Alen, Slen: lla.Slen}
      |                                                                 ^
../.././libgo/go/syscall/route_bsd.go:88:81: error: reference to undefined name ‘Slen’
   88 |         sa := &SockaddrDatalink{Type: lla.Type, Nlen: lla.Nlen, Alen: lla.Alen, Slen: lla.Slen}
      |                                                                                 ^
../.././libgo/go/syscall/route_bsd.go:185:19: error: reference to undefined name ‘sysctl’
  185 |         if err := sysctl(mib, nil, &n, nil, 0); err != nil {
      |                   ^
../.././libgo/go/syscall/route_bsd.go:192:19: error: reference to undefined name ‘sysctl’
  192 |         if err := sysctl(mib, &tab[0], &n, nil, 0); err != nil {
      |                   ^
../.././libgo/go/syscall/route_netbsd.go:11:102: 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:
      |                                                                                                      ^
../.././libgo/go/syscall/route_bsd.go:46:36: error: use of undefined type ‘SockaddrDatalink’
   46 | func parseSockaddrLink(b []byte) (*SockaddrDatalink, error) {
      |                                    ^
../.././libgo/go/syscall/route_bsd.go:42:23: error: incompatible types in binary expression
   42 |         return (salen + salign - 1) & ^(salign - 1)
      |                       ^
../.././libgo/go/syscall/route_bsd.go:237:32: error: incompatible types in assignment (type has no methods)
  237 |                         sas[i] = sa
      |                                ^
../.././libgo/go/syscall/route_bsd.go:277:23: error: incompatible types in assignment (type has no methods)
  277 |         sas[RTAX_IFP] = sa
      |                       ^
../.././libgo/go/syscall/route_bsd.go:305:32: error: incompatible types in assignment (type has no methods)
  305 |                         sas[i] = sa
      |                                ^
gmake[4]: *** [Makefile:2910: syscall.lo] Error 1
@benesch
Copy link
Contributor

@benesch benesch commented Oct 16, 2020

gopherbot pushed a commit to golang/gofrontend that referenced this issue Oct 21, 2020
Import some missing upstream code for BSD sockets and sysctls and
adapt it for gccgo.

Updates golang/go#38538.

Change-Id: I3b08bf01b499b5be55ef79b4633f47ba266d0148
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/261137
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Benny Siegert <bsiegert@gmail.com>
jpf91 pushed a commit to D-Programming-GDC/gcc that referenced this issue Oct 22, 2020
Import some missing upstream code for BSD sockets and sysctls and
adapt it for gccgo.

Updates golang/go#38538.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/261137
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.