Yubico / yubihsm-connector

https://developers.yubico.com/yubihsm-connector/
Apache License 2.0
30 stars 13 forks source link

Current yubihsm-connector fails to build #5

Closed mouse07410 closed 4 years ago

mouse07410 commented 5 years ago

MacOS Mojave 10.14.3, Xcode-10.1, Macports-installed Go go version go1.12 darwin/amd64

$ make
github.com/hashicorp/hcl/hcl/strconv
github.com/kardianos/service
github.com/magiconair/properties
github.com/mitchellh/mapstructure
github.com/spf13/afero/mem
golang.org/x/text/transform
github.com/spf13/jwalterweatherman
github.com/spf13/cast
github.com/spf13/pflag
github.com/hashicorp/hcl/hcl/token
github.com/pelletier/go-toml
golang.org/x/sys/unix
github.com/spf13/cobra
github.com/hashicorp/hcl/hcl/ast
golang.org/x/text/unicode/norm
github.com/hashicorp/hcl/json/token
github.com/hashicorp/hcl/hcl/scanner
github.com/fsnotify/fsnotify
golang.org/x/crypto/ssh/terminal
github.com/hashicorp/hcl/json/scanner
github.com/hashicorp/hcl/hcl/parser
gopkg.in/yaml.v2
github.com/hashicorp/hcl/json/parser
github.com/sirupsen/logrus
github.com/hashicorp/hcl/hcl/printer
github.com/sirupsen/logrus/hooks/syslog
github.com/hashicorp/hcl
github.com/spf13/afero
github.com/spf13/viper
cgo-gcc-prolog:194:2: warning: 'libusb_set_debug' is deprecated [-Wdeprecated-declarations]
/opt/local/include/libusb-1.0/libusb.h:1299:1: note: 'libusb_set_debug' has been explicitly marked deprecated here
/opt/local/include/libusb-1.0/libusb.h:89:49: note: expanded from macro 'LIBUSB_DEPRECATED_FOR'
github.com/thorduri/go-libusb/usb
golang.org/x/sys/unix.kevent: relocation target golang.org/x/sys/unix.Syscall6 not defined for ABIInternal (but is defined for ABI0)
golang.org/x/sys/unix.ioctl: relocation target golang.org/x/sys/unix.Syscall not defined for ABIInternal (but is defined for ABI0)
golang.org/x/sys/unix.Close: relocation target golang.org/x/sys/unix.Syscall not defined for ABIInternal (but is defined for ABI0)
golang.org/x/sys/unix.Kqueue: relocation target golang.org/x/sys/unix.Syscall not defined for ABIInternal (but is defined for ABI0)
golang.org/x/sys/unix.Open: relocation target golang.org/x/sys/unix.Syscall not defined for ABIInternal (but is defined for ABI0)
golang.org/x/sys/unix.mmap: relocation target golang.org/x/sys/unix.Syscall6 not defined for ABIInternal (but is defined for ABI0)
golang.org/x/sys/unix.munmap: relocation target golang.org/x/sys/unix.Syscall not defined for ABIInternal (but is defined for ABI0)
# yubihsm-connector
yubihsm-connector
FATAL: command "build" failed: exit status 2
make: *** [build] Error 1
$

Provided yubihsm-connector-2.0.0.tar.gz also fails to build in exactly the same way.

This pretty much makes YubiHSM2 useless, because it cannot be accessed without yubihsm-connector. Please address this problem ASAP.

nevun commented 5 years ago

For what it is worth, this works with homebrew:

