Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sqlite3-binding.c error 'pread64' undeclared here #68

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

jt-shippit
Copy link
Contributor

@jt-shippit jt-shippit commented Jun 14, 2024

Hi team,
The purpose of this PR is to resolve the following error while trying to build the Dockerfile supplied by this repo, the issue is related to the absence of certain functions (pread64, pwrite64, and off64_t) that are typically available in a glibc environment, but not in musl libc, which is used by Alpine Linux. So as a solution, I am proposing to use a distroless debian image which uses glibc and provides the necessary functions for building SQLite with the Go bindings.

42.57 # github.com/mattn/go-sqlite3
42.57 sqlite3-binding.c:38268:42: error: 'pread64' undeclared here (not in a function); did you mean 'pread'?
42.57 38268 |   { "pread64",      (sqlite3_syscall_ptr)pread64,    0  },
42.57       |                                          ^~~~~~~
42.57       |                                          pread
42.57 sqlite3-binding.c:38286:42: error: 'pwrite64' undeclared here (not in a function); did you mean 'pwrite'?
42.57 38286 |   { "pwrite64",     (sqlite3_syscall_ptr)pwrite64,   0  },
42.57       |                                          ^~~~~~~~
42.57       |                                          pwrite
42.57 sqlite3-binding.c: In function 'seekAndRead':
42.57 sqlite3-binding.c:38272:49: error: unknown type name 'off64_t'; did you mean 'off_t'?
42.57 38272 | #define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)
42.57       |                                                 ^~~~~~~
42.57 sqlite3-binding.c:41128:11: note: in expansion of macro 'osPread64'
42.57 41128 |     got = osPread64(id->h, pBuf, cnt, offset);
42.57       |           ^~~~~~~~~
42.57 sqlite3-binding.c:38272:58: error: expected ')' before 'aSyscall'
42.57 38272 | #define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)
42.57       |                   ~                                      ^~~~~~~~
42.57 sqlite3-binding.c:41128:11: note: in expansion of macro 'osPread64'
42.57 41128 |     got = osPread64(id->h, pBuf, cnt, offset);
42.57       |           ^~~~~~~~~
42.57 sqlite3-binding.c: In function 'seekAndWriteFd':
42.57 sqlite3-binding.c:38290:57: error: unknown type name 'off64_t'; did you mean 'off_t'?
42.57 38290 | #define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off64_t))\
42.57       |                                                         ^~~~~~~
42.57 sqlite3-binding.c:41257:17: note: in expansion of macro 'osPwrite64'
42.57 41257 |   do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
42.57       |                 ^~~~~~~~~~
42.57 sqlite3-binding.c:38291:21: error: expected ')' before 'aSyscall'
42.57 38291 |                     aSyscall[13].pCurrent)
42.57       |                     ^~~~~~~~
42.57 sqlite3-binding.c:41257:17: note: in expansion of macro 'osPwrite64'
42.57 41257 |   do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
42.57       |                 ^~~~~~~~~~
42.57 sqlite3-binding.c:38290:21: note: to match this '('
42.57 38290 | #define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off64_t))\
42.57       |                     ^
42.57 sqlite3-binding.c:41257:17: note: in expansion of macro 'osPwrite64'
42.57 41257 |   do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
42.57       |                 ^~~~~~~~~~
50.70 2024/06/14 03:28:26 [INFO] Cleaning up temporary folder: /tmp/buildenv_2024-06-14-0327.4282164722
50.70 2024/06/14 03:28:26 [FATAL] exit status 1

@jt-shippit jt-shippit requested a review from a team as a code owner June 14, 2024 05:10
@jt-shippit jt-shippit requested review from szkiba and removed request for a team June 14, 2024 05:10
@CLAassistant
Copy link

CLAassistant commented Jun 14, 2024

CLA assistant check
All committers have signed the CLA.

@jt-shippit
Copy link
Contributor Author

Hi @szkiba , It seems that some of the tests for 1.20.x failed, should I remove the update to 1.22 from this PR ?

@szkiba
Copy link
Contributor

szkiba commented Jun 17, 2024

Hi @szkiba , It seems that some of the tests for 1.20.x failed, should I remove the update to 1.22 from this PR ?

Yes, since it is not related to sqlite bindings....

@jt-shippit
Copy link
Contributor Author

Hi @szkiba , It seems that some of the tests for 1.20.x failed, should I remove the update to 1.22 from this PR ?

Yes, since it is not related to sqlite bindings....

Thanks for confirming. I just reverted it back to Go 1.21

Copy link
Contributor

@szkiba szkiba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

LGTM

go.mod Outdated
@@ -1,6 +1,6 @@
module github.com/grafana/xk6-sql

go 1.21
go 1.22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jt-shippit Could you explain why this is necessary? One of the workflow tests does not run successfully because of this version change...

@szkiba szkiba merged commit 4e5f020 into grafana:master Jun 18, 2024
10 checks passed
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.

3 participants