Skip to content

mruby-bin-mrbc: define global_mrb for non-mruby targets#6902

Merged
matz merged 1 commit into
mruby:masterfrom
hasumikin:global_mrb-for-non-mruby-targets
Jun 22, 2026
Merged

mruby-bin-mrbc: define global_mrb for non-mruby targets#6902
matz merged 1 commit into
mruby:masterfrom
hasumikin:global_mrb-for-non-mruby-targets

Conversation

@hasumikin

@hasumikin hasumikin commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

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.

@hasumikin hasumikin requested a review from matz as a code owner June 22, 2026 06:02

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request conditionally declares or defines the global_mrb variable in mrbc.c depending on whether MRC_TARGET_MRUBY is defined. Feedback suggests defining global_mrb as a macro expanding to NULL in the #else block to avoid polluting the global symbol namespace with an unused global variable.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c
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.
@hasumikin hasumikin force-pushed the global_mrb-for-non-mruby-targets branch from 1a57d78 to d5b0bc6 Compare June 22, 2026 07:18
@matz matz merged commit 0a3adc9 into mruby:master Jun 22, 2026
7 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants