Skip to content

Conversation

assembler-0
Copy link
Owner

@assembler-0 assembler-0 commented Oct 6, 2025

Summary by CodeRabbit

  • New Features

    • Build option to choose heap implementation language (C or Rust), defaulting to Rust, with input validation.
  • Refactor

    • Centralized source aggregation for more consistent builds.
    • Streamlined build status messages.
  • Documentation

    • README and Quickstart updated to document the new heap language option and revised heap module wording.
  • Chores

    • Removed deprecated rsalloc shell command and obsolete name-mangling script.

Copy link

coderabbitai bot commented Oct 6, 2025

Walkthrough

Refactors build to centralize source lists into cmake/source.cmake, replaces boolean heap option with string VF_CONFIG_HEAP_LANG and validates it, updates CMake messaging and flags, adds C/Rust heap backend switching via macros in mm/KernelHeap.h, removes rsalloc shell command and deletes scripts/mangle.py; updates README and build flags.

Changes

Cohort / File(s) Summary
Top-level CMake update
CMakeLists.txt
Adds include(source) after include(flags), updates status messages to show VF_CONFIG_HEAP_LANG and a "CMake sources configured." message, and removes previous inline source-organization block.
CMake cache & flags
cmake/cache.cmake, cmake/flags.cmake
Replaces VF_CONFIG_HEAP_RUST (BOOL) with VF_CONFIG_HEAP_LANG (STRING) and registers allowed values (RUST, C); adds -target x86_64-unknown-none-elf to compile flags.
CMake features & source aggregation
cmake/features.cmake, cmake/source.cmake
Adds validation and mapping for VF_CONFIG_HEAP_LANG -> VF_CONFIG_HEAP_RUST/VF_CONFIG_HEAP_C with fatal error on invalid values; centralizes many grouped source lists (ASM_SOURCES, KERNEL_CORE_SOURCES, SCHED_SOURCES, MM_SOURCES, FS_SOURCES, DRIVER_SOURCES, ARCH_SOURCES, INCLUDE_SOURCES, CPP_SOURCES, C_SOURCES, OBJ_SOURCES) and conditionally appends KernelHeap.c when heap lang == C.
Documentation
README.md
Adds rustup prerequisite, documents -DVF_CONFIG_HEAP_LANG=<C/RUST> in Quickstart/CMake usage, and updates feature list to "Heap (C & Rust modules)".
Kernel shell command removal
kernel/etc/Shell.c
Removes RsAllocHandler implementation and its {"rsalloc", RsAllocHandler} command table entry, deleting the rsalloc shell command path.
Heap interface switching
mm/KernelHeap.h
Splits public API by backend: when VF_CONFIG_HEAP_C present, exposes C prototypes; when VF_CONFIG_HEAP_RUST present, includes KernelHeapRust.h/APIC.h and maps KernelHeap APIs to rust_* macros (and no-op macros for stats/tuning/validation).
Tooling removal
scripts/mangle.py
Removes the entire name-mangling script and its CLI, eliminating project-wide function mangling logic and JSON map output.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor DevEnv
  participant CMake as CMake configure
  participant Kernel as Runtime
  participant HeapAPI as mm/KernelHeap.h
  participant CHeap as KernelHeap C impl
  participant RHeap as KernelHeap Rust impl

  rect rgb(245,250,255)
  note left of CMake: User sets -DVF_CONFIG_HEAP_LANG=<C/RUST>
  DevEnv->>CMake: configure project
  CMake->>CMake: validate VF_CONFIG_HEAP_LANG (RUST/C) or fatal
  CMake->>Kernel: generate build with VF_CONFIG_HEAP_RUST or VF_CONFIG_HEAP_C
  end

  rect rgb(230,240,255)
  note over HeapAPI,Kernel: Compile-time API mapping via macros or prototypes
  Kernel->>HeapAPI: KernelMemoryAlloc(size)
  alt VF_CONFIG_HEAP_LANG == "C"
    HeapAPI->>CHeap: KernelMemoryAlloc(size)
    CHeap-->>Kernel: ptr
  else VF_CONFIG_HEAP_LANG == "RUST"
    HeapAPI->>RHeap: rust_kmalloc(size)
    RHeap-->>Kernel: ptr
  end
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Development #147 — Overlaps on Rust heap allocator integration and lapic-based flush calls; directly related to VF_CONFIG_HEAP_LANG and rust_* mappings.
  • Development #146 — Related to build-time heap selection and KernelHeap Rust/C linking and conditional KernelHeap.c inclusion.
  • Development #138 — Related CMake modularization and source organization changes (cmake/source.cmake and feature handling).

Poem

A rabbit tweaks the CMake vine,
Chooses Rust or C for heap design.
The rsalloc burrow closed its door—
New macros hop and scribble more.
Scripts leap off — the build purrs fine. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The pull request title “Development” is overly generic and does not convey any of the substantive changes being made—such as adding a C/Rust heap language option, reorganizing CMake source aggregation, or removing the mangling script—so it fails to inform reviewers about the primary intent of the changeset. Please revise the title to succinctly summarize the main change, for example “Add VF_CONFIG_HEAP_LANG option and restructure CMake source management,” so that it clearly reflects the pull request’s purpose.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Development

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b50eaea and c5c2aec.

