Skip to content

Conversation

@astrieanna
Copy link
Contributor

When building the windows plugin exe's (host-local, flannel, win-overlay, win-bridge), it was necessary to use 'GOOS=windows go build path/to/plugin' rather than the build script.

This PR makes GOOS=windows GOARCH=amd64 ./build.sh build all the windows plugin binaries.

Previous Behavior

Only host-local.exe and win-bridge.exe are built, and there's an error message.

$ GOARCH=amd64 ./build.sh
Building plugins linux
  bandwidth
  flannel
  portmap
  tuning
  bridge
  host-device
  ipvlan
  loopback
  macvlan
  ptp
  vlan
  host-local.exe
  win-bridge.exe
# runtime/cgo
exec: "x86_64-w64-mingw32-gcc": executable file not found in $PATH

If you try to set GOOS, all you get are errors.

$ GOOS=windows GOARCH=amd64 ./build.sh
Building plugins windows
  bandwidth
# github.com/containernetworking/plugins/vendor/github.com/vishvananda/netns
gopath/src/github.com/containernetworking/plugins/vendor/github.com/vishvananda/netns/netns.go:27:13: undefined: syscall.Stat_t
gopath/src/github.com/containernetworking/plugins/vendor/github.com/vishvananda/netns/netns.go:28:12: undefined: syscall.Fstat
gopath/src/github.com/containernetworking/plugins/vendor/github.com/vishvananda/netns/netns.go:31:12: undefined: syscall.Fstat
gopath/src/github.com/containernetworking/plugins/vendor/github.com/vishvananda/netns/netns.go:39:8: undefined: syscall.Stat_t
gopath/src/github.com/containernetworking/plugins/vendor/github.com/vishvananda/netns/netns.go:43:12: undefined: syscall.Fstat
gopath/src/github.com/containernetworking/plugins/vendor/github.com/vishvananda/netns/netns.go:52:8: undefined: syscall.Stat_t
gopath/src/github.com/containernetworking/plugins/vendor/github.com/vishvananda/netns/netns.go:56:12: undefined: syscall.Fstat
gopath/src/github.com/containernetworking/plugins/vendor/github.com/vishvananda/netns/netns.go:70:29: cannot use int(*ns) (type int) as type syscall.Handle in argument to syscall.Close

New Behavior

Windows plugins are not build when GOOS is not specified:

GOARCH=amd64 ./build.sh
Building plugins linux
  bandwidth
  flannel
  portmap
  tuning
  bridge
  host-device
  ipvlan
  loopback
  macvlan
  ptp
  vlan
  dhcp
  host-local
  static
  sample

All windows plugins are built when GOOS=windows is specified:

$ GOOS=windows GOARCH=amd64 ./build.sh
Building plugins windows
  host-local.exe
  win-bridge.exe
  win-overlay.exe
  flannel.exe

If GOARCH is wrong, you get a specific error message:

$ GOOS=windows ./build.sh
Building plugins windows
Could not build windows plugins when GOARCH != amd64

When building the windows plugin exe's (host-local, flannel, win-overlay, win-bridge),
it was necessary to use 'GOOS=windows go build path/to/plugin' rather than the build script.

This makes 'GOOS=windows GOARCH=amd64 ./build.sh' build all the windows plugin binaries.
@rosenhouse
Copy link
Contributor

rosenhouse commented Oct 31, 2018

hey @astrieanna , thanks for this PR. sorry for the delay in responding.

We were discussing this at the maintainers meeting, and were thinking: rather than have this conditional logic inside the build script, it may be better to just split it into two different scripts: build_linux and build_windows.

What do you think?

@pjh
Copy link

pjh commented Nov 1, 2018

@astrieanna Thanks for sharing this PR! I cherry-picked it and GOOS=windows GOARCH=amd64 ./build.sh successfully built the Windows plugins for me.

Whether this PR or an alternate approach gets submitted, please add some notes in CONTRIBUTING.md explaining what command(s) to run to build the Windows plugins (see #224).

@benmoss
Copy link

benmoss commented Nov 1, 2018

@rosenhouse I just split it apart, and also updated the release.sh script so that it will publish a tarball. As part of that I wanted to call attention to the fact that I renamed the output tarballs to cni-plugins-{os}-{arch}-{version}, they previously didn't have OS as part of their names.

Hopefully you don't now want a release_linux and release_windows :)

@benmoss
Copy link

benmoss commented Nov 1, 2018

I think we can get rid of

- sudo apt-get install gcc-multilib gcc-mingw-w64 -y
now too, I don't think that we're running any Windows tests on Travis.

@dcbw
Copy link
Member

dcbw commented Nov 7, 2018

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants