Bug 202504 - lang/go: golang 1.5 on FreeBSD 11
Summary: lang/go: golang 1.5 on FreeBSD 11
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Julien Laffaye
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-20 04:36 UTC by Leon Dang
Modified: 2015-09-01 22:11 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (jlaffaye)


Attachments
go-if_data.patch (7.20 KB, patch)
2015-08-26 16:01 UTC, Maciej Pasternacki
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Leon Dang 2015-08-20 04:36:13 UTC
if_data8 in types_freebsd.go is incompatible with FreeBSD-11's if.h. This results in go:net failing test and not being able to pick up available network interfaces correctly. Extra info: https://github.com/golang/go/issues/11641

ztypes_freebsd_{amd64/i386}.go need to be regenerated with:

CC=clang go tool cgo -godefs types_freebsd.go > ztypes_freebsd_amd64.go

Patch with:

--- types_freebsd.go	2015-08-19 21:29:37.683186671 -0700
+++ /opt/go-src/1.5/go/src/syscall/types_freebsd.go	2015-08-19 17:39:53.767826664 -0700
@@ -106,15 +106,16 @@
 
 // This structure is a duplicate of if_data on FreeBSD 8-STABLE.
 // See /usr/include/net/if.h.
+#undef ifi_epoch
+#undef ifi_lastchange
 struct if_data8 {
 	u_char  ifi_type;
 	u_char  ifi_physical;
 	u_char  ifi_addrlen;
 	u_char  ifi_hdrlen;
 	u_char  ifi_link_state;
-	u_char  ifi_spare_char1;
-	u_char  ifi_spare_char2;
-	u_char  ifi_datalen;
+	u_char  ifi_vhid;
+	u_short ifi_datalen;
 	u_long  ifi_mtu;
 	u_long  ifi_metric;
 	u_long  ifi_baudrate;
Comment 1 Maciej Pasternacki 2015-08-26 16:01:48 UTC
Created attachment 160383 [details]
go-if_data.patch

Attaching a proper patch against port dir based on Leon Dang's command.

It adds a conditional patch, activated only on FreeBSD 11. The files generated by `go tool cgo` are also included in the patch, as they required manual tweaking on i386. Tested on amd64 and in an i386 jail.

Test case:

$ cat > iftest.go 
package main

import "fmt"
import "net"

func main() {
        fmt.Println(net.InterfaceByName("lo0"))
}

Correct result (on patched system):

$ go run iftest.go 
&{2 16384 lo0  up|loopback|multicast} <nil>

Incorrect result:
$ go run iftest.go
<nil> route ip+net: no such network interface
Comment 2 Neel Natu freebsd_committer 2015-08-26 23:58:36 UTC
I am hitting this bug on FreeBSD/current as well.

Please fix.
Comment 3 Maciej Pasternacki 2015-09-01 17:10:25 UTC
What would need to happen for this to be merged? This issue is blocking my work, and is a blocker for Go 1.5 on -CURRENT.
Comment 4 commit-hook freebsd_committer 2015-09-01 20:41:46 UTC
A commit references this bug:

Author: jlaffaye
Date: Tue Sep  1 20:41:31 UTC 2015
New revision: 395798
URL: https://svnweb.freebsd.org/changeset/ports/395798

Log:
  Fix net package on CURRENT

  PR:		202504
  Submitted by:	Maciej Pasternacki <maciej@pasternacki.net>

Changes:
  head/lang/go/Makefile
  head/lang/go/files/struct-if_data-patch
Comment 5 Julien Laffaye freebsd_committer 2015-09-01 20:42:19 UTC
Committed, thanks!
Comment 6 Neel Natu freebsd_committer 2015-09-01 22:11:02 UTC
Thanks!