[llvm-dev] Linker error while building a new back end in the latest LLVM from GitHub

Alex Susu via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 9 03:33:15 PST 2021


   Hello.
     I would like to inform that I managed to solve the problem mentioned here and to 
build LLVM today.
     What I had to do was to add (uncomment) in the lib/Target/Connex/CMakeLists.txt (my 
main back end CMakeLists file), in the section LINK_COMPONENTS the following 2 lines:
           Analysis
           TransformUtils

     I got inspired a bit from the XCore back end's main CMakeLists.txt since my back 
end's ConnexTargetTransformInfo.h is inspired from XCore.

     If ever, you can find the corrected CMakeLists.txt at 
https://sites.google.com/site/alexsusu/myfilecabinet/Connex_be.zip.


     However, I still have issues. While running llc I get the following error:
         ********** EXPANDING POST-RA PSEUDO INSTRS **********
         ********** Function: MatMul_BTransposed
         real copy:   $r5 = COPY $r0
         Target didn't implement TargetInstrInfo::copyPhysReg!
         UNREACHABLE executed at 
/home/asusu/LLVM/llvm2021_01_23/llvm-project/llvm/include/llvm/CodeGen/TargetInstrInfo.h:951!
         ...
          #8 0x00007fce772ce4b6 llvm::TargetInstrInfo::isCopyInstrImpl(llvm::MachineInstr 
const&) const 
/home/asusu/LLVM/llvm2021_01_23/llvm-project/llvm/include/llvm/CodeGen/TargetInstrInfo.h:960:3
          #9 0x00007fce712082c8 (anonymous 
namespace)::ExpandPostRA::LowerCopy(llvm::MachineInstr*) 
/home/asusu/LLVM/llvm2021_01_23/llvm-project/llvm/lib/CodeGen/ExpandPostRAPseudos.cpp:166:19
         #10 0x00007fce71208611 (anonymous 
namespace)::ExpandPostRA::runOnMachineFunction(llvm::MachineFunction&) 
/home/asusu/LLVM/llvm2021_01_23/llvm-project/llvm/lib/CodeGen/ExpandPostRAPseudos.cpp:215:20
        ...
         #17 0x00005560165771f7 compileModule(char**, llvm::LLVMContext&) 
/home/asusu/LLVM/llvm2021_01_23/llvm-project/llvm/tools/llc/llc.cpp:661:66


     But actually I did implement TargetInstrInfo::copyPhysReg() in ConnexInstrInfo.cpp in 
my back end (you can see my back end code at 
https://sites.google.com/site/alexsusu/myfilecabinet/Connex_be.zip).

     Can somebody help me with this new llc runtime error that just appeared? (It looks 
like llc does not load the object file of ConnexInstrInfo.cpp, so it might be a hidden 
linker issue).

   Thank you very much,
     Alex



On 2/6/2021 7:26 PM, Alex Susu wrote:
>    Hello.
>      I would like to come back to this message.
>      It seems the reason of these linker errors are some changes performed in LLVM itself 
> in the last 2 years, since I am able to run my back end in an older LLVM build downloaded 
> from the source repository in Mar 2019. I apologize for being a bit in the haze - I didn't 
> follow closely the changes performed to LLVM lately.
> 
>      If interested please find my main CMakeLists.txt for my Connex LLVM back end:
>          add_llvm_component_group(Connex)
> 
>          set(LLVM_TARGET_DEFINITIONS Connex.td)
> 
>          tablegen(LLVM ConnexGenRegisterInfo.inc -gen-register-info)
>          tablegen(LLVM ConnexGenInstrInfo.inc -gen-instr-info)
>          tablegen(LLVM ConnexGenAsmWriter.inc -gen-asm-writer)
>          tablegen(LLVM ConnexGenAsmMatcher.inc -gen-asm-matcher)
>          tablegen(LLVM ConnexGenDAGISel.inc -gen-dag-isel)
>          tablegen(LLVM ConnexGenMCCodeEmitter.inc -gen-emitter)
>          tablegen(LLVM ConnexGenCallingConv.inc -gen-callingconv)
>          tablegen(LLVM ConnexGenSubtargetInfo.inc -gen-subtarget)
>          add_public_tablegen_target(ConnexCommonTableGen)
> 
>          add_llvm_target(ConnexCodeGen
>            ConnexAsmPrinter.cpp
>            ConnexFrameLowering.cpp
>            ConnexHazardRecognizer.cpp
>            # ConnexHazardRecognizerPreRAScheduler.cpp
>            ConnexInstrInfo.cpp
>            ConnexISelDAGToDAG.cpp
>            ConnexISelLowering.cpp
>            ConnexMCInstLower.cpp
>            ConnexRegisterInfo.cpp
>            ConnexSelectionDAGInfo.cpp
>            ConnexSubtarget.cpp
>            ConnexTargetMachine.cpp
> 
>            LINK_COMPONENTS
>            #Analysis
>            AsmPrinter
>            CodeGen
>            Core
>            ConnexDesc
>            ConnexInfo
>            MC
>            SelectionDAG
>            Support
>            Target
>            #TransformUtils
> 
>            ADD_TO_COMPONENT
>            Connex
>            )
> 
>          #add_subdirectory(AsmParser) # 2021_01
>          #add_subdirectory(InstPrinter)
>          #add_subdirectory(Disassembler)
>          add_subdirectory(MCTargetDesc)
>          add_subdirectory(TargetInfo)
> 
> 
>      Please keep in mind that the source files of my Connex LLVM back
>   end are in a ZIP archive at this address:
>   https://sites.google.com/site/alexsusu/myfilecabinet/Connex_be.zip .
> 
> 
>    Thank you very much,
>      Alex
> 
> 
> On 2/3/2021 11:43 PM, Alex Susu wrote:
>> Hello.
>>      I am trying to build against the latest LLVM source from GitHub (from Jan 23 2021) 
>> my Connex processor back end, which is mostly inspired from the BPF and Mips back end.
>>      I did my best to correct all the errors that appeared, but I now get a rather 
>> strange linker error that I don't know exactly how to solve (maybe somebody is more 
>> experienced than me on this). Maybe I have an error in lib/Target/Connex/CMakeLists.txt.
>>
>>     The error I get while building LLVM is:
>>        <<cd /home/asusu/LLVM/llvm2021_01_23/llvm-project/build/lib/Target/Connex && 
>> /usr/bin/cmake -E cmake_link_script CMakeFiles/LLVMConnexCodeGen.dir/link.txt --verbose=1
>>        /usr/bin/c++ -fPIC  -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-redundant-move -Wno-noexcept-type 
>> -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -g 
>>   -Wl,-rpath-link,/home/asusu/LLVM/llvm2021_01_23/llvm-project/build/./lib   -Wl,-z,defs 
>> -Wl,-z,nodelete -shared -Wl,-soname,libLLVMConnexCodeGen.so.12git -o 
>> ../../libLLVMConnexCodeGen.so.12git 
>> CMakeFiles/LLVMConnexCodeGen.dir/ConnexAsmPrinter.cpp.o 
>> CMakeFiles/LLVMConnexCodeGen.dir/ConnexFrameLowering.cpp.o 
>> CMakeFiles/LLVMConnexCodeGen.dir/ConnexHazardRecognizer.cpp.o 
>> CMakeFiles/LLVMConnexCodeGen.dir/ConnexInstrInfo.cpp.o 
>> CMakeFiles/LLVMConnexCodeGen.dir/ConnexISelDAGToDAG.cpp.o 
>> CMakeFiles/LLVMConnexCodeGen.dir/ConnexISelLowering.cpp.o 
>> CMakeFiles/LLVMConnexCodeGen.dir/ConnexMCInstLower.cpp.o 
>> CMakeFiles/LLVMConnexCodeGen.dir/ConnexRegisterInfo.cpp.o 
>> CMakeFiles/LLVMConnexCodeGen.dir/ConnexSelectionDAGInfo.cpp.o 
>> CMakeFiles/LLVMConnexCodeGen.dir/ConnexSubtarget.cpp.o 
>> CMakeFiles/LLVMConnexCodeGen.dir/ConnexTargetMachine.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib" 
>> ../../libLLVMAsmPrinter.so.12git ../../libLLVMConnexDesc.so.12git 
>> ../../libLLVMConnexInfo.so.12git ../../libLLVMSelectionDAG.so.12git 
>> ../../libLLVMCodeGen.so.12git ../../libLLVMTarget.so.12git ../../libLLVMMC.so.12git 
>> ../../libLLVMCore.so.12git ../../libLLVMSupport.so.12git 
>> -Wl,-rpath-link,/home/asusu/LLVM/llvm2021_01_23/llvm-project/build/lib
>>        /usr/bin/ld: CMakeFiles/LLVMConnexCodeGen.dir/ConnexTargetMachine.cpp.o: in 
>> function `llvm::TargetTransformInfo::Model<llvm::ConnexTTIImpl>::~Model()':
>> /home/asusu/LLVM/llvm2021_01_23/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfo.h:1672: 
>> undefined reference to `llvm::TargetTransformInfo::Concept::~Concept()'
>>        /usr/bin/ld: CMakeFiles/LLVMConnexCodeGen.dir/ConnexTargetMachine.cpp.o: in 
>> function 
>> `llvm::TargetTransformInfoImplCRTPBase<llvm::ConnexTTIImpl>::getUserCost(llvm::User 
>> const*, llvm::ArrayRef<llvm::Value const*>, llvm::TargetTransformInfo::TargetCostKind)':
>> /home/asusu/LLVM/llvm2021_01_23/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h:911: 
>> undefined reference to `llvm::IntrinsicCostAttributes::IntrinsicCostAttributes(unsigned 
>> int, llvm::CallBase const&)'
>>        /usr/bin/ld: 
>> /home/asusu/LLVM/llvm2021_01_23/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h:953: 
>> undefined reference to `llvm::TargetTransformInfo::getOperandInfo(llvm::Value const*, 
>> llvm::TargetTransformInfo::OperandValueProperties&)'
>>        ...
>>        ...
>>        /usr/bin/ld: 
>> /home/asusu/LLVM/llvm2021_01_23/llvm-project/llvm/include/llvm/CodeGen/BasicTTIImpl.h:1805: 
>> undefined reference to `llvm::IntrinsicCostAttributes::IntrinsicCostAttributes(unsigned 
>> int, llvm::Type*, llvm::ArrayRef<llvm::Type*>)'
>>        /usr/bin/ld: 
>> /home/asusu/LLVM/llvm2021_01_23/llvm-project/llvm/include/llvm/CodeGen/BasicTTIImpl.h:1826: 
>> undefined reference to `llvm::IntrinsicCostAttributes::IntrinsicCostAttributes(unsigned 
>> int, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::FastMathFlags)'
>>        collect2: error: ld returned 1 exit status>>
>>
>>
>>      Please find if you have the time also most of the source files of my Connex LLVM 
>> back end in the ZIP archive at this address: 
>> https://sites.google.com/site/alexsusu/myfilecabinet/Connex_be.zip (please note the file 
>> ERROR_LINKER.txt contains the above mentioned linker error).
>>      Please let me know if you want me to provide any further information about my build.
>>
>>    Thank you very much,
>>      Alex


More information about the llvm-dev mailing list