about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRafael Ávila de Espíndola <respindola@mozilla.com>2011-04-08 13:54:48 -0400
committerRafael Ávila de Espíndola <respindola@mozilla.com>2011-04-08 14:25:18 -0400
commitf8e22cdff328dc9895e146cdcf0089f3e4db27f8 (patch)
treeefcc5554072e2974bcd00eda7f1d8cb929dba858
parent97d0f76c633b3e3f73bed79096e24b320ee6dbaf (diff)
downloadrust-f8e22cdff328dc9895e146cdcf0089f3e4db27f8.tar.gz
rust-f8e22cdff328dc9895e146cdcf0089f3e4db27f8.zip
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.
-rw-r--r--Makefile.in17
1 files changed, 13 insertions, 4 deletions
diff --git a/Makefile.in b/Makefile.in
index c9b5411559b..a9d79182723 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -38,7 +38,8 @@ ifeq ($(CFG_OSTYPE), Linux)
   CFG_LIB_NAME=lib$(1).so
   CFG_GCC_CFLAGS += -fPIC -march=i686 -O2
   CFG_GCC_LINK_FLAGS += -shared -fPIC -ldl -lpthread -lrt
-  CFG_GCC_DEF_FLAG := -Wl,-whole-archive,--export-dynamic,--dynamic-list=
+  CFG_GCC_DEF_FLAG := -Wl,--export-dynamic,--dynamic-list=
+  CFG_GCC_PRE_LIB_FLAGS := -Wl,-whole-archive
   CFG_GCC_POST_LIB_FLAGS := -Wl,-no-whole-archive
   ifeq ($(CFG_CPUTYPE), x86_64)
     CFG_GCC_CFLAGS += -m32
@@ -417,11 +418,19 @@ rt/$(CFG_RUNTIME): $(RUNTIME_OBJS) $(MKFILES) $(RUNTIME_HDR) $(RUNTIME_DEF)
 	@$(call E, link: $@)
 	$(Q)$(call CFG_LINK_C,$@,$(RUNTIME_LIBS) $(RUNTIME_OBJS),$(RUNTIME_DEF))
 
-rustllvm/$(CFG_RUSTLLVM): $(RUSTLLVM_OBJS) $(MKFILES) $(RUSTLLVM_HDR) \
+# FIXME: Building a .a is a hack so that we build with both older and newer
+# versions of LLVM. In newer versions some of the bits of this library are
+# already in LLVM itself, so they are skipped.
+rustllvm/rustllvmbits.a: $(RUSTLLVM_OBJS)
+	rm -f $@
+	ar crs $@ $^
+
+rustllvm/$(CFG_RUSTLLVM): rustllvm/rustllvmbits.a $(MKFILES) $(RUSTLLVM_HDR) \
                           $(RUSTLLVM_DEF)
 	@$(call E, link: $@)
-	$(Q)$(call CFG_LINK_C,$@,$(RUSTLLVM_LIBS) $(RUSTLLVM_OBJS) \
-          $(CFG_LLVM_LIBS) $(CFG_LLVM_LDFLAGS),$(RUSTLLVM_DEF))
+	$(Q)$(call CFG_LINK_C,$@,$(RUSTLLVM_LIBS) rustllvm/rustllvmbits.a \
+          $(CFG_GCC_PRE_LIB_FLAGS) $(CFG_LLVM_LIBS) \
+          $(CFG_GCC_POST_LIB_FLAGS) $(CFG_LLVM_LDFLAGS),$(RUSTLLVM_DEF))
 
 ifdef CFG_BOOT_NATIVE
 boot/rustboot$(X): $(BOOT_CMXS) $(MKFILES)