8000 feat: add `lean_setup_libuv` for initializing required LIBUV components by algebraic-dev · Pull Request #8636 · leanprover/lean4 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add lean_setup_libuv for initializing required LIBUV components #8636

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

algebraic-dev
Copy link
Member

This PR adds a function called lean_setup_libuv that initializes required LIBUV components. It needs to be outside of lean_initialize_runtime_module because it requires argv and argc to work correctly.

@algebraic-dev algebraic-dev self-assigned this Jun 4, 2025
@algebraic-dev algebraic-dev added the changelog-compiler Compiler, runtime, and FFI label Jun 4, 2025
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Jun 4, 2025
@leanprover-community-bot
Copy link
Collaborator
leanprover-community-bot commented Jun 4, 2025

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e08b2a1f62238f7f817c719e4fffcfef14243338 --onto c12159b51982221bdd66f0c5997f85e1f9d91772. You can force Mathlib CI using the force-mathlib-ci label. (2025-06-04 23:23:00)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e08b2a1f62238f7f817c719e4fffcfef14243338 --onto 0a9c24649767dea857a388e5385b7ae94bfd0185. You can force Mathlib CI using the force-mathlib-ci label. (2025-06-12 16:00:12)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e08b2a1f62238f7f817c719e4fffcfef14243338 --onto db499e96aac8ad654c8ed5ab40c4e6885d38c9a1. You can force Mathlib CI using the force-mathlib-ci label. (2025-06-20 23:13:14)

@algebraic-dev algebraic-dev marked this pull request as ready for review June 5, 2025 01:38
@eric-wieser
Copy link
Contributor

This presumably makes progress on #5819 ?

@algebraic-dev
Copy link
Member Author

This presumably makes progress on #5819 ?

Not exactly, LibUV provides some functions like uv_exepath that can get the executable path but it's not exactly the same as argv[0]

Copy link
Member
@TwoFX TwoFX left a comment

Choose a reason for hiding this comment

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

FFI changes LGTM except for the documentation comments. I didn't check the compiler changes.

```c
void lean_initialize_runtime_module();
void lean_initialize();
lean_object * initialize_A_B(uint8_t builtin, lean_object *);
lean_object * initialize_C(uint8_t builtin, lean_object *);
...

lean_setup_libuv(argc, argv); // if using process-related functionality
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
lean_setup_libuv(argc, argv); // if using process-related functionality
argv = lean_setup_libuv(argc, argv); // if using process-related functionality

@@ -131,14 +131,19 @@ Thus `[init]` functions are run iff their module is imported, regardless of whet

The initializer for module `A.B` is called `initialize_A_B` and will automatically initialize any imported modules.
Module initializers are idempotent (when run with the same `builtin` flag), but not thread-safe.

**Important for process-related functionality**: If your application needs to use process-related functions from libuv, you must call `lean_setup_libuv(argc, argv)` before calling `lean_initialize()` or `lean_initialize_runtime_module()`. This ensures that libuv's process handling capabilities are properly configured with the command-line arguments, which is essential for certain system-level operations that Lean's runtime may depend on.
Copy link
Member

Choose a reason for hiding this comment

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

This needs to mention that users should replace their argv with the one returned by lean_setup_libuv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-compiler Compiler, runtime, and FFI toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0