Skip to content

Commit 2da4847

Browse files
authored
ensures static linking with llvm >= 4.0 (#889)
it turned out that after `llvm-4.0` a default linking mode is `shared`, and it's not what we want. e.g. debian package will be broken, as `bap` will be depend from `LLVM.so`. our previous request for libraries now returns an extremly short list: ``` ubuntu@ubuntu-xenial:~$ llvm-config-4.0 --libs -lLLVM-4.0 ``` which is just shared library. So what we can do, is to use a new flag for llvm-config: ``` ubuntu@ubuntu-xenial:~$ llvm-config-4.0 --link-static --libs -lLLVMLTO -lLLVMPasses -lLLVMObjCARCOpts -lLLVMMIRParser ... ``` Here it is!
1 parent b1feeee commit 2da4847

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

oasis/llvm.setup.ml.in

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ let llvm var () : unit =
1212
(fun () ->
1313
let llvm_config = BaseEnv.var_get "llvm_config" in
1414
let llvm_version = BaseEnv.var_get "llvm_version" in
15+
let link_mode =
16+
let llvm_static = BaseEnv.var_get "llvm_static" in
17+
if strip_patch llvm_version > "3.8" && llvm_static = "true"
18+
then "--link-static"
19+
else "" in
1520
let extract v =
16-
OASISExec.run_read_one_line ~ctxt llvm_config ["--"^v] in
21+
OASISExec.run_read_one_line ~ctxt llvm_config [link_mode; "--"^v] in
1722
if strip_patch llvm_version > "3.4" && var = "ldflags"
1823
then extract var ^ " " ^ extract "system-libs"
1924
else extract var) |>

0 commit comments

Comments
 (0)