Giter Site home page Giter Site logo

Allow usage of `wasm2lua` without static linking to `libc` / Incorrect error message when `mallocName` is undefined about wasm2lua HOT 3 CLOSED

swadicalrag avatar swadicalrag commented on May 17, 2024
Allow usage of `wasm2lua` without static linking to `libc` / Incorrect error message when `mallocName` is undefined

from wasm2lua.

Comments (3)

SwadicalRag avatar SwadicalRag commented on May 17, 2024 1

I lied, sorry I fixed it.

You can try the above fix, or by running wasm2lua with the nolibc flag

from wasm2lua.

SwadicalRag avatar SwadicalRag commented on May 17, 2024
  1. undefined is not defined is a user experience bug, this code should be
-this.writeLn(this.outBuf,`local __MALLOC__ = ${malloc ? malloc.id : `function() error "${this.options.webidl.mallocName} is not defined" end`}`);
+this.writeLn(this.outBuf,`local __MALLOC__ = ${malloc ? malloc.id : `function() error "${this.options.webidl.mallocName || "malloc"} is not defined" end`}`);
  1. hm, uhh, hmm

When I last used this project, malloc was defined and exported alongside whatever program you were compiling to a .wasm file. The default symbol for malloc was just simply malloc. This is because libc was being compiled into the WASM file too.

Here's what the code was trying to reference

image

image

Perhaps you should investigate your wasm binary - is the malloc symbol defined and exported there? Is it called something else? If so you should plug the right symbol name into mallocName. If nothing seems to make sense, perhaps the WASI ecosystem has changed since I last looked at this project.

HOWEVER, it seems like you want a way to use wasm2lua without libc. I can certainly add a flag to include a stub malloc in, but that'd mean that I have to dig my hands into a repository that I haven't touched in a while and do scary things to it.

Perhaps what you can try instead is to define your own stub malloc export in the code you're writing.

extern "C" void* malloc(int size) {
  return 0;
}

Something like that should be enough for your troubles.

I hope this.. helps? Unfortunately I'm held up with real life responsibilities and other projects, so I can't do very much here unless things are looking dire.

from wasm2lua.

Vurv78 avatar Vurv78 commented on May 17, 2024

Awesome, tysm!

from wasm2lua.

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.