Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to llvm::MachineInstruction::dump #18

Closed
Youda008 opened this issue Nov 17, 2018 · 3 comments
Closed

undefined reference to llvm::MachineInstruction::dump #18

Youda008 opened this issue Nov 17, 2018 · 3 comments

Comments

@Youda008
Copy link

I tried building this project, exactly as described in README (i copy&pasted the 7 commands), but i got the following linker error:

[ 97%] Linking CXX executable ../../bin/llvm-mctoll
../../lib/libX86Raiser.a(X86MachineInstructionRaiser.cpp.o): In function `X86MachineInstructionRaiser::raiseDirectBranchMachineInstr(ControlTransferInfo*)':
X86MachineInstructionRaiser.cpp:(.text._ZN27X86MachineInstructionRaiser29raiseDirectBranchMachineInstrEP19ControlTransferInfo+0x724): undefined reference to `llvm::MachineInstr::dump() const'
X86MachineInstructionRaiser.cpp:(.text._ZN27X86MachineInstructionRaiser29raiseDirectBranchMachineInstrEP19ControlTransferInfo+0x909): undefined reference to `llvm::MachineInstr::dump() const'
../../lib/libX86Raiser.a(X86MachineInstructionRaiser.cpp.o): In function `X86MachineInstructionRaiser::raiseCompareMachineInstr(llvm::MachineInstr const&, llvm::BasicBlock*, bool, llvm::Value*)':
X86MachineInstructionRaiser.cpp:(.text._ZN27X86MachineInstructionRaiser24raiseCompareMachineInstrERKN4llvm12MachineInstrEPNS0_10BasicBlockEbPNS0_5ValueE+0xb8): undefined reference to `llvm::MachineInstr::dump() const'
X86MachineInstructionRaiser.cpp:(.text._ZN27X86MachineInstructionRaiser24raiseCompareMachineInstrERKN4llvm12MachineInstrEPNS0_10BasicBlockEbPNS0_5ValueE+0x185): undefined reference to `llvm::MachineInstr::dump() const'
../../lib/libX86Raiser.a(X86MachineInstructionRaiser.cpp.o): In function `X86MachineInstructionRaiser::raiseSetCCMachineInstr(llvm::MachineInstr const&, llvm::BasicBlock*)':
X86MachineInstructionRaiser.cpp:(.text._ZN27X86MachineInstructionRaiser22raiseSetCCMachineInstrERKN4llvm12MachineInstrEPNS0_10BasicBlockE+0x18a): undefined reference to `llvm::MachineInstr::dump() const'
../../lib/libX86Raiser.a(X86MachineInstructionRaiser.cpp.o):X86MachineInstructionRaiser.cpp:(.text._ZN27X86MachineInstructionRaiser33raiseBinaryOpImmToRegMachineInstrERKN4llvm12MachineInstrEPNS0_10BasicBlockE+0x1f4): more undefined references to `llvm::MachineInstr::dump() const' follow
CMakeFiles/llvm-mctoll.dir/MCInstRaiser.cpp.o: In function `MCInstRaiser::RaiseMCInst(llvm::MCInstrInfo const&, llvm::MachineFunction&, llvm::MCInst, unsigned long)':
MCInstRaiser.cpp:(.text._ZN12MCInstRaiser11RaiseMCInstERKN4llvm11MCInstrInfoERNS0_15MachineFunctionENS0_6MCInstEm+0x149): undefined reference to `llvm::MCOperand::dump() const'
CMakeFiles/llvm-mctoll.dir/MCInstRaiser.cpp.o: In function `MCInstRaiser::buildCFG(llvm::MachineFunction&, llvm::MCInstrAnalysis const*, llvm::MCInstrInfo const*)':
MCInstRaiser.cpp:(.text._ZN12MCInstRaiser8buildCFGERN4llvm15MachineFunctionEPKNS0_15MCInstrAnalysisEPKNS0_11MCInstrInfoE+0x5db): undefined reference to `llvm::MachineFunction::dump() const'
../../lib/libARMRaiser.a(ARMFunctionPrototype.cpp.o): In function `ARMFunctionPrototype::discover(llvm::MachineFunction&)':
ARMFunctionPrototype.cpp:(.text._ZN20ARMFunctionPrototype8discoverERN4llvm15MachineFunctionE+0x1bc): undefined reference to `llvm::MachineFunction::dump() const'
ARMFunctionPrototype.cpp:(.text._ZN20ARMFunctionPrototype8discoverERN4llvm15MachineFunctionE+0x1c4): undefined reference to `llvm::Value::dump() const'
../../lib/libARMRaiser.a(ARMEliminatePrologEpilog.cpp.o): In function `ARMEliminatePrologEpilog::eliminate()':
ARMEliminatePrologEpilog.cpp:(.text._ZN24ARMEliminatePrologEpilog9eliminateEv+0x95): undefined reference to `llvm::MachineFunction::dump() const'
ARMEliminatePrologEpilog.cpp:(.text._ZN24ARMEliminatePrologEpilog9eliminateEv+0x9e): undefined reference to `llvm::Value::dump() const'
collect2: error: ld returned 1 exit status
tools/llvm-mctoll/CMakeFiles/llvm-mctoll.dir/build.make:545: recipe for target 'bin/llvm-mctoll' failed
make[2]: *** [bin/llvm-mctoll] Error 1
CMakeFiles/Makefile2:62533: recipe for target 'tools/llvm-mctoll/CMakeFiles/llvm-mctoll.dir/all' failed
make[1]: *** [tools/llvm-mctoll/CMakeFiles/llvm-mctoll.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

The important parts being:

undefined reference to `llvm::MachineInstr::dump() const'
undefined reference to `llvm::MachineFunction::dump() const'
undefined reference to `llvm::MCOperand::dump() const'

I believe the problem lies in the step 6 "Run cmake command that you usually use to build llvm", the LLVM have quite a lot of options and i may be missing some that are important.

For example here llvm::MachineInstr::dump and here LLVM_DUMP_METHOD it looks like it strips all dump methods in Release builds, so you probably need to build in Debug mode or add some other option to preserve them in output libs.

Can you please add more information in README about what build arguments are needed in step 6 for succesfull build?

@kozera2137
Copy link

kozera2137 commented Nov 17, 2018

Same problem here, I have tried to use ninja but it doesn't work also.

@Youda008
Copy link
Author

I have solved it by adding -DLLVM_ENABLE_DUMP=ON to cmake command.
It should probably be added to README that llvm has to be build either in Debug mode, or with this parameter.

Also i encountered a second problem, where if your LLVM_TARGETS_TO_BUILD doesn't contain ARM, then you will get another undefined reference to InitializeARMMachineInstructionRaiser. Also should be added to README.

@bharadwajy
Copy link
Contributor

Thanks for reporting this issue. Suggested changes to README.md have been pushed.

Please note that current development is being done using default LLVM (and llvm-mctoll) build - which is Debug build. Release build has not been tested. I'll open an issue to track this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants