Title: Undefined references to HACL symbols when statically linking Python 3.12 · Issue #131298 · python/cpython · GitHub
Open Graph Title: Undefined references to HACL symbols when statically linking Python 3.12 · Issue #131298 · python/cpython
X Title: Undefined references to HACL symbols when statically linking Python 3.12 · Issue #131298 · python/cpython
Description: Bug report Bug description: I am developing an application that uses Python 3.12's static library (libpython3.12.a). Due to some restrictions, I am required to use a package manager to install Python and cannot compile it from source. Ad...
Open Graph Description: Bug report Bug description: I am developing an application that uses Python 3.12's static library (libpython3.12.a). Due to some restrictions, I am required to use a package manager to install Pyth...
X Description: Bug report Bug description: I am developing an application that uses Python 3.12's static library (libpython3.12.a). Due to some restrictions, I am required to use a package manager to install ...
Opengraph URL: https://github.com/python/cpython/issues/131298
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Undefined references to HACL symbols when statically linking Python 3.12","articleBody":"# Bug report\n\n### Bug description:\n\nI am developing an application that uses Python 3.12's static library (libpython3.12.a). Due to some restrictions, I am required to use a package manager to install Python and cannot compile it from source. Additionally, I can't use dynamic libraries, so I must link python statically.\n\nWhen linking libpython3.12.a to my project, I encounter undefined references to HACL (HACL*) symbols, such as:\n\n```bash\n/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/libpython3.12.a(sha2module.o): in function `update_256':\n(.text.unlikely+0x9ea): undefined reference to `python_hashlib_Hacl_Hash_SHA2_update_256'\n/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/libpython3.12.a(sha2module.o): in function `SHA512Type_copy':\n(.text.unlikely+0xcd3): undefined reference to `python_hashlib_Hacl_Hash_SHA2_copy_512'\n[etc.]\n```\n\nThese symbols appear to be related to the HACL library, which is included in Python 3.12's development. However, I cannot locate the corresponding object files or static libraries for HACL in the Python installation provided by the package manager.\n\nI was previously using python3.11 - which worked flawlessly -, however the dev package has been removed from apt and other similar package managers. For this specific reason, I had to upgrade.\n\nA quick note, the command `nm -gA /usr/lib/x86_64-linux-gnu/*.a 2\u003e/dev/null | grep python_hashlib_Hacl_Hash_SHA2_update_512` shows that these symbols are shipped with the static package: `/usr/lib/x86_64-linux-gnu/libpython3.12.a:sha2module.o: U python_hashlib_Hacl_Hash_SHA2_update_512`.\n\nSteps to Reproduce:\n1. Install Python 3.12 using your system's package manager (e.g., `apt` on Ubuntu).\n2. Attempt to statically link the Python static library `libpython3.12.a` into a C/C++ project.\n3. Observe linker errors related to undefined references to HACL symbols.\n\nExpected Behavior:\nThe static library libpython3.12.a should include all necessary dependencies, including HACL, or provide a way to link against HACL statically.\n\nActual Behavior:\nThe linker fails with undefined references to HACL symbols, as the required HACL objects or static libraries are not provided.\n\nQuestions:\n1. Are the HACL object files or static libraries supposed to be included in the Python 3.12 package from the package manager?\n2. If not, is there a recommended way to obtain the necessary HACL static library for linking with libpython3.12.a? And if so, is it possible to do so without having to compile Python or any other large project?\n3. Could this be an issue with the packaging of Python 3.12 in the package manager, or is it a broader issue with the static linking setup?\n4. My primary goal is to link python statically. If there isn't any solution available that follows the requirements of using a package manager, are there any work arounds to bypass the linker issue?\n\nThank you for your assistance.\n\n### CPython versions tested on:\n\n3.12\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-132438\n* gh-133012\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/luis605","@type":"Person","name":"luis605"},"datePublished":"2025-03-15T17:56:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/131298/cpython/issues/131298"}
| 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:7d24bbc0-cddf-7e15-8e2b-1b28448e4dbe |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 81D4:BAE66:398FDA:51C657:696A4592 |
| html-safe-nonce | 5f871dfb5099de9ea4b83a6bbcf577c53c3d162d3b926c4f2f667cf1fad9aae9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MUQ0OkJBRTY2OjM5OEZEQTo1MUM2NTc6Njk2QTQ1OTIiLCJ2aXNpdG9yX2lkIjoiMjg3MDAxMjQ2NDUzMjcwMjYxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e425b5fe5e88bbc2f8ad8baa5acb24b2669b7faf249cfcd56e40e71b129cfe96 |
| hovercard-subject-tag | issue:2922384904 |
| 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/131298/issue_layout |
| twitter:image | https://opengraph.githubassets.com/17aa4b413ded04370e3cfa6063d43d9a92dbb98b4d754a37e325bf30a45634b9/python/cpython/issues/131298 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/17aa4b413ded04370e3cfa6063d43d9a92dbb98b4d754a37e325bf30a45634b9/python/cpython/issues/131298 |
| og:image:alt | Bug report Bug description: I am developing an application that uses Python 3.12's static library (libpython3.12.a). Due to some restrictions, I am required to use a package manager to install Pyth... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | luis605 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3f871c8e07f0ae1886fa8dac284166d28b09ad5bada6476fc10b674e489788ef |
| 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 | 63c426b30d262aba269ef14c40e3c817b384cd61 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width