Skip to content

Commit

Permalink
fix shared library build with llvm-19 (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt authored Aug 28, 2024
1 parent 8279f95 commit 3f812ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,21 @@ 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.
# Note: --allow-undefined-file=linker-provided-symbols.txt is
# a workaround for https://github.com/llvm/llvm-project/issues/103592
$(SYSROOT_LIB)/libc.so: $(OBJDIR)/libc.so.a $(BUILTINS_LIB)
$(CC) $(EXTRA_CFLAGS) --target=${TARGET_TRIPLE} -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) $(EXTRA_CFLAGS) --target=${TARGET_TRIPLE} \
-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
7 changes: 7 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,13 @@
#include <signal.h>
#include <errno.h>

#ifndef __wasilibc_unmodified_upstream
/* undef the macro to use the standard stderr instead of __stderr_FILE
* (the libc internal symbol) as this lives in a separate library,
* libwasi-emulated-signal.so. */
#undef stderr
#endif

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

0 comments on commit 3f812ab

Please sign in to comment.