Title: Statically linked `sqlite3` fails checks due to missing `-lm` · Issue #128321 · python/cpython · GitHub
Open Graph Title: Statically linked `sqlite3` fails checks due to missing `-lm` · Issue #128321 · python/cpython
X Title: Statically linked `sqlite3` fails checks due to missing `-lm` · Issue #128321 · python/cpython
Description: Bug report Bug description: On Linux, if I build a static version of sqlite3 (e.g., ./configure --disable-shared && make from a sqlite3 tarball) You can see that ./configure for CPython fails the SQLite checks (added back in #30016): $ ....
Open Graph Description: Bug report Bug description: On Linux, if I build a static version of sqlite3 (e.g., ./configure --disable-shared && make from a sqlite3 tarball) You can see that ./configure for CPython fails the S...
X Description: Bug report Bug description: On Linux, if I build a static version of sqlite3 (e.g., ./configure --disable-shared && make from a sqlite3 tarball) You can see that ./configure for CPython fai...
Opengraph URL: https://github.com/python/cpython/issues/128321
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Statically linked `sqlite3` fails checks due to missing `-lm`","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nOn Linux, if I build a static version of sqlite3 (e.g., `./configure --disable-shared \u0026\u0026 make` from a sqlite3 tarball)\r\n\r\nYou can see that `./configure` for CPython fails the SQLite checks (added back in https://github.com/python/cpython/pull/30016):\r\n\r\n```\r\n$ ./configure 2\u003e\u00261 | grep sqlite\r\nchecking for sqlite3 \u003e= 3.15.2... yes\r\nchecking for sqlite3.h... yes\r\nchecking for sqlite3_bind_double in -lsqlite3... no\r\nchecking for sqlite3_column_decltype in -lsqlite3... no\r\nchecking for sqlite3_column_double in -lsqlite3... no\r\nchecking for sqlite3_complete in -lsqlite3... no\r\nchecking for sqlite3_progress_handler in -lsqlite3... no\r\nchecking for sqlite3_result_double in -lsqlite3... no\r\nchecking for sqlite3_set_authorizer in -lsqlite3... no\r\nchecking for sqlite3_trace_v2 in -lsqlite3... no\r\nchecking for sqlite3_trace in -lsqlite3... no\r\nchecking for sqlite3_value_double in -lsqlite3... no\r\nchecking for sqlite3_load_extension in -lsqlite3... no\r\nchecking for sqlite3_serialize in -lsqlite3... no\r\nchecking for --enable-loadable-sqlite-extensions... no\r\n```\r\n\r\nAnd in the `config.log` there are a bunch of failures due to undefined references to functions in libm, e.g.:\r\n\r\n```\r\nconfigure:15469: checking for sqlite3_bind_double in -lsqlite3\r\nconfigure:15492: gcc -o conftest -I/usr/local/include -I$(srcdir)/Modules/_sqlite -L/usr/local/lib -lsqlite3 -L/usr/local/lib conftest.c -lsqlite3 -L/usr/local/lib -lsqlite3 -ldl \u003e\u00265\r\n/usr/bin/ld: /usr/local/lib/libsqlite3.a(sqlite3.o): in function `logFunc':\r\n/repo/sqlite-autoconf-3470100/sqlite3.c:131765:(.text+0x26858): undefined reference to `log2'\r\n/usr/bin/ld: /repo/sqlite-autoconf-3470100/sqlite3.c:131768:(.text+0x268d4): undefined reference to `log'\r\n/usr/bin/ld: /repo/sqlite-autoconf-3470100/sqlite3.c:131762:(.text+0x268ec): undefined reference to `log10'\r\n/usr/bin/ld: /repo/sqlite-autoconf-3470100/sqlite3.c:131750:(.text+0x2691c): undefined reference to `log'\r\n```\r\n\r\nCPython is determing SQLite's requirements via `pkg-config` if it can at:\r\n\r\nhttps://github.com/python/cpython/blob/492b224b991cd9027f1bc6d9988d01e94f764992/configure.ac#L4204-L4209\r\n\r\nAnd `-lm` is included in the `pkg-config` for the static sqlite3 build, but it's in the private libs and requires the `--static` flag to be included in the `--libs` output:\r\n\r\n```\r\n$ pkg-config --static --libs sqlite3 \r\n-L/usr/local/lib -lsqlite3 -lm \r\n$ pkg-config --libs sqlite3 \r\n-L/usr/local/lib -lsqlite3 \r\n```\r\n\r\nHowever, `PKG_CHECK_MODULES` doesn't pass this flag. There's a `PKG_CHECK_MODULES_STATIC` macro which does, but CPython doesn't seem to use this yet. The alternative is set the flag manually at configure time:\r\n\r\n```\r\nPKG_CONFIG=\"$PKG_CONFIG --static\"\r\n```\r\n\r\nwhich changes all the `PKG_CHECK_MODULES` calls to include the `--static` flag. However, there's a missing export for `LIBS` which prevents this from resolving the issue:\r\n\r\n```\r\n$ git rev-parse HEAD\r\nf9a5a3a3ef34e63dc197156e9a5f57842859ca04\r\n$ export PKG_CONFIG=\"pkg-config --static\"\r\n$ ./configure 2\u003e\u00261 | grep sqlite\r\nchecking for sqlite3 \u003e= 3.15.2... yes\r\nchecking for sqlite3.h... yes\r\nchecking for sqlite3_bind_double in -lsqlite3... no\r\nchecking for sqlite3_column_decltype in -lsqlite3... no\r\nchecking for sqlite3_column_double in -lsqlite3... no\r\nchecking for sqlite3_complete in -lsqlite3... no\r\nchecking for sqlite3_progress_handler in -lsqlite3... no\r\nchecking for sqlite3_result_double in -lsqlite3... no\r\nchecking for sqlite3_set_authorizer in -lsqlite3... no\r\nchecking for sqlite3_trace_v2 in -lsqlite3... no\r\nchecking for sqlite3_trace in -lsqlite3... no\r\nchecking for sqlite3_value_double in -lsqlite3... no\r\nchecking for sqlite3_load_extension in -lsqlite3... no\r\nchecking for sqlite3_serialize in -lsqlite3... no\r\nchecking for --enable-loadable-sqlite-extensions... no\r\nchecking for stdlib extension module _sqlite3... missing\r\n^C\r\n```\r\n\r\nThis is \"solved\" with the patch:\r\n\r\n```diff\r\ndiff --git a/configure.ac b/configure.ac\r\nindex badb19d5589..5ed147f5482 100644\r\n--- a/configure.ac\r\n+++ b/configure.ac\r\n@@ -4221,6 +4221,7 @@ dnl bpo-45774/GH-29507: The CPP check in AC_CHECK_HEADER can fail on FreeBSD,\r\n dnl hence CPPFLAGS instead of CFLAGS.\r\n CPPFLAGS=\"$CPPFLAGS $LIBSQLITE3_CFLAGS\"\r\n LDFLAGS=\"$LIBSQLITE3_LIBS $LDFLAGS\"\r\n+ LIBS=\"$LIBSQLITE3_LIBS $LIBS\"\r\n \r\n AC_CHECK_HEADER([sqlite3.h], [\r\n have_sqlite3=yes\r\n```\r\n\r\nAs demonstrated by:\r\n\r\n```\r\n$ export PKG_CONFIG=\"pkg-config --static\"\r\n$ ./configure 2\u003e\u00261 | grep sqlite\r\nchecking for sqlite3 \u003e= 3.15.2... yes\r\nchecking for sqlite3.h... yes\r\nchecking for sqlite3_bind_double in -lsqlite3... yes\r\nchecking for sqlite3_column_decltype in -lsqlite3... yes\r\nchecking for sqlite3_column_double in -lsqlite3... yes\r\nchecking for sqlite3_complete in -lsqlite3... yes\r\nchecking for sqlite3_progress_handler in -lsqlite3... yes\r\nchecking for sqlite3_result_double in -lsqlite3... yes\r\nchecking for sqlite3_set_authorizer in -lsqlite3... yes\r\nchecking for sqlite3_trace_v2 in -lsqlite3... yes\r\nchecking for sqlite3_value_double in -lsqlite3... yes\r\nchecking for sqlite3_load_extension in -lsqlite3... yes\r\nchecking for sqlite3_serialize in -lsqlite3... yes\r\nchecking for --enable-loadable-sqlite-extensions... no\r\n```\r\n\r\nFor context, this was reported in https://github.com/astral-sh/python-build-standalone/issues/449 and some of the findings here are repeated there.\r\n\r\nI've posted the patch in https://github.com/python/cpython/pull/128322\r\n\r\n### CPython versions tested on:\r\n\r\nCPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-128322\r\n* gh-128355\n* gh-128356\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/zanieb","@type":"Person","name":"zanieb"},"datePublished":"2024-12-29T02:58:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/128321/cpython/issues/128321"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5cd6c077-6ced-8f49-6a65-db810f3da957 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C07C:1B7E6F:1A49C3E:2432F4E:696AA604 |
| html-safe-nonce | a70d998bceacd17b989fc183e9c1030e50c234960ab202227070a7b17b874780 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDdDOjFCN0U2RjoxQTQ5QzNFOjI0MzJGNEU6Njk2QUE2MDQiLCJ2aXNpdG9yX2lkIjoiMzgwODc3NzM2MDYzODY0OTg2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a4258d56379b20ebe74c8073bfccba84261993da39c20ce6910a3df1d01079c3 |
| hovercard-subject-tag | issue:2762081552 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/128321/issue_layout |
| twitter:image | https://opengraph.githubassets.com/687a62926e8e4e504550c9f7d5c8f37c67bfd0577986a14254e5dfa6ff2bd9a8/python/cpython/issues/128321 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/687a62926e8e4e504550c9f7d5c8f37c67bfd0577986a14254e5dfa6ff2bd9a8/python/cpython/issues/128321 |
| og:image:alt | Bug report Bug description: On Linux, if I build a static version of sqlite3 (e.g., ./configure --disable-shared && make from a sqlite3 tarball) You can see that ./configure for CPython fails the S... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zanieb |
| hostname | github.com |
| expected-hostname | github.com |
| None | a51f97dbb9326f71c08ecb61577457d543c602124d1a2672871258ef37ac5261 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4bd0eac606c70914085176ef312ebdcd97a8cdf1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width