mtlynch / picoshare

A minimalist, easy-to-host service for sharing images and other files
https://demo.pico.rocks
Other
2.34k stars 169 forks source link

Bump `go-sqlite3` version for musl compatibility #576

Closed hafeoz closed 5 months ago

hafeoz commented 5 months ago

An error was encountered during my attempt to build on Alpine (musl-based distribution):

# github.com/mattn/go-sqlite3
sqlite3-binding.c:34670:42: error: 'pread64' undeclared here (not in a function); did you mean 'pread'?
34670 |   { "pread64",      (sqlite3_syscall_ptr)pread64,    0  },
      |                                          ^~~~~~~
      |                                          pread
sqlite3-binding.c:34688:42: error: 'pwrite64' undeclared here (not in a function); did you mean 'pwrite'?
34688 |   { "pwrite64",     (sqlite3_syscall_ptr)pwrite64,   0  },
      |                                          ^~~~~~~~
      |                                          pwrite
sqlite3-binding.c: In function 'seekAndRead':
sqlite3-binding.c:34674:49: error: unknown type name 'off64_t'; did you mean 'off_t'?
34674 | #define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)
      |                                                 ^~~~~~~
sqlite3-binding.c:37536:11: note: in expansion of macro 'osPread64'
37536 |     got = osPread64(id->h, pBuf, cnt, offset);
      |           ^~~~~~~~~
sqlite3-binding.c:34674:58: error: expected ')' before 'aSyscall'
34674 | #define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)
      |                   ~                                      ^~~~~~~~
sqlite3-binding.c:37536:11: note: in expansion of macro 'osPread64'
37536 |     got = osPread64(id->h, pBuf, cnt, offset);
      |           ^~~~~~~~~
sqlite3-binding.c: In function 'seekAndWriteFd':
sqlite3-binding.c:34692:57: error: unknown type name 'off64_t'; did you mean 'off_t'?
34692 | #define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off64_t))\
      |                                                         ^~~~~~~
sqlite3-binding.c:37665:17: note: in expansion of macro 'osPwrite64'
37665 |   do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
      |                 ^~~~~~~~~~
sqlite3-binding.c:34693:21: error: expected ')' before 'aSyscall'
34693 |                     aSyscall[13].pCurrent)
      |                     ^~~~~~~~
sqlite3-binding.c:37665:17: note: in expansion of macro 'osPwrite64'
37665 |   do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
      |                 ^~~~~~~~~~
sqlite3-binding.c:34692:21: note: to match this '('
34692 | #define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off64_t))\
      |                     ^
sqlite3-binding.c:37665:17: note: in expansion of macro 'osPwrite64'
37665 |   do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
      |                 ^~~~~~~~~~

A quick google search points to https://github.com/mattn/go-sqlite3/issues/1164#issuecomment-1975022901. After updating go-sqlite3 version in go.mod and running go tidy I was able to compile without problem:

go.mod
7c7
<   github.com/mattn/go-sqlite3 v1.14.11
---
>   github.com/mattn/go-sqlite3 v1.14

I don't have any experience in go and I can't find any changelog for go-sqlite3, so I'm not sure if it breaks anything. The updated build works on my machine though :)

mtlynch commented 5 months ago

Thanks for reporting this! If you want to submit a PR to resolve this, I'd accept.