$ git clone git@github.com:Yubico/yubihsm-connector.git
Cloning into 'yubihsm-connector'...
remote: Enumerating objects: 1314, done.
remote: Counting objects: 100% (1314/1314), done.
remote: Compressing objects: 100% (994/994), done.
remote: Total 1314 (delta 213), reused 1312 (delta 212), pack-reused 0
Receiving objects: 100% (1314/1314), 2.34 MiB | 4.17 MiB/s, done.
Resolving deltas: 100% (213/213), done.
$ cd yubihsm-connector/
$ make
github.com/hashicorp/hcl/hcl/strconv
github.com/kardianos/service
github.com/magiconair/properties
github.com/mitchellh/mapstructure
github.com/spf13/pflag
github.com/spf13/afero/mem
github.com/spf13/jwalterweatherman
github.com/spf13/cast
golang.org/x/text/transform
github.com/hashicorp/hcl/hcl/token
github.com/pelletier/go-toml
golang.org/x/sys/unix
github.com/spf13/cobra
github.com/hashicorp/hcl/hcl/ast
github.com/hashicorp/hcl/hcl/scanner
github.com/hashicorp/hcl/json/token
golang.org/x/text/unicode/norm
golang.org/x/crypto/ssh/terminal
github.com/fsnotify/fsnotify
github.com/hashicorp/hcl/hcl/parser
github.com/hashicorp/hcl/json/scanner
github.com/sirupsen/logrus
github.com/hashicorp/hcl/hcl/printer
github.com/hashicorp/hcl/json/parser
gopkg.in/yaml.v2
github.com/spf13/afero
github.com/sirupsen/logrus/hooks/syslog
github.com/hashicorp/hcl
github.com/spf13/viper
cgo-gcc-prolog:186:2: warning: 'libusb_set_debug' is deprecated [-Wdeprecated-declarations]
/usr/local/include/libusb-1.0/libusb.h:1299:1: note: 'libusb_set_debug' has been explicitly marked deprecated here
/usr/local/include/libusb-1.0/libusb.h:89:49: note: expanded from macro 'LIBUSB_DEPRECATED_FOR'
github.com/thorduri/go-libusb/usb
yubihsm-connector
$ go version
go version go1.11.5 darwin/amd64
$ sw_vers 
ProductName:    Mac OS X
ProductVersion: 10.14.3
BuildVersion:   18D109
mouse07410 commented 5 years ago

For what it is worth, this works with homebrew...

I see. But commercial product shouldn't depend on customers installing a particular package manager. Perhaps Yubico should distribute binaries, like every decent product does - sources are nice, especially when they're written in stable common languages, but in this case they hinder rather than help.

Also, note that the Homebrew compiler version is 1.11.5, while Macports has it updated to 1.12.

Again, Yubico, please fix it, or make sure you distribute binaries - as not everybody wants to mess with compiling in weird languages. This isn't a student course work, y'know...

nevun commented 5 years ago

And this macos binary does not work for you? https://developers.yubico.com/YubiHSM2/Releases/yubihsm2-sdk-2.0.0-darwin-amd64.tar.gz

mouse07410 commented 5 years ago

And this macos binary does not work for you?

Ouch! I forgot that there's an HSM2 SDK. While it does require work (shared libraries it is linked against are mostly in the wrong places - but adjusting that with install_name_tool is simple enough), it works fine. Thank you!

P.S. I still think the build problem should be fixed. ;-) P.P.S. Since I can't be sure where the problem is - I've submitted a ticket against Macports go: https://trac.macports.org/ticket/58192#ticket P.P.P.S. I've just verified that the same problem exists with the Go-1.12 from https://golang.org So the problem is either in the code it's trying to compile (no compatibility with the current Go), or in the current stable Go release.

mouse07410 commented 5 years ago

Well, after some investigation, it looks like you (actually, we) have been bitten by the "shiny new toy" syndrome. Go compiler changed last December, gb tool did not - and its developer doesn't seem to have time to update it any more, for the last year at least. So you cannot build projects with gb under the currently released stable go.

Since you're comfortable programming in Go, perhaps you can tell how to build yubihsm-connector without gb, as gb became useless for go 1.12+.

References:

mouse07410 commented 5 years ago

So, what's your plan? To stay on go-1.11.5 compiler indefinitely, until gb catches up? Or modify the code to make it build-able with go alone (not relying on gb)?

mouse07410 commented 5 years ago

@klali that's a bad remedy.

This is a good one (note: I made more changes as I needed them, but this is what's relevant):

diff --git a/Makefile b/Makefile
index 6a548e4..34d1869 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
 # yubihsm-connector

+DIR := ${CURDIR}
+
 MAKEFLAGS += -s
 MAKEFLAGS += --no-builtin-rules
 .SUFFIXES:
@@ -7,34 +9,41 @@ MAKEFLAGS += --no-builtin-rules
 all: build

 build:
-       @gb generate ${GB_GEN_FLAGS}
-       @gb build ${GB_BUILD_FLAGS}
+       gb generate ${GB_GEN_FLAGS}
+       cd src/yubihsm-connector && CGO_CFLAGS="-I/opt/local/include" CGO_LDFLAGS="-L/opt/local/lib" GOPATH="${GOPATH}:${DIR}/vendor" go build && cp yubihsm-connector ../../bin && cd ../..

 rebuild: clean build

 install: build
        install bin/yubihsm-connector /usr/local/bin

+update:
+       gb vendor update --all
+
 cert:

Never mind the /opt/local/xxxx stuff - it's to accommodate Macports (that I use) instead of Brew (that your team seems to prefer).

syntaxcase commented 4 years ago

gb is gone now, closing this. Please reopen if the issue is still there.