ardnew / mcp2221a

Go module for the MCP2221A USB to I²C/UART Protocol Converter with GPIO
MIT License
17 stars 4 forks source link

Build Fails on windows #2

Open dbboyd17 opened 1 year ago

dbboyd17 commented 1 year ago

$ go build

github.com/karalabe/hid

In file included from ....\pkg\mod\github.com\karalabe\hid@v1.0.0\hid_enabled.go:40: ....\pkg\mod\github.com\karalabe\hid@v1.0.0/hidapi/windows/hid.c: In function 'hid_enumerate': ....\pkg\mod\github.com\karalabe\hid@v1.0.0/hidapi/windows/hid.c:431:5: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-overflow=] strncpy(cur_dev->path, str, len+1); ^~~~~~~~~~ ....\pkg\mod\github.com\karalabe\hid@v1.0.0/hidapi/windows/hid.c:429:11: note: length computed here len = strlen(str); ^~~

This looks to be an underlying bug in hidapi. built on go1.20.3

ardnew commented 1 year ago
Thanks @dbboyd17 for reporting this!

Immediate status

Unfortunately, I no longer have a Windows PC to recreate this issue and investigate.

And since I am not experiencing the issue on Linux or macOS (both using go1.20.3), I tentatively concur that hidapi is the culprit.

I will have Windows access again next week. so I'll report back (in this thread) once I've had a chance to debug on there.

Who should be responsible

Given that this bug is like 2 degrees separated from ~Kev...  ~ this repository:

github.com/ardnew/mcp2221a@0.1.1    (Kevin Bacon)
└── github.com/karalabe/hid@1.0.0   (Go module)
    ├── hidapi                      (C library)
    └── libusb                      (C library)

So I think it would be more appropriate to report the bug to the other maintainers; specifically to @karalabe, since they have constructed their project source repo monolithically, disconnecting these libraries from upstream development.

Workaround

Since this bug is not appearing in Linux, I would recommend trying to build from a WSL instance on Windows (until the bug is fixed):

# From a WSL shell, you'll need to install one of the Go release 
# packages for Linux. Do not try to use the Windows build you
# currently have installed.
#
# Once you've verified the Linux toolchain builds without error, 
# you can then use that to cross-compile back to Windows.
#
# For example:
% GOOS=windows GOARCH=amd64 go build ./src