Skip to content

Commit

Permalink
ensures static linking with llvm >= 4.0 (#889)
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
gitoleg authored Oct 10, 2018
1 parent b1feeee commit 2da4847
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion oasis/llvm.setup.ml.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ let llvm var () : unit =
(fun () ->
let llvm_config = BaseEnv.var_get "llvm_config" in
let llvm_version = BaseEnv.var_get "llvm_version" in
let link_mode =
let llvm_static = BaseEnv.var_get "llvm_static" in
if strip_patch llvm_version > "3.8" && llvm_static = "true"
then "--link-static"
else "" in
let extract v =
OASISExec.run_read_one_line ~ctxt llvm_config ["--"^v] in
OASISExec.run_read_one_line ~ctxt llvm_config [link_mode; "--"^v] in
if strip_patch llvm_version > "3.4" && var = "ldflags"
then extract var ^ " " ^ extract "system-libs"
else extract var) |>
Expand Down

0 comments on commit 2da4847

Please sign in to comment.