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) #2

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

crajcan
Copy link
Owner

@crajcan crajcan commented Jun 14, 2024

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.

…cos#275)

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.
@crajcan crajcan merged commit dc12c38 into main Jun 14, 2024
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.

2 participants