Skip to content

[llvm-libc] Import setjmp from llvm-libc #24765

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

Merged
merged 3 commits into from
Jul 30, 2025

Conversation

google-yfyang
Copy link
Collaborator

Defined a wasm-specific wasm/sigsetjmp.cpp that just fowards the call to setjmp.

Defines in the musl header don't quite work with llvm-libc's setjmp.

@@ -26,7 +26,7 @@ typedef struct __jmp_buf_tag {
|| defined(_BSD_SOURCE)
typedef jmp_buf sigjmp_buf;
/* XXX EMSCRIPTEN: No signals support, alias sigsetjmp and siglongjmp to their non-signals counterparts. */
#if __EMSCRIPTEN__
#if __EMSCRIPTEN__ && !defined(LLVM_LIBC)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could remove this musl patch and instead do this redirection in source files, then our musl patch would be smaller and we could avoid the need for this new LLVM_LIBC macro.

I'm fine landing this patch either way, we can always clean this up as a followup.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine either way as well.
On the hand, this should no longer be of any issue once we switch over to use llvm-libc public headers over the musl ones.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but I honestly think that process will take O(years). We can't delete musl until llvm-libc is has complete parity, or at least close enough that we accept some minor regressions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly. As I expect to see more of these as we import more llvm-libc, I feel like we should probably try to address this properly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL. The forwarding is now done in source files.

@google-yfyang google-yfyang force-pushed the main branch 5 times, most recently from 1ed883d to c58148b Compare July 23, 2025 19:36
@@ -1363,6 +1366,7 @@ def get_files(self):
filenames=['thread_profiler.c'])

libc_files += glob_in_path('system/lib/libc/compat', '*.c')
libc_files += glob_in_path('system/lib/libc/musl/setjmp', '*.c')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put these two wrappers into the existing emscripten_libc_stubs.c instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it looks like system/lib/libc/musl/src/signal/siglongjmp.c already exists and does the right thing.

Can you update the existing system/lib/libc/musl/src/signal/sigsetjmp.c to include this stub and then add those two files to list on line 1330 in system_libs.py.

@google-yfyang google-yfyang force-pushed the main branch 2 times, most recently from ce52e32 to c1c862b Compare July 24, 2025 19:22
@google-yfyang google-yfyang merged commit 0af682e into emscripten-core:main Jul 30, 2025
30 checks passed
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