📒 Files selected for processing (4)
  • README.md (3 hunks)
  • cmake/features.cmake (1 hunks)
  • cmake/flags.cmake (1 hunks)
  • mm/KernelHeap.h (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
mm/KernelHeap.h (1)
mm/KernelHeap.c (8)
  • KernelHeapInit (341-355)
  • KernelMemoryAlloc (357-433)
  • KernelAllocate (435-446)
  • KernelReallocate (448-478)
  • KernelFree (480-525)
  • PrintHeapStats (527-577)
  • KernelHeapFlushCaches (584-597)
  • KernelHeapTune (600-625)
🔇 Additional comments (8)
cmake/flags.cmake (1)

4-4: LGTM!

The addition of -target x86_64-unknown-none-elf explicitly specifies the bare-metal cross-compilation target, which is appropriate for a freestanding kernel. While -m64 becomes redundant, both flags coexist without conflict.

mm/KernelHeap.h (2)

8-24: LGTM!

The C backend block correctly includes necessary headers and declares all heap functions. The declarations are consistent with the implementations in mm/KernelHeap.c.


35-36: Confirm and document no-op heap macros under VF_CONFIG_HEAP_RUST.

  • PrintHeapStats (Panic.c 144/228, Shell.c 341) and KernelHeapSetValidationLevel (mm/KernelHeap.c 354, Shell.c 823–828) become empty—ensure this is intentional and note it in documentation.
  • KernelHeapTune is defined but unused—either remove or document its purpose.
README.md (3)

35-35: LGTM!

The rustup prerequisite addition is necessary for the new Rust heap backend and correctly specifies version requirements.


66-66: LGTM!

The CMake option documentation correctly describes the new heap language configuration, including the default value (RUST) and accepted values (C/RUST).


104-104: LGTM!

The feature description update accurately reflects the new dual-language heap support. The change from "Class-based" to "C & Rust modules" is more precise and informative.

cmake/features.cmake (2)

50-50: LGTM!

The grammar correction from "Have you pass" to "Did you pass" addresses the past review feedback and improves the error message clarity.


53-59: No remaining references to old VF_CONFIG_HEAP_RUST
The boolean-based VF_CONFIG_HEAP_RUST check has been fully removed from CMake files, and the new VF_CONFIG_HEAP_LANG logic is the sole validation mechanism.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
cmake/source.cmake (1)

136-141: Consider using list(APPEND) for consistency.

While functionally correct, using list(APPEND OBJ_SOURCES ...) instead of set(OBJ_SOURCES ...) would be more consistent with the conditional source addition pattern at lines 131-133 and more maintainable if OBJ_SOURCES is extended elsewhere in the future.

Apply this diff for consistency:

 if(NOT EXCLUDE_EXTRA_OBJECTS)
-    set(OBJ_SOURCES
+    list(APPEND OBJ_SOURCES
             kernel/etc/objects/splash1.o
             kernel/etc/objects/panic.o
     )
 endif()
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b539c05 and b50eaea.

📒 Files selected for processing (8)
  • CMakeLists.txt (2 hunks)
  • README.md (2 hunks)
  • cmake/cache.cmake (1 hunks)
  • cmake/features.cmake (1 hunks)
  • cmake/source.cmake (1 hunks)
  • kernel/etc/Shell.c (0 hunks)
  • mm/KernelHeap.h (2 hunks)
  • scripts/mangle.py (0 hunks)
💤 Files with no reviewable changes (2)
  • scripts/mangle.py
  • kernel/etc/Shell.c
🔇 Additional comments (6)
CMakeLists.txt (2)

18-18: Centralized source configuration looks good.
Adding include(source) keeps the top-level CMake tidy while letting the new module manage source aggregation.


59-60: Status messaging aligns with new heap configuration.
Reporting VF_CONFIG_HEAP_LANG (and confirming sources configured) gives immediate feedback that the new language-selectable heap path is active.

cmake/cache.cmake (1)

7-8: LGTM! String-based configuration is more explicit.

The refactor from boolean to string-based heap language selection is well-structured and follows the same pattern as VF_SCHEDULER. This approach is more explicit and extensible.

Verify the default value change is intentional.

The default is now "RUST". If the previous VF_CONFIG_HEAP_RUST boolean defaulted to OFF (meaning C heap), this changes the default behavior. Please confirm this is intentional for existing users.

cmake/source.cmake (3)

4-110: LGTM! Well-organized source grouping.

The source groups are logically organized by functional area (core, scheduling, memory management, filesystems, drivers, etc.) and follow CMake conventions.


112-123: LGTM! Appropriate C source aggregation.

C_SOURCES correctly aggregates C source groups while intentionally excluding ASM_SOURCES, CPP_SOURCES, and OBJ_SOURCES, which are typically handled separately in CMake build configurations.


130-134: Verify Rust heap backend configuration.

The conditional only handles the "C" case for VF_CONFIG_HEAP_LANG. Ensure that when VF_CONFIG_HEAP_LANG equals "RUST", the Rust heap implementation sources are properly configured elsewhere in the build system.

Run the following script to verify Rust heap backend handling:

Additionally, consider adding a comment explaining where the Rust heap backend is configured for better maintainability.

@assembler-0 assembler-0 merged commit 3de7bed into main Oct 7, 2025
2 checks passed
This was referenced Oct 7, 2025
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.

1 participant