@@ -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
0 commit comments