Skip to content

LLVM 13 Support #1385

Closed
Closed
@larkwiot

Description

When installing BAP from opam with LLVM 13 as the system LLVM, a couple things are needed.

  1. bap-llvm errors when building because LLVM internals have changed.
  2. conf-bap-llvm does not find llvm-config, even when it is located under that name in /bin. This can be fixed with the opam set config llvm-config /bin/llvm-config as stated in the wiki, but hopefully once LLVM 13 is supported this will not be necessary.

The error from bap-llvm:

#=== ERROR while compiling bap-llvm.2.3.0 =====================================#                                                                                                                                     
# context     2.1.1 | linux/x86_64 | ocaml-base-compiler.4.09.0 | https://opam.ocaml.org#9cddf6b1                                                                                                                    
# path        ~/.opam/4.09.0/.opam-switch/build/bap-llvm.2.3.0                                                                                                                                                       
# command     ~/.opam/opam-init/hooks/sandbox.sh build make                                                                                                                                                          
# exit-code   2                                                                                                                                                                                                      
# env-file    ~/.opam/log/bap-llvm-164383-193911.env                                                                                                                                                                 
# output-file ~/.opam/log/bap-llvm-164383-193911.out                                                                                                                                                                 
### output ###                                                                                                                                                                                                       
# [...]                                                                                                                                                                                                              
# lib/bap_llvm/llvm_disasm.cpp:521:18: error: no member named 'isFPImm' in 'llvm::MCOperand'                                                                                                                         
#         if (mcop.isFPImm()) {                                                                                                                                                                                      
#             ~~~~ ^                                                                                                                                                                                                 
# lib/bap_llvm/llvm_disasm.cpp:523:31: error: no member named 'getFPImm' in 'llvm::MCOperand'                                                                                                                        
#             op.fmm_val = mcop.getFPImm();                                                                                                                                                                          
#                          ~~~~ ^                                                                                                                                                                                    
# lib/bap_llvm/llvm_disasm.cpp:631:15: error: no member named 'ParseEnvironmentOptions' in namespace 'llvm::cl'                                                                                                      
#     llvm::cl::ParseEnvironmentOptions("bap", "BAP_LLVM_OPTIONS");                                                                                                                                                  
#     ~~~~~~~~~~^                                                                                                                                                                                                    
# 4 errors generated.                                                                                                                                                                                                
# Command exited with code 1.                                                                                                                                                                                        
# make: *** [Makefile:8: build] Error 1

After some grepping around in LLVM source, it seems that isFPImm() was split into two separate functions:

23:16:02 <~/clones/llvm-project/llvm/lib/MC>  11%
<main> »»» rg FPI
MCInst.cpp
33:  else if (isSFPImm())
34:    OS << "SFPImm:" << bit_cast<float>(getSFPImm());
35:  else if (isDFPImm())
36:    OS << "DFPImm:" << bit_cast<double>(getDFPImm());

I am not familiar with BAP internals, but would mcop.isSFPImm() || mcop.isDFPImm() work?

As far as the second part is concerned, a comment in CommandLine.cpp:1307 seems to indicate that cl::ParseCommandLineOptions() is what should be used instead of ParseEnvironentOptions().

I've never messed with BAP internals before, so I'm not making a PR right now. But if I can find the time then maybe I will. Till then, I hope this gives someone more knowledgeable than me a headstart.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions