This is an archive of the discontinued LLVM Phabricator instance.

Renovate CMake files in the `llvm-exegesis` tool.
ClosedPublic

Authored by vtjnash on Nov 6 2020, 1:38 PM.

Details

Summary

This attempts to move all tools over to using add_llvm_library for
better consistency. After doing this, I noticed it ended up as nearly a
reimplementation of https://reviews.llvm.org/rL342148, which later got
reverted in r342336 (b09a8c9bd9b819741b38071a7ccd95042ef2643a).

With ccache and ninja on a large core machine (40), I haven't run into
build errors, so I'm hopeful it's better now, though it doesn't seem to
be any different / new.

Diff Detail

Event Timeline

vtjnash created this revision.Nov 6 2020, 1:38 PM
vtjnash requested review of this revision.Nov 6 2020, 1:38 PM

Seems reasonable to me...

This revision is now accepted and ready to land.Jan 31 2021, 10:10 AM
This revision was landed with ongoing or failed builds.Feb 8 2021, 3:27 PM
This revision was automatically updated to reflect the committed changes.
vtjnash reopened this revision.Feb 8 2021, 4:23 PM

Reverted. Seems that something is going wrong with -DBUILD_SHARED_LIBS=ON with this.

Full details are available at:

http://lab.llvm.org:8011/#builders/61/builds/5159
Step 5 (build-unified-tree) failure: build (failure)
...
33.648 [7/5/3257] Building CXX object tools/llvm-exegesis/lib/CMakeFiles/obj.LLVMExegesis.dir/SerialSnippetGenerator.cpp.o
33.710 [7/4/3258] Building CXX object tools/llvm-exegesis/lib/CMakeFiles/obj.LLVMExegesis.dir/Target.cpp.o
34.330 [7/3/3259] Building CXX object tools/llvm-exegesis/lib/CMakeFiles/obj.LLVMExegesis.dir/SnippetRepetitor.cpp.o
34.370 [7/2/3260] Building CXX object tools/llvm-exegesis/lib/CMakeFiles/obj.LLVMExegesis.dir/SnippetGenerator.cpp.o
34.386 [5/3/3261] Linking CXX static library lib/libLLVMExegesis_static.a
34.511 [5/2/3262] Linking CXX shared library lib/libLLVMExegesis.so.13git
34.515 [4/2/3263] Creating library symlink lib/libLLVMExegesis.so
37.244 [4/1/3264] Building CXX object tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o
37.253 [2/2/3265] Linking CXX static library lib/libLLVMExegesisX86_static.a
37.342 [2/1/3266] Linking CXX shared library lib/libLLVMExegesisX86.so.13git
FAILED: lib/libLLVMExegesisX86.so.13git 
: && /usr/bin/clang++ -fPIC -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -O3  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/./lib  -Wl,-O3 -Wl,--gc-sections -shared -Wl,-soname,libLLVMExegesisX86.so.13git -o lib/libLLVMExegesisX86.so.13git tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/X86Counter.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMX86CodeGen.so.13git  lib/libLLVMX86AsmParser.so.13git  lib/libLLVMX86Desc.so.13git  lib/libLLVMX86Disassembler.so.13git  lib/libLLVMX86Info.so.13git  lib/libLLVMExeges
 is.so.13git  lib/libLLVMCore.so.13git  -Wl,-rpath-link,/vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/lib && :
tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o: In function `llvm::cl::opt<unsigned int, false, llvm::cl::parser<unsigned int> >::~opt()':
Target.cpp:(.text._ZN4llvm2cl3optIjLb0ENS0_6parserIjEEED2Ev[_ZN4llvm2cl3optIjLb0ENS0_6parserIjEEED2Ev]+0x7): undefined reference to `vtable for llvm::cl::opt<unsigned int, false, llvm::cl::parser<unsigned int> >'
Target.cpp:(.text._ZN4llvm2cl3optIjLb0ENS0_6parserIjEEED2Ev[_ZN4llvm2cl3optIjLb0ENS0_6parserIjEEED2Ev]+0x32): undefined reference to `vtable for llvm::cl::Option'
tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o: In function `llvm::exegesis::(anonymous namespace)::ExegesisX86Target::createCounter(llvm::StringRef, llvm::exegesis::LLVMState const&) const':
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target13createCounterENS_9StringRefERKNS0_9LLVMStateE+0x46): undefined reference to `llvm::StringError::StringError(llvm::Twine const&, std::error_code)'
tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o: In function `llvm::exegesis::(anonymous namespace)::ExegesisX86Target::setRegTo(llvm::MCSubtargetInfo const&, unsigned int, llvm::APInt const&) const':
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target8setRegToERKNS_15MCSubtargetInfoEjRKNS_5APIntE+0x1b1): undefined reference to `llvm::APInt::initSlowCase(llvm::APInt const&)'
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target8setRegToERKNS_15MCSubtargetInfoEjRKNS_5APIntE+0xd79): undefined reference to `llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long)'
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target8setRegToERKNS_15MCSubtargetInfoEjRKNS_5APIntE+0xd9a): undefined reference to `llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long)'
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target8setRegToERKNS_15MCSubtargetInfoEjRKNS_5APIntE+0xdbb): undefined reference to `llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long)'
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target8setRegToERKNS_15MCSubtargetInfoEjRKNS_5APIntE+0xddc): undefined reference to `llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long)'
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target8setRegToERKNS_15MCSubtargetInfoEjRKNS_5APIntE+0xdfb): undefined reference to `llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long)'
tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o:Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target8setRegToERKNS_15MCSubtargetInfoEjRKNS_5APIntE+0xe1b): more undefined references to `llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long)' follow
tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o: In function `llvm::exegesis::(anonymous namespace)::ExegesisX86Target::getScratchMemoryRegister(llvm::Triple const&) const':
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target24getScratchMemoryRegisterERKNS_6TripleE+0x8): undefined reference to `llvm::Triple::isArch64Bit() const'
tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o: In function `llvm::exegesis::(anonymous namespace)::ExegesisX86Target::fillMemoryOperands(llvm::exegesis::InstructionTemplate&, unsigned int, unsigned int) const':
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target18fillMemoryOperandsERNS0_19InstructionTemplateEjj+0x3c2): undefined reference to `llvm::llvm_unreachable_internal(char const*, char const*, unsigned int)'
tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o: In function `llvm::exegesis::(anonymous namespace)::ExegesisX86Target::getLoopCounterRegister(llvm::Triple const&) const':
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target22getLoopCounterRegisterERKNS_6TripleE+0x5): undefined reference to `llvm::Triple::isArch64Bit() const'
tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o: In function `llvm::exegesis::(anonymous namespace)::ExegesisX86Target::decrementLoopCounterAndJump(llvm::MachineBasicBlock&, llvm::MachineBasicBlock&, llvm::MCInstrInfo const&) const':
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target27decrementLoopCounterAndJumpERNS_17MachineBasicBlockES4_RKNS_11MCInstrInfoE+0x57): undefined reference to `llvm::MachineFunction::CreateMachineInstr(llvm::MCInstrDesc const&, llvm::DebugLoc const&, bool)'
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target27decrementLoopCounterAndJumpERNS_17MachineBasicBlockES4_RKNS_11MCInstrInfoE+0x98): undefined reference to `llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&)'
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target27decrementLoopCounterAndJumpERNS_17MachineBasicBlockES4_RKNS_11MCInstrInfoE+0xc8): undefined reference to `llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&)'
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target27decrementLoopCounterAndJumpERNS_17MachineBasicBlockES4_RKNS_11MCInstrInfoE+0xf2): undefined reference to `llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&)'
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target27decrementLoopCounterAndJumpERNS_17MachineBasicBlockES4_RKNS_11MCInstrInfoE+0x145): undefined reference to `llvm::MachineFunction::CreateMachineInstr(llvm::MCInstrDesc const&, llvm::DebugLoc const&, bool)'
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target27decrementLoopCounterAndJumpERNS_17MachineBasicBlockES4_RKNS_11MCInstrInfoE+0x17c): undefined reference to `llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&)'
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target27decrementLoopCounterAndJumpERNS_17MachineBasicBlockES4_RKNS_11MCInstrInfoE+0x1a6): undefined reference to `llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&)'
tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o: In function `llvm::exegesis::(anonymous namespace)::ExegesisX86Target::randomizeTargetMCOperand(llvm::exegesis::Instruction const&, llvm::exegesis::Variable const&, llvm::MCOperand&, llvm::BitVector const&) const':
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target24randomizeTargetMCOperandERKNS0_11InstructionERKNS0_8VariableERNS_9MCOperandERKNS_9BitVectorE+0x86): undefined reference to `llvm::inconvertibleErrorCode()'
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target24randomizeTargetMCOperandERKNS0_11InstructionERKNS0_8VariableERNS_9MCOperandERKNS_9BitVectorE+0x96): undefined reference to `llvm::StringError::StringError(llvm::Twine const&, std::error_code)'
tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o: In function `llvm::exegesis::(anonymous namespace)::ExegesisX86Target::generateInstructionVariants(llvm::exegesis::Instruction const&, unsigned int) const':
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target27generateInstructionVariantsERKNS0_11InstructionEj+0x10d): undefined reference to `llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long)'
tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o: In function `llvm::exegesis::(anonymous namespace)::ExegesisX86Target::checkFeatureSupport() const':
Target.cpp:(.text._ZNK4llvm8exegesis12_GLOBAL__N_117ExegesisX86Target19checkFeatureSupportEv+0x46): undefined reference to `llvm::StringError::StringError(llvm::Twine const&, std::error_code)'
tools/llvm-exegesis/lib/X86/CMakeFiles/obj.LLVMExegesisX86.dir/Target.cpp.o: In function `llvm::exegesis::loadImmediate(unsigned int, unsigned int, llvm::APInt const&)':
Target.cpp:(.text._ZN4llvm8exegesisL13loadImmediateEjjRKNS_5APIntE+0xa3): undefined reference to `llvm::APInt::countLeadingZerosSlowCase() const'
Target.cpp:(.text._ZN4llvm8exegesisL13loadImmediateEjjRKNS_5APIntE+0x15a): undefined reference to `llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long)'

and http://lab.llvm.org:8011/#builders/121/builds/4493

[3287/5507] Building CXX object tools/llvm-exegesis/lib/AArch64/CMakeFiles/obj.LLVMExegesisAArch64.dir/Target.cpp.o
FAILED: tools/llvm-exegesis/lib/AArch64/CMakeFiles/obj.LLVMExegesisAArch64.dir/Target.cpp.o 
/usr/bin/c++  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/llvm-exegesis/lib/AArch64 -I/home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/tools/llvm-exegesis/lib/AArch64 -Iinclude -I/home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/include -I/home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/lib/Target/AArch64 -Ilib/Target/AArch64 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -O3     -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT tools/llvm-exegesis/lib/AArch64/CMakeFiles/obj.LLVMExegesisAArch64.dir/Target.cpp.o -MF tools/llvm-exegesis/lib/AArch64/CMakeFiles/obj.LLVMExegesisAArch64.dir/Target.cpp.o.d -o tools/llvm-exegesis/lib/AArch64/CMakeFiles/obj.LLVMExegesisAArch64.dir/Target.cpp.o -c /home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp
In file included from /home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/lib/Target/AArch64/AArch64.h:17,
                 from /home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp:9:
/home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.h:84:10: fatal error: AArch64GenInstrInfo.inc: No such file or directory
 #include "AArch64GenInstrInfo.inc"
          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
This revision is now accepted and ready to land.Feb 8 2021, 4:23 PM
vtjnash updated this revision to Diff 322258.Feb 8 2021, 6:05 PM

Okay, the first problem is because add_llvm_library doesn't support STATIC, so we need to use llvm_add_library instead (though it is also fixed by adding the missing Support dependency). The second problem is also missing dependency (for CommonTableGen).

With these updates, the STATIC linkage is also no longer required, though I've left that change for later.

vtjnash updated this revision to Diff 322262.Feb 8 2021, 6:33 PM

On second thought, since the SHARED build is now fixed, there is no reason to disable it (and it helps eliminate more missing link problems).

This revision was landed with ongoing or failed builds.Feb 10 2021, 11:24 AM
This revision was automatically updated to reflect the committed changes.