Skip to content

Commit

Permalink
On Debian testing and recent Ubuntu systems llvm-ld fails to find libc,
Browse files Browse the repository at this point in the history
causing every test in the nightly testsuite to fail.  But llvm-ld is only
using libc to work out which symbols to internalize, not for linking with
it.  How can libc effect which symbols are internalized?  I can see two
possibilities: either libc makes use of a function defined in the bitcode
(which it clearly doesn't) or a weak function occurs both in the bitcode
and in libc (in which case using the bitcode's copy should be OK).  Thus
there doesn't seem to any point in looking at libc and comparable system
libraries (eg: libstdc++) when internalizing, and this is confirmed by my
testing: not passing -lc or $(LIBS) when invoking llvm-ld doesn't cause
any failures.  So a simple fix for the Debian issue would be simply not
to pass them to llvm-ld.  But then the question arises: why use llvm-ld
at all rather than "opt -std-link-opts"?  This patch goes all the way
and drops llvm-ld in favour of "opt -std-link-opts".  It also removes
some apparently pointless Makefile rules, which I suspect exist because
llvm-ld produces two output files, X (a script) and X.bc (the bitcode).
With this llvm-ld is not used by the nightly testsuite at all.  It works
for me, but since I don't know the nightly testsuite infrastructure well
I may have broken something, so please review.

llvm-svn: 143460
  • Loading branch information
CunningBaldrick committed Nov 1, 2011
1 parent 7244ff2 commit 18326ba
Showing 1 changed file with 17 additions and 42 deletions.
59 changes: 17 additions & 42 deletions Makefile.programs
Original file line number Diff line number Diff line change
Expand Up @@ -309,53 +309,28 @@ ifndef DISABLE_FOR_LLVM_PROGRAMS
# optimization...

$(PROGRAMS_TO_TEST:%=Output/%.llvm.bc): \
Output/%.llvm.bc: Output/%.linked.bc $(LLVM_LDDPROG)
$(RUNTOOLSAFELY) $(LLVMLD) -info-output-file=$(CURDIR)/$@.info $(STATS) $< \
$(EXTRA_LINKTIME_OPT_FLAGS) $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm
ifneq ($(OPTPASSES),)
$(RUNTOOLSAFELY) $(LOPT) -q $(OPTPASSES) $@ -o $@.tmp
$(MV) -f $@.tmp $@
endif

$(PROGRAMS_TO_TEST:%=Output/%.llvm): \
Output/%.llvm: Output/%.linked.bc $(LLVMLD)
$(RUNTOOLSAFELY) $(LLVMLD) -info-output-file=$(CURDIR)/$@.info $(STATS) $< \
$(EXTRA_LINKTIME_OPT_FLAGS) $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm
ifneq ($(OPTPASSES),)
$(RUNTOOLSAFELY) $(LOPT) -q $(OPTPASSES) $@ -o $@.tmp
$(MV) -f $@.tmp $@
endif
Output/%.llvm.bc: Output/%.linked.bc $(LOPT)
$(RUNTOOLSAFELY) $(LOPT) -std-link-opts $(OPTPASSES) \
-info-output-file=$(CURDIR)/$@.info \
$(STATS) $< $(EXTRA_LINKTIME_OPT_FLAGS) -o $@

$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta.bc): \
Output/%.llvm.optbeta.bc: Output/%.linked.optbeta.bc $(LLVMLD)
$(RUNTOOLSAFELY) $(LLVMLD) -info-output-file=$(CURDIR)/$@.info $(STATS) $< \
$(EXTRA_LINKTIME_OPT_FLAGS) $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm.optbeta

$(PROGRAMS_TO_TEST:%=Output/%.llvm.optbeta): \
Output/%.llvm.optbeta: Output/%.linked.optbeta.bc $(LLVMLD)
$(RUNTOOLSAFELY) $(LLVMLD) -info-output-file=$(CURDIR)/$@.info $(STATS) $< \
$(EXTRA_LINKTIME_OPT_FLAGS) $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm.optbeta
Output/%.llvm.optbeta.bc: Output/%.linked.optbeta.bc $(LOPT)
$(RUNTOOLSAFELY) $(LOPT) -std-link-opts \
-info-output-file=$(CURDIR)/$@.info \
$(STATS) $< $(EXTRA_LINKTIME_OPT_FLAGS) -o $@

$(PROGRAMS_TO_TEST:%=Output/%.noopt-llvm.bc): \
Output/%.noopt-llvm.bc: Output/%.linked.rbc $(LLVMLD)
$(RUNTOOLSAFELY) $(LLVMLD) -disable-opt -info-output-file=$(CURDIR)/$@.info $(STATS) $< \
$(LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.noopt-llvm

$(PROGRAMS_TO_TEST:%=Output/%.noopt-llvm): \
Output/%.noopt-llvm: Output/%.linked.rbc $(LLVMLD)
$(RUNTOOLSAFELY) $(LLVMLD) -disable-opt -info-output-file=$(CURDIR)/$@.info $(STATS) $< \
$(LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.noopt-llvm

Output/%.noopt-llvm.bc: Output/%.linked.rbc $(LOPT)
$(RUNTOOLSAFELY) $(LOPT) \
-info-output-file=$(CURDIR)/$@.info \
$(STATS) $< -o $@

$(PROGRAMS_TO_TEST:%=Output/%.nollvm-ldopt-llvm.bc): \
Output/%.nollvm-ldopt-llvm.bc: Output/%.linked.bc $(LLVMLD)
$(RUNTOOLSAFELY) $(LLVMLD) -disable-opt -info-output-file=$(CURDIR)/$@.info $(STATS) $< \
$(LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.nollvm-ldopt-llvm

$(PROGRAMS_TO_TEST:%=Output/%.nollvm-ldopt-llvm): \
Output/%.nollvm-ldopt-llvm: Output/%.linked.rbc $(LLVMLD)
$(RUNTOOLSAFELY) $(LLVMLD) -disable-opt -info-output-file=$(CURDIR)/$@.info $(STATS) $< \
$(LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.nollvm-ldopt-llvm
Output/%.nollvm-ldopt-llvm.bc: Output/%.linked.bc $(LOPT)
$(RUNTOOLSAFELY) $(LOPT) \
-info-output-file=$(CURDIR)/$@.info \
$(STATS) $< -o $@

endif # ifndef DISABLE_FOR_LLVM_PROGRAMS

Expand All @@ -372,7 +347,7 @@ ifneq ($(ARCH),PowerPC)
ifneq ($(ARCH),x86)
ifneq ($(ARCH),x86_64)
LLCFLAGS += -enable-correct-eh-support
LLVMLD_FLAGS += -disable-inlining
EXTRA_LINKTIME_OPT_FLAGS += -disable-inlining
endif
endif
endif
Expand Down

0 comments on commit 18326ba

Please sign in to comment.