Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm32-unknown-unknown: Fix undefined malloc/free/calloc symbols #275

Merged
merged 1 commit into from
May 24, 2024

Conversation

jbms
Copy link
Contributor

@jbms jbms commented Apr 12, 2024

As discussed in #250, in some cases the definitions of malloc, free, and calloc are used but don't get linked in, leading to undefined symbols (i.e. reference to the symbol in "env").

I was not able to determine exactly why this is happening, but it seems to be related to malloc, calloc, and free being defined as inline functions. When building in debug mode there are undefined symbols; when building in release mode there are not, presumably because the functions are inlined.

Switching to macros avoids issues of inlining and fixes this issue for me.

As discussed in gyscos#250, in some
cases the definitions of `malloc`, `free`, and `calloc` are used but
don't get linked in, leading to undefined symbols (i.e. reference to the
symbol in "env").

I was not able to determine exactly why this is happening, but it seems
to be related to `malloc`, `calloc`, and `free` being defined as inline
functions.  When building in debug mode there are undefined symbols;
when building in release mode there are not, presumably because the
functions are inlined.

Switching to macros avoids issues of inlining and fixes this issue for
me.
@gyscos gyscos merged commit fb6b490 into gyscos:main May 24, 2024
@gyscos
Copy link
Owner

gyscos commented May 24, 2024

Hi, and thanks for the work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants