[LLVMdev] llvm-mc build failure

Óscar Fuentes ofv at wanadoo.es
Wed Jul 27 18:58:22 PDT 2011

Dawie Joubert <djjoubert at csir.co.za> writes:

> Recently (approximately a week ago) Clang and LLVM started to failed at
> building. Assuming it was my incompetence, I cleared everything and
> started witha  fresh checkout (not that I changed it though). I am on
> Ubuntu 10.04 LTS 64-Bit. And I configure and compile with CMake.
> The error message I get at approximatley 66% is as follows:
> Linking CXX executable ../../bin/llvm-mc
> ../../lib/libLLVMMSP430Desc.a(MSP430MCTargetDesc.cpp.o): In function
> `llvm::MSP430InstPrinter::MSP430InstPrinter(llvm::MCAsmInfo const&)':
> MSP430MCTargetDesc.cpp:(.text._ZN4llvm17MSP430InstPrinterC1ERKNS_9MCAsmInfoE[llvm::MSP430InstPrinter::MSP430InstPrinter(llvm::MCAsmInfo
> const&)]+0x2a): undefined reference to `vtable for
> llvm::MSP430InstPrinter'
> ../../lib/libLLVMMipsDesc.a(MipsMCTargetDesc.cpp.o): In function
> `llvm::MipsInstPrinter::MipsInstPrinter(llvm::MCAsmInfo const&)':
> MipsMCTargetDesc.cpp:(.text._ZN4llvm15MipsInstPrinterC1ERKNS_9MCAsmInfoE[llvm::MipsInstPrinter::MipsInstPrinter(llvm::MCAsmInfo
> const&)]+0x2a): undefined reference to `vtable for
> llvm::MipsInstPrinter'
> ../../lib/libLLVMPowerPCDesc.a(PPCMCTargetDesc.cpp.o): In function
> `llvm::PPCInstPrinter::PPCInstPrinter(llvm::MCAsmInfo const&, unsigned
> int)':
> PPCMCTargetDesc.cpp:(.text._ZN4llvm14PPCInstPrinterC1ERKNS_9MCAsmInfoEj[llvm::PPCInstPrinter::PPCInstPrinter(llvm::MCAsmInfo
> const&, unsigned int)]+0x2d): undefined reference to `vtable for
> llvm::PPCInstPrinter'
> ../../lib/libLLVMARMDesc.a(ARMMCTargetDesc.cpp.o): In function
> `llvm::ARMInstPrinter::ARMInstPrinter(llvm::MCAsmInfo const&)':
> ARMMCTargetDesc.cpp:(.text._ZN4llvm14ARMInstPrinterC1ERKNS_9MCAsmInfoE[llvm::ARMInstPrinter::ARMInstPrinter(llvm::MCAsmInfo
> const&)]+0x2a): undefined reference to `vtable for
> llvm::ARMInstPrinter'
> ../../lib/libLLVMMBlazeDesc.a(MBlazeMCTargetDesc.cpp.o): In function
> `llvm::MBlazeInstPrinter::MBlazeInstPrinter(llvm::MCAsmInfo const&)':
> MBlazeMCTargetDesc.cpp:(.text._ZN4llvm17MBlazeInstPrinterC1ERKNS_9MCAsmInfoE[llvm::MBlazeInstPrinter::MBlazeInstPrinter(llvm::MCAsmInfo
> const&)]+0x2a): undefined reference to `vtable for
> llvm::MBlazeInstPrinter'
> collect2: ld returned 1 exit status
> make[2]: *** [bin/llvm-mc] Error 1
> make[1]: *** [tools/llvm-mc/CMakeFiles/llvm-mc.dir/all] Error 2
> make: *** [all] Error 2

Let's restrict the discussion to the PowerPC libraries. The other
instances probably are similar.

The tool that inspects dependencies among LLVM libraries fails to detect
the vtable reference from libLLVMPowerPCDesc to
libLLVMPowerPCAsmPrinter, which is the only reference among them when
compiled in release mode. So the algorithm that creates the list of
libraries to be linked into llvm-mc has no reason for putting one in
front of another. The cmake build is unlucky and lists them in the wrong
order, while the configure&make build is lucky and lists them in the
right order.

The proper fix for the problem is to teach utils/GenLibDeps.pl how to
detect vtable references. An interim fix for the cmake build is to
explicitly declare a library dependency from LLVM${Target}Desc to
LLVM${Target}AsmPrinter, or hack LLVM-Config.cmake to be bug-compatible
with the llvm-config perl script.

More information about the llvm-dev mailing list