Skip to content

Commit f8e22cd

Browse files
committed
Gold is more strict about --whole-archive and will report duplicated
symbols because of an Object.o in a .a and one outside. A similar problem happens for the non-shared part of libpthread. This patch moves the -whole-archive/-no-whole-archive to include just the llvm libs.
1 parent 97d0f76 commit f8e22cd

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Makefile.in

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ ifeq ($(CFG_OSTYPE), Linux)
3838
CFG_LIB_NAME=lib$(1).so
3939
CFG_GCC_CFLAGS += -fPIC -march=i686 -O2
4040
CFG_GCC_LINK_FLAGS += -shared -fPIC -ldl -lpthread -lrt
41-
CFG_GCC_DEF_FLAG := -Wl,-whole-archive,--export-dynamic,--dynamic-list=
41+
CFG_GCC_DEF_FLAG := -Wl,--export-dynamic,--dynamic-list=
42+
CFG_GCC_PRE_LIB_FLAGS := -Wl,-whole-archive
4243
CFG_GCC_POST_LIB_FLAGS := -Wl,-no-whole-archive
4344
ifeq ($(CFG_CPUTYPE), x86_64)
4445
CFG_GCC_CFLAGS += -m32
@@ -417,11 +418,19 @@ rt/$(CFG_RUNTIME): $(RUNTIME_OBJS) $(MKFILES) $(RUNTIME_HDR) $(RUNTIME_DEF)
417418
@$(call E, link: $@)
418419
$(Q)$(call CFG_LINK_C,$@,$(RUNTIME_LIBS) $(RUNTIME_OBJS),$(RUNTIME_DEF))
419420

420-
rustllvm/$(CFG_RUSTLLVM): $(RUSTLLVM_OBJS) $(MKFILES) $(RUSTLLVM_HDR) \
421+
# FIXME: Building a .a is a hack so that we build with both older and newer
422+
# versions of LLVM. In newer versions some of the bits of this library are
423+
# already in LLVM itself, so they are skipped.
424+
rustllvm/rustllvmbits.a: $(RUSTLLVM_OBJS)
425+
rm -f $@
426+
ar crs $@ $^
427+
428+
rustllvm/$(CFG_RUSTLLVM): rustllvm/rustllvmbits.a $(MKFILES) $(RUSTLLVM_HDR) \
421429
$(RUSTLLVM_DEF)
422430
@$(call E, link: $@)
423-
$(Q)$(call CFG_LINK_C,$@,$(RUSTLLVM_LIBS) $(RUSTLLVM_OBJS) \
424-
$(CFG_LLVM_LIBS) $(CFG_LLVM_LDFLAGS),$(RUSTLLVM_DEF))
431+
$(Q)$(call CFG_LINK_C,$@,$(RUSTLLVM_LIBS) rustllvm/rustllvmbits.a \
432+
$(CFG_GCC_PRE_LIB_FLAGS) $(CFG_LLVM_LIBS) \
433+
$(CFG_GCC_POST_LIB_FLAGS) $(CFG_LLVM_LDFLAGS),$(RUSTLLVM_DEF))
425434

426435
ifdef CFG_BOOT_NATIVE
427436
boot/rustboot$(X): $(BOOT_CMXS) $(MKFILES)

0 commit comments

Comments
 (0)