lean4 icon indicating copy to clipboard operation
lean4 copied to clipboard

feat: support Lake for building Lean core oleans

Open david-christiansen opened this issue 1 year ago • 6 comments

This is from a ~~pair~~triple programming session with @tydeu and @mhuisi.

It does not yet allow Lake to be used to build the Lean binaries, but it will allow Lake to be used for working interactively with the Lean source. In our preliminary experiments, this allowed updates to Init.Data.Nat to be noticed automatically when reloading downstream files, rather than requiring a full manual compiler rebuild. This will make it easier to work on the system.

As part of this change, Lake is added to stage 0. This allows Lake to function in src, which uses the stage 0 toolchain.

david-christiansen avatar Apr 12 '24 05:04 david-christiansen

The lakefile.toml will have to be generated by CMake to correctly heed LEAN_MAKE_OPTS/LEANC_OPTS/...

Kha avatar Apr 17 '24 12:04 Kha

@Kha Right now, this is just for interactive editing, not for building the binaries or shared libraries, so we do not need those options at the moment.

tydeu avatar Apr 17 '24 16:04 tydeu

Okay, I would not have expected that to be a desirable intermediate state if it forces me to redo the build in cmake whenever I want to actually run and test Lean. It also begs the question of how to opt into the current workflow when the lakefile.toml always exists.

Kha avatar Apr 17 '24 18:04 Kha

@Kha

Okay, I would not have expected that to be a desirable intermediate state if it forces me to redo the build in cmake whenever I want to actually run and test Lean.

While it does require an additional run of CMake to run/test Lean, it does not require redoing work, as Make can successfully make use of elaboration results (as there are no relevant LEAN_OPTS to standard dev builds).

tydeu avatar Apr 17 '24 18:04 tydeu

I am flummoxed by the linker errors in the CMake build of stage0 Lake. It builds successfully on my machine.

tydeu avatar May 02 '24 18:05 tydeu

Mathlib CI status (docs):

  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 092ca8530a6f272b7cb19235750479cdffab11de --onto b470eb522bfd68ca96938c23f6a1bce79da8a99f. (2024-05-03 08:38:43)
  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 092ca8530a6f272b7cb19235750479cdffab11de --onto 00cf5771f31e7de7f6ab3089cb4b9ffa606a35ed. (2024-05-03 19:35:36)
  • ✅ Mathlib branch lean-pr-testing-3886 has successfully built against this PR. (2024-06-11 02:53:48) View Log
  • ✅ Mathlib branch lean-pr-testing-3886 has successfully built against this PR. (2024-06-11 09:44:23) View Log
  • ✅ Mathlib branch lean-pr-testing-3886 has successfully built against this PR. (2024-06-13 17:26:42) View Log

I added a -DUSE_LAKE=ON CMake flag to opt into the new behavior and to fix the hard-coded path so if that looks good and the stage0 update is removed to be redone on master, I think this PR is ready to be merged.

It wasn't clear to me why the additional lakefile.tomls in the root and in tests/ are necessary, so I've removed them for now.

Kha avatar Jun 02 '24 15:06 Kha

@Kha

It wasn't clear to me why the additional lakefile.tomls in the root and in tests/ are necessary, so I've removed them for now.

They are necessary for the multiple roots of the VS Code workspace. Each root needs to have a lakefile for the server to make use of Lake at that root. Without them, Lake will not be used for Lean files in the root (outside src/) or in tests/.

tydeu avatar Jun 03 '24 12:06 tydeu

Why is that relevant? tests/ is not a Lake project, even running the full build from src/ in it does not help as it will not actually build the executables. I'd rather have it not to work at all than stop half-way to a successful build.

Kha avatar Jun 04 '24 13:06 Kha

@Kha

Why is that relevant? tests/ is not a Lake project, even running the full build from src/ in it does not help as it will not actually build the executables.

It is not for building (e.g., the executables). It is for interactively editing the tests using the modules built from src (via Lake in the server). For example, when we pair programming this at the retreat, we added a definition in Init.Data.Nat and the immediately saw the change propagate to a test file in tests.

tydeu avatar Jun 04 '24 14:06 tydeu

!bench

Kha avatar Jun 11 '24 08:06 Kha

Here are the benchmark results for commit a25f4b4cf9d4f1af5573608413a2188019cc559f. There were no significant changes against commit 287d46e1f6a7a6136c7996367a9b203d93797d00.

leanprover-bot avatar Jun 11 '24 09:06 leanprover-bot

@Kha What are you attempting to benchmark? Without the stage0 update, this PR has no practical effect.

tydeu avatar Jun 11 '24 17:06 tydeu

@tydeu The update-stage0 size increase but I noticed we don't actually have a benchmark for that :) . Do you know how much it was?

Kha avatar Jun 13 '24 11:06 Kha