Skip to content

Combining MRB_NO_BOXING, MRB_INT64, and MRB_USE_FLOAT32 on a 32-bit system causes a compilation error #6722

Description

@dearblue

On FreeBSD 15 amd64 with cc -m32 or on 32-bit MinGW, combining MRB_NO_BOXING, MRB_INT64, and MRB_USE_FLOAT32 results in different compilation errors.

  • mruby revision: commit 2031ae9

  • cc -m32 on FreeBSD 15 amd64

    • build configuration (myconfig1.rb)

      MRuby::Lockfile.disable
      
      MRuby::Build.new do
        toolchain "gcc"
        cc.flags << "-m32"
        linker.flags << "-m32"
        defines << %w(MRB_NO_BOXING MRB_INT64 MRB_USE_FLOAT32)
      end
    • rake MRUBY_CONFIG=myconfig1.rb

      ...omitted...
      CC    src/gc.c -> build/host/mrbc/src/gc.o
      In file included from /var/tmp/mruby/src/gc.c:11:
      /var/tmp/mruby/src/gc.c: In function 'mrb_init_gc':
      /var/tmp/mruby/include/mruby.h:83:39: error: static assertion failed: "RVALUE size must be within 5 words"
         83 | # define mrb_static_assert2(exp, str) _Static_assert(exp, str)
            |                                       ^~~~~~~~~~~~~~
      /var/tmp/mruby/include/mruby.h:99:40: note: in definition of macro 'mrb_static_assert_expand'
         99 | # define mrb_static_assert_expand(...) __VA_ARGS__ /* for MSVC behaviour - https://stackoverflow.com/q/5530505 */
            |                                        ^~~~~~~~~~~
      /var/tmp/mruby/include/mruby.h:100:54: note: in expansion of macro 'mrb_static_assert2'
        100 | # define mrb_static_assert_selector(a, b, name, ...) name
            |                                                      ^~~~
      /var/tmp/mruby/include/mruby.h:109:30: note: in expansion of macro 'mrb_static_assert_selector'
        109 |     mrb_static_assert_expand(mrb_static_assert_selector(__VA_ARGS__, mrb_static_assert2, mrb_static_assert1, _)(__VA_ARGS__))
            |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
      /var/tmp/mruby/include/mruby/object.h:41:3: note: in expansion of macro 'mrb_static_assert'
         41 |   mrb_static_assert(sizeof(st) <= sizeof(void*) * 5, \
            |   ^~~~~~~~~~~~~~~~~
      /var/tmp/mruby/src/gc.c:1597:3: note: in expansion of macro 'mrb_static_assert_object_size'
       1597 |   mrb_static_assert_object_size(RVALUE);
            |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      rake aborted!
      Command failed with status (1): [gcc -MMD -c -std=gnu99 -g -O3 -Wall -Wundef -Werror-implicit-function-declaration -Wwrite-strings -m32 -DMRB_NO_GEMS -DMRB_NO_BOXING -DMRB_INT64 -DMRB_USE_FLOAT32 -I"/var/tmp/mruby/include" -I"/var/tmp/mruby/build/host/mrbc/include" -o "/var/tmp/mruby/build/host/mrbc/src/gc.o" "/var/tmp/mruby/src/gc.c"]
      /var/tmp/mruby/lib/mruby/build/command.rb:33:in 'MRuby::Command#_run'
      /var/tmp/mruby/lib/mruby/build/command.rb:95:in 'MRuby::Command::Compiler#run'
      /var/tmp/mruby/lib/mruby/build/command.rb:120:in 'block (2 levels) in MRuby::Command::Compiler#define_rules'
      Tasks: TOP => default => all => gensym => /var/tmp/mruby/build/host/presym => /var/tmp/mruby/build/host/mrblib/mrblib.pi => /var/tmp/mruby/build/host/mrblib/mrblib.c => /var/tmp/mruby/build/host/mrbc/bin/mrbc => /var/tmp/mruby/build/host/mrbc/lib/libmruby_core.a => /var/tmp/mruby/build/host/mrbc/src/gc.o
      (See full trace by running task with --trace)
      
  • mingw32-gcc on FreeBSD 15 amd64

    • build configuration (myconfig2.rb)

      MRuby::Lockfile.disable
      
      MRuby::CrossBuild.new("mingw32") do
        toolchain "gcc"
        cc.command = "mingw32-gcc"
        linker.command = "mingw32-gcc"
        defines << %w(MRB_NO_BOXING MRB_INT64 MRB_USE_FLOAT32)
      end
    • rake MRUBY_CONFIG=myconfig2.rb

      ...omitted...
      CC    src/array.c -> build/mingw32/src/array.o
      In file included from /var/tmp/mruby/src/array.c:7:0:
      /var/tmp/mruby/include/mruby.h:83:39: error: static assertion failed: "MRB_ARY_EMBED_LEN_MAX > 0"
       # define mrb_static_assert2(exp, str) _Static_assert(exp, str)
                                             ^
      /var/tmp/mruby/include/mruby.h:99:40: note: in definition of macro 'mrb_static_assert_expand'
       # define mrb_static_assert_expand(...) __VA_ARGS__ /* for MSVC behaviour - https://stackoverflow.com/q/5530505 */
                                              ^
      /var/tmp/mruby/include/mruby.h:100:54: note: in expansion of macro 'mrb_static_assert2'
       # define mrb_static_assert_selector(a, b, name, ...) name
                                                            ^
      /var/tmp/mruby/include/mruby.h:109:30: note: in expansion of macro 'mrb_static_assert_selector'
           mrb_static_assert_expand(mrb_static_assert_selector(__VA_ARGS__, mrb_static_assert2, mrb_static_assert1, _)(__VA_ARGS__))
                                    ^
      /var/tmp/mruby/include/mruby/array.h:31:1: note: in expansion of macro 'mrb_static_assert'
       mrb_static_assert(MRB_ARY_EMBED_LEN_MAX > 0, "MRB_ARY_EMBED_LEN_MAX > 0");
       ^
      rake aborted!
      Command failed with status (1): [mingw32-gcc -MMD -c -std=gnu99 -g -O3 -Wall -Wundef -Werror-implicit-function-declaration -Wwrite-strings -DMRB_NO_GEMS -DMRB_NO_BOXING -DMRB_INT64 -DMRB_USE_FLOAT32 -I"/var/tmp/mruby/include" -I"/var/tmp/mruby/build/mingw32/include" -o "/var/tmp/mruby/build/mingw32/src/array.o" "/var/tmp/mruby/src/array.c"]
      /var/tmp/mruby/lib/mruby/build/command.rb:33:in 'MRuby::Command#_run'
      /var/tmp/mruby/lib/mruby/build/command.rb:95:in 'MRuby::Command::Compiler#run'
      /var/tmp/mruby/lib/mruby/build/command.rb:120:in 'block (2 levels) in MRuby::Command::Compiler#define_rules'
      /var/tmp/mruby/Rakefile:48:in 'block in <top (required)>'
      Tasks: TOP => build => /var/tmp/mruby/build/mingw32/lib/libmruby_core.a => /var/tmp/mruby/build/mingw32/src/array.o
      (See full trace by running task with --trace)
      

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions