Skip to content

Commit 3f812ab

Browse files
authored
fix shared library build with llvm-19 (#526)
1 parent 8279f95 commit 3f812ab

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,21 @@ PIC_OBJS = \
617617
# link that using `--whole-archive` rather than pass the object files directly
618618
# to CC. This is a workaround for a Windows command line size limitation. See
619619
# the `%.a` rule below for details.
620-
$(SYSROOT_LIB)/%.so: $(OBJDIR)/%.so.a $(BUILTINS_LIB)
621-
$(CC) --target=$(TARGET_TRIPLE) -nodefaultlibs -shared --sysroot=$(SYSROOT) \
622-
-o $@ -Wl,--whole-archive $< -Wl,--no-whole-archive $(BUILTINS_LIB)
620+
621+
# Note: libc.so is special because it shouldn't link to libc.so.
622+
# Note: --allow-undefined-file=linker-provided-symbols.txt is
623+
# a workaround for https://github.com/llvm/llvm-project/issues/103592
624+
$(SYSROOT_LIB)/libc.so: $(OBJDIR)/libc.so.a $(BUILTINS_LIB)
625+
$(CC) $(EXTRA_CFLAGS) --target=${TARGET_TRIPLE} -nodefaultlibs \
626+
-shared --sysroot=$(SYSROOT) \
627+
-o $@ -Wl,--whole-archive $< -Wl,--no-whole-archive $(BUILTINS_LIB) \
628+
-Wl,--allow-undefined-file=linker-provided-symbols.txt
629+
630+
$(SYSROOT_LIB)/%.so: $(OBJDIR)/%.so.a $(SYSROOT_LIB)/libc.so
631+
$(CC) $(EXTRA_CFLAGS) --target=${TARGET_TRIPLE} \
632+
-shared --sysroot=$(SYSROOT) \
633+
-o $@ -Wl,--whole-archive $< -Wl,--no-whole-archive \
634+
-Wl,--allow-undefined-file=linker-provided-symbols.txt
623635

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

libc-top-half/musl/src/signal/psignal.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
#include <signal.h>
44
#include <errno.h>
55

6+
#ifndef __wasilibc_unmodified_upstream
7+
/* undef the macro to use the standard stderr instead of __stderr_FILE
8+
* (the libc internal symbol) as this lives in a separate library,
9+
* libwasi-emulated-signal.so. */
10+
#undef stderr
11+
#endif
12+
613
void psignal(int sig, const char *msg)
714
{
815
FILE *f = stderr;

linker-provided-symbols.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__heap_base
2+
__heap_end
3+
__c_longjmp

0 commit comments

Comments
 (0)