diff --git a/bap-llvm.opam.template b/bap-llvm.opam.template index 8c3c19a0e..8b7096511 100644 --- a/bap-llvm.opam.template +++ b/bap-llvm.opam.template @@ -3,6 +3,7 @@ build: [ [ "ocaml" "tools/configure.ml" "--with-llvm-config=%{conf-bap-llvm:config}%" + "--%{llvm-shared?disable:enable}%-llvm-static" ] [ "dune" diff --git a/lib/bap_llvm/config/llvm_configurator.ml b/lib/bap_llvm/config/llvm_configurator.ml index 5496cd076..961feabd3 100644 --- a/lib/bap_llvm/config/llvm_configurator.ml +++ b/lib/bap_llvm/config/llvm_configurator.ml @@ -30,9 +30,13 @@ let args = [ let () = C.main ~args ~name:"bap-llvm" @@ fun self -> + let linkmode = + "--link-" ^ + (String.strip @@ + C.Process.run_capture_exn self llvm_config ["--shared-mode"]) in C.Flags.write_sexp "link.flags" @@ List.concat [ - llvm self ["--link-static"; "--ldflags"]; - llvm self (["--link-static"; "--libs"] @ llvm_components); + llvm self [linkmode; "--ldflags"]; + llvm self ([linkmode; "--libs"] @ llvm_components); ["-lstdc++"; "-lcurses"; "-lzstd"]; ]; C.Flags.write_sexp "cxx.flags" @@ List.concat [ diff --git a/lib/bap_llvm/llvm_disasm.cpp b/lib/bap_llvm/llvm_disasm.cpp index 41f9bb64f..dad0f52ab 100644 --- a/lib/bap_llvm/llvm_disasm.cpp +++ b/lib/bap_llvm/llvm_disasm.cpp @@ -12,6 +12,9 @@ #if LLVM_VERSION_MAJOR >= 12 #include #include +#if LLVM_VERSION_MAJOR <= 16 +#include +#endif #endif #include