Coder Social home page Coder Social logo

Comments (4)

holmesmr avatar holmesmr commented on June 3, 2024

Ah, actually, is this covered by this limitation notice in the wiki?

from c2rust.

take-cheeze avatar take-cheeze commented on June 3, 2024

There is too many features used in mruby that is in the known limitation:

  • longjmp/setjmp
  • bitfields
  • variadic function definitions
  • C macros

from c2rust.

holmesmr avatar holmesmr commented on June 3, 2024

Apologies for not reading thoroughly before opening this issue. Will close.

from c2rust.

rinon avatar rinon commented on June 3, 2024

Wanted to see what was going on here so I dug a bit deeper. This failure is actually not one of the limitations mentioned above, it is due to a non-C99 gcc extension, Labels as Values. Ruby can use a threaded interpreter dispatch style that stores goto labels in an array and dispatches directly to one of these labels after each opcode is handled. Rust does not have an analogous feature, so we have no plans to support this extension.

However, I was able to disable the feature in mruby with the following build_config.rb:

MRuby::Build.new do |conf|
  if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
    toolchain :visualcpp
  else
    toolchain :gcc
  end

  conf.cc do |cc|
    cc.defines = %w(MRB_DISABLE_DIRECT_THREADING)
  end
end

Note that while this allowed the project to be fully translated, varargs functions are not (yet) supported. mrb_get_args, mrb_format, mrb_raisef, etc. will need to either be compiled as C code and statically linked into the rust code or re-implemented manually. There are also some warnings about potential flexible array member struct fields. At first glance these appear to be false positive warnings, but I may have missed a real problem in there.

from c2rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.