From 21078b7adab1df897da13777be86b1dc7a16ca36 Mon Sep 17 00:00:00 2001 From: Xevion Date: Mon, 29 Dec 2025 14:50:40 -0600 Subject: [PATCH] fix(emscripten): avoid Module.arguments access with ASSERTIONS enabled Skip env::args() on Emscripten builds to prevent accessing Module.arguments after runtime initialization, which causes abort with ASSERTIONS=1. --- pacman/src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pacman/src/main.rs b/pacman/src/main.rs index c0cd0ee..50c88cd 100644 --- a/pacman/src/main.rs +++ b/pacman/src/main.rs @@ -104,9 +104,14 @@ unsafe extern "C" fn main_loop_callback(_arg: *mut std::ffi::c_void) { /// This function initializes SDL, the window, the game state, and then enters /// the main game loop. pub fn main() { - // Parse command line arguments - let args: Vec = env::args().collect(); - let force_console = args.iter().any(|arg| arg == "--console" || arg == "-c"); + // Parse command line arguments (only on desktop - Emscripten ignores force_console) + #[cfg(not(target_os = "emscripten"))] + let force_console = { + let args: Vec = env::args().collect(); + args.iter().any(|arg| arg == "--console" || arg == "-c") + }; + #[cfg(target_os = "emscripten")] + let force_console = false; // On Emscripten, this connects the subscriber to the browser console platform::init_console(force_console).expect("Could not initialize console");