From d5b0bc63e95f920c0277cc957096428f4c775a41 Mon Sep 17 00:00:00 2001 From: HASUMI Hitoshi Date: Mon, 22 Jun 2026 14:57:36 +0900 Subject: [PATCH] mruby-bin-mrbc: define global_mrb for non-mruby targets PicoRuby builds its bootstrap mrbc without PICORB_VM_MRUBY so that the standalone compiler does not depend on mruby headers or generated presym definitions. As a result, MRC_TARGET_MRUBY is not defined and mruby-compiler does not provide global_mrb, causing mrbc to fail at link time with an undefined reference. This patch lets mrbc use NULL when MRC_TARGET_MRUBY is not defined. For normal mruby builds, the existing behavior is unchanged: mrbc declares the symbol extern and mruby-compiler's ccontext.c remains its definition. This also keeps the ownership conditions complementary and avoids both undefined and duplicate symbol errors. --- mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c index f29b4a9839..e9e48df2cc 100644 --- a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +++ b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c @@ -12,7 +12,11 @@ #include "mrc_compile.h" #include "mrc_pool.h" +#if defined(MRC_TARGET_MRUBY) extern mrb_state *global_mrb; /* defined in mruby-compiler (ccontext.c) */ +#else +#define global_mrb NULL +#endif #define RITEBIN_EXT ".mrb" #define C_EXT ".c"