doc/guides/mrbconf.md
You can do the build configuration in the build configuration file. The default
configuration file is build_config/default.rb.
You can specify your own configuration file by the MRUBY_CONFIG environment
variable (you can use CONFIG for shorthand for MRUBY_CONFIG). If the path
doesn't exist, build_config/${MRUBY_CONFIG}.rb is used.
Just add the configuration value to the MRuby::Build#defines attribute.
This is the same for MRuby::CrossBuild.
# build_config.rb
MRuby::Build.new do |conf|
...
conf.defines << 'MRB_GC_FIXED_ARENA'
conf.defines << 'MRB_NO_METHOD_CACHE'
...
end
NOTE
conf.defines) instead of per-compiler definitions (e.g., conf.cc.defines) unless there is a special reason not to.include/mruby/mrbconf.h file or give it directly as a compiler flag, as was the case before.MRB_NO_STDIO
<stdio.h> functions won't be used.mrb_irep load/dump from/to file.MRB_USE_DEBUG_HOOK
code_fetch_hook and/or debug_op_hook of mrb_state.OP_DEBUG.MRB_DEBUG
mrb_assert* macro will be defined with macros from <assert.h>.enable_debug method of MRuby::Build.MRB_STACK_EXTEND_DOUBLING
MRB_STACK_GROWTH).MRB_STACK_GROWTH
128.MRB_STACK_EXTEND_DOUBLING is defined.MRB_STACK_MAX
0x40000 - MRB_STACK_GROWTH.RuntimeError when stack size exceeds this value.MRB_USE_FLOAT32
float) is used as mrb_float.double) is used as mrb_float.MRB_NO_FLOAT
MRB_INT32
MRB_INT64 are not defined on 32-bit CPU mode, mrb_int will be defined as int32_t.MRB_INT64.MRB_INT64
MRB_INT32 are not defined on 64-bit CPU mode, mrb_int will be defined as int64_t.MRB_INT32.MRB_INT64 requires MRB_NO_BOXING because heap-allocated RInteger needs 8-byte alignment that the GC heap may not guarantee with word or NaN boxing.MRB_GC_STRESS
RBasic allocation.MRB_DEBUG, full GC is emitted also per each heap allocation (mrb_malloc() or etc.).
This configuration slows down mruby execution by a factor of 2 to 3 or even more.MRB_GC_TURN_OFF_GENERATIONAL
MRB_GC_FIXED_ARENA
RuntimeError when this is defined and GC arena size exceeds MRB_GC_ARENA_SIZE.MRB_GC_ARENA_SIZE
100.MRB_GC_FIXED_ARENA isn't defined.MRB_HEAP_PAGE_SIZE
1024.RBasic per each heap page.POOL_ALIGNMENT
4.POOL_PAGE_SIZE
16000.MRB_FIXED_STATE_ATEXIT_STACK
mrb_state atexit stack.RuntimeError when mrb_state_atexit call count to same mrb_state exceeds
MRB_FIXED_STATE_ATEXIT_STACK_SIZE's value.MRB_FIXED_STATE_ATEXIT_STACK_SIZE
5.MRB_FIXED_STATE_ATEXIT_STACK isn't defined this macro is ignored.mrb_value configurationMRB_ENDIAN_BIG
MRB_NAN_BOXING.MRB_NAN_BOXING
mrb_value in boxed double.MRB_USE_FLOAT32 and MRB_NO_FLOAT.MRB_WORD_BOXING
mrb_value as a word (natural unit of data for the processor).RFloat objects.MRB_NO_BOXING
mrb_value as a C struct (occupies 2 words).MRB_INT64 on 32-bit platforms.host-debug configuration.MRB_WORDBOX_NO_INLINE_FLOAT
RFloat objects.double cannot fit in a 32-bit word).MRB_WORD_BOXING.MRB_USE_ETEXT_RO_DATA_P
etext and edata section addresses defined by the linker to detect read-only data.MRB_NO_DEFAULT_RO_DATA_P
mrb_ro_data_p() does not work for any reason.MRB_USE_CUSTOM_RO_DATA_P
mrb_ro_data_p() implementation.mrb_bool mrb_ro_data_p(const char *ptr).TRUE if ptr is in the read-only section, otherwise return FALSE.MRB_USE_MALLOC_TRIM
malloc_trim(0) for each mrb_full_gc() call.MRB_UTF8_STRING
MRB_STR_LENGTH_MAX
MRB_ARY_LENGTH_MAX
MRB_FUNCALL_ARGC_MAX
16.argc) max value of mrb_funcall.ArgumentError when the argc argument is bigger then this value mrb_funcall.KHASH_INITIAL_SIZE
32.kh_init_ ## name function.MRB_NO_METHOD_CACHE
MRB_METHOD_CACHE_SIZE
256.MRB_NO_METHOD_CACHE is defined.MRB_USE_ALL_SYMBOLS
Symbol.all_symbols in mrbgems/mruby-symbol-extMRB_USE_VM_SWITCH_DISPATCH
MRB_SYMBOL_LINEAR_THRESHOLD
256.Predefined profiles adjust several macros together for specific deployment targets. Define one of the following:
MRB_CONSTRAINED_BASELINE_PROFILE
MRB_NO_METHOD_CACHE, reduces KHASH_INITIAL_SIZE to 16,
and MRB_HEAP_PAGE_SIZE to 256.MRB_BASELINE_PROFILE
MRB_MAIN_PROFILE
MRB_METHOD_CACHE_SIZE to 1024 and MRB_HEAP_PAGE_SIZE
to 4096.MRB_HIGH_PROFILE
MRB_METHOD_CACHE_SIZE to 4096 and MRB_HEAP_PAGE_SIZE
to 4096.