Skip to content

Propagate debugger CLI config in single-file executables - #25600

Merged
Jarred-Sumner merged 1 commit into
mainfrom
jarred/compile-debugger
Dec 19, 2025
Merged

Jarred-Sumner merged 1 commit into
mainfrom
jarred/compile-debugger

Conversation

@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

What does this PR do?

How did you verify your code works?

@robobun

robobun commented Dec 19, 2025

Copy link
Copy Markdown
Collaborator
Updated 11:10 PM PT - Dec 18th, 2025

@Jarred-Sumner, your commit 166cf80 is building: #33561

@coderabbitai

coderabbitai Bot commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Runtime options wiring is added in two initialization contexts: the Run struct now captures smol, debugger, and parsed dns_result_order from ctx.runtime_options in bootStandalone; the VM initialization sets is_main_thread and updates is_smol_mode flags.

Changes

Cohort / File(s) Summary
Run struct initialization
src/bun.js.zig
Wires three runtime option fields (smol, debugger, dns_result_order) into the Run struct during bootStandalone initialization, including parsing of DNSResolver.Order
VM state updates
src/bun.js/VirtualMachine.zig
Sets is_main_thread flag and updates is_smol_mode during VM initialization on module graph load

Possibly related PRs

  • oven-sh/bun#22300: Modifies the same VirtualMachine initialization paths to disable DCE annotation emission, sharing overlapping code regions with these runtime option wiring changes.

Suggested reviewers

  • pfgithub

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description contains only template headings with no actual content filled in; both required sections lack any explanation of what the PR does or how it was verified. Fill in both sections: explain the specific runtime options being propagated (debugger, smol, dns_result_order) and describe the verification testing performed.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title describes propagating debugger CLI config in single-file executables, which aligns with the changes wiring debugger and smol fields into the Run struct, though it doesn't fully capture all changes (dns_result_order also added).

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/bun.js/VirtualMachine.zig (1)

1057-1074: Critical: Missing assignments for dns_result_order and smol options.

The dns_result_order and smol options are passed via opts but never assigned to the VM instance fields. This means these runtime options won't take effect for standalone executables.

🔎 Add missing field assignments
     if (opts.is_main_thread) {
         VMHolder.main_thread_vm = vm;
         vm.is_main_thread = true;
     }
     is_smol_mode = opts.smol;
+    vm.smol = opts.smol;
+    vm.dns_result_order = opts.dns_result_order;
     vm.global = JSGlobalObject.create(

For reference, the regular init function assigns both fields at lines 1195-1196:

vm.smol = opts.smol;
vm.dns_result_order = opts.dns_result_order;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9902039 and 166cf80.

📒 Files selected for processing (2)
  • src/bun.js.zig (1 hunks)
  • src/bun.js/VirtualMachine.zig (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.{cpp,zig}

📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)

src/**/*.{cpp,zig}: Use bun bd or bun run build:debug to build debug versions for C++ and Zig source files; creates debug build at ./build/debug/bun-debug
Run tests using bun bd test <test-file> with the debug build; never use bun test directly as it will not include your changes
Execute files using bun bd <file> <...args>; never use bun <file> directly as it will not include your changes
Enable debug logs for specific scopes using BUN_DEBUG_$(SCOPE)=1 environment variable
Code generation happens automatically as part of the build process; no manual code generation commands are required

Files:

  • src/bun.js/VirtualMachine.zig
  • src/bun.js.zig
src/**/*.zig

📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)

Use bun.Output.scoped(.${SCOPE}, .hidden) for creating debug logs in Zig code

Implement core functionality in Zig, typically in its own directory in src/

src/**/*.zig: Private fields in Zig are fully supported using the # prefix: struct { #foo: u32 };
Use decl literals in Zig for declaration initialization: const decl: Decl = .{ .binding = 0, .value = 0 };
Prefer @import at the bottom of the file (auto formatter will move them automatically)

Files:

  • src/bun.js/VirtualMachine.zig
  • src/bun.js.zig
**/*.zig

📄 CodeRabbit inference engine (.cursor/rules/zig-javascriptcore-classes.mdc)

**/*.zig: Expose generated bindings in Zig structs using pub const js = JSC.Codegen.JS<ClassName> with trait conversion methods: toJS, fromJS, and fromJSDirect
Use consistent parameter name globalObject instead of ctx in Zig constructor and method implementations
Use bun.JSError!JSValue return type for Zig methods and constructors to enable proper error handling and exception propagation
Implement resource cleanup using deinit() method that releases resources, followed by finalize() called by the GC that invokes deinit() and frees the pointer
Use JSC.markBinding(@src()) in finalize methods for debugging purposes before calling deinit()
For methods returning cached properties in Zig, declare external C++ functions using extern fn and callconv(JSC.conv) calling convention
Implement getter functions with naming pattern get<PropertyName> in Zig that accept this and globalObject parameters and return JSC.JSValue
Access JavaScript CallFrame arguments using callFrame.argument(i), check argument count with callFrame.argumentCount(), and get this with callFrame.thisValue()
For reference-counted objects, use .deref() in finalize instead of destroy() to release references to other JS objects

In Zig code, be careful with allocators and use defer for cleanup

Files:

  • src/bun.js/VirtualMachine.zig
  • src/bun.js.zig
🧠 Learnings (6)
📚 Learning: 2025-11-24T18:35:39.205Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/registering-bun-modules.mdc:0-0
Timestamp: 2025-11-24T18:35:39.205Z
Learning: Add tests for new Bun runtime functionality

Applied to files:

  • src/bun.js.zig
📚 Learning: 2025-11-24T18:36:08.558Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/zig-javascriptcore-classes.mdc:0-0
Timestamp: 2025-11-24T18:36:08.558Z
Learning: Applies to src/bun.js/bindings/generated_classes_list.zig : Include new class bindings in `src/bun.js/bindings/generated_classes_list.zig` to register them with the code generator

Applied to files:

  • src/bun.js.zig
📚 Learning: 2025-11-24T18:34:55.173Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/building-bun.mdc:0-0
Timestamp: 2025-11-24T18:34:55.173Z
Learning: Applies to src/**/*.{cpp,zig} : Use `bun bd` or `bun run build:debug` to build debug versions for C++ and Zig source files; creates debug build at `./build/debug/bun-debug`

Applied to files:

  • src/bun.js.zig
📚 Learning: 2025-10-16T02:17:35.237Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/analytics.zig:15-21
Timestamp: 2025-10-16T02:17:35.237Z
Learning: In src/analytics.zig and similar files using bun.EnvVar boolean environment variables: the new EnvVar API for boolean flags (e.g., bun.EnvVar.do_not_track.get(), bun.EnvVar.ci.get()) is designed to parse and return boolean values from environment variables, not just check for their presence. This is an intentional design change from the previous presence-based checks using bun.getenvZ().

Applied to files:

  • src/bun.js.zig
📚 Learning: 2025-10-17T20:50:58.644Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 23755
File: src/bun.js/api/bun/socket/Handlers.zig:154-159
Timestamp: 2025-10-17T20:50:58.644Z
Learning: In Bun socket configuration error messages (src/bun.js/api/bun/socket/Handlers.zig), use the user-facing JavaScript names "data" and "drain" instead of internal field names "onData" and "onWritable", as these are the names users see in the API according to SocketConfig.bindv2.ts.

Applied to files:

  • src/bun.js.zig
📚 Learning: 2025-11-24T18:37:11.466Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/js/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:37:11.466Z
Learning: Write JS builtins for Bun's Node.js compatibility and APIs, and run `bun bd` after changes

Applied to files:

  • src/bun.js.zig
🔇 Additional comments (1)
src/bun.js.zig (1)

41-43: Runtime options are properly consumed by the VM.

The wiring of smol, debugger, and dns_result_order from ctx.runtime_options is correct. In VirtualMachine.initWithModuleGraph, vm.smol and vm.dns_result_order are properly assigned at lines 1195-1196, and the debugger option is configured via vm.configureDebugger(opts.debugger) at line 1202.

VMHolder.main_thread_vm = vm;
vm.is_main_thread = true;
}
is_smol_mode = opts.smol;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Inconsistent pattern for is_smol_mode assignment.

The unconditional assignment is_smol_mode = opts.smol differs from the conditional pattern in the init function (lines 1198-1199), which only sets it when opts.smol is true. While functionally equivalent (since setting to false matches the default), consistency would improve maintainability.

🔎 Make the pattern consistent
     if (opts.is_main_thread) {
         VMHolder.main_thread_vm = vm;
         vm.is_main_thread = true;
     }
-    is_smol_mode = opts.smol;
+    if (opts.smol)
+        is_smol_mode = opts.smol;
🤖 Prompt for AI Agents
In src/bun.js/VirtualMachine.zig around line 1061, the code unconditionally
assigns is_smol_mode = opts.smol which is inconsistent with the init function
(lines 1198-1199) that only sets the flag when opts.smol is true; change the
assignment to only set is_smol_mode when opts.smol is true (e.g., guard the
assignment with an if (opts.smol) so the flag is only changed when explicitly
enabled) to match the existing pattern and maintain consistency.

@Jarred-Sumner
Jarred-Sumner merged commit e79b512 into main Dec 19, 2025
54 of 56 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the jarred/compile-debugger branch December 19, 2025 17:49
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.

2 participants