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

fix shared library build with llvm-19 #526

Merged
merged 7 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,17 @@ PIC_OBJS = \
# link that using `--whole-archive` rather than pass the object files directly
# to CC. This is a workaround for a Windows command line size limitation. See
# the `%.a` rule below for details.
$(SYSROOT_LIB)/%.so: $(OBJDIR)/%.so.a $(BUILTINS_LIB)
$(CC) --target=$(TARGET_TRIPLE) -nodefaultlibs -shared --sysroot=$(SYSROOT) \
-o $@ -Wl,--whole-archive $< -Wl,--no-whole-archive $(BUILTINS_LIB)

# Note: libc.so is special because it shouldn't link to libc.so.
$(SYSROOT_LIB)/libc.so: $(OBJDIR)/libc.so.a $(BUILTINS_LIB)
$(CC) $(CFLAGS) -nodefaultlibs -shared --sysroot=$(SYSROOT) \
-o $@ -Wl,--whole-archive $< -Wl,--no-whole-archive $(BUILTINS_LIB) \
-Wl,--allow-undefined-file=linker-provided-symbols.txt

$(SYSROOT_LIB)/%.so: $(OBJDIR)/%.so.a $(SYSROOT_LIB)/libc.so
$(CC) $(CFLAGS) -shared --sysroot=$(SYSROOT) \
-o $@ -Wl,--whole-archive $< -Wl,--no-whole-archive \
-Wl,--allow-undefined-file=linker-provided-symbols.txt

$(OBJDIR)/libc.so.a: $(LIBC_SO_OBJS) $(MUSL_PRINTSCAN_LONG_DOUBLE_SO_OBJS)

Expand Down
5 changes: 5 additions & 0 deletions libc-top-half/musl/src/signal/psignal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
#include <signal.h>
#include <errno.h>

/* undef the macro to use the standard stderr instead of __stderr_FILE
abrown marked this conversation as resolved.
Show resolved Hide resolved
* (the libc internal symbol) as this lives in a separate library,
* libwasi-emulated-signal.so. */
#undef stderr

void psignal(int sig, const char *msg)
{
FILE *f = stderr;
Expand Down
3 changes: 3 additions & 0 deletions linker-provided-symbols.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__heap_base
__heap_end
__c_longjmp
Copy link
Member

Choose a reason for hiding this comment

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

Can you open a wasm-ld bug regarding this? I think these should not be necessary.

Also, perhaps add a comment here (or in the Makefile) with a link the bug so we know its temporary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

Choose a reason for hiding this comment

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