Not an int attribute
yegor256 opened this issue · comments
This is my code:
#include <climits>
#include "klee/klee.h"
int f(int x) {
int a = x * 2;
a = a - 4;
if (a == 0)
return 111;
return 42 / a;
}
int main(int argc, char**) {
int x = 3;
klee_make_symbolic(&x, sizeof(x), "x");
return f(x);
}
I'm doing this:
$ clang -I /opt/homebrew/Cellar/klee/2.3_4/include -c -g -emit-llvm -O0 -Xclang -disable-O0-optnone a.cpp
Then:
$ klee a.bc
KLEE: ERROR: Loading file a.bc failed: Not an int attribute (Producer: 'LLVM15.0.7' Reader: 'LLVM 13.0.1')
What's wrong?
This solved the problem:
$ /opt/homebrew/Cellar/llvm@13/13.0.1_2/bin/clang -I /opt/homebrew/Cellar/klee/2.3_4/include -c -g -emit-llvm -O0 -Xclang -disable-O0-optnone a.cpp
Apparently, brew install klee
installed LLVM 13 on my machine, while LLVM 15 was already installed. Any ideas how I can get rid of two versions of LLVM and make sure KLEE uses LLVM 15?
The most recent released version of KLEE (2.3) IIRC is compatible with LLVM 13, so that's why Homebrew installs it with KLEE.
If you are able to, the simplest path would be to use the LLVM 13 install, as that's what your version of KLEE expects.
If you must have LLVM 15 for some reason, then you can try building KLEE from source. There are some fixes applied to at least support LLVM 14, and perhaps 15 as well, unsure. These fixes would make their way to Homebrew whenever the KLEE team does their next release.
@jryans I understand the problem, thanks for the explanation. As a suggestion, it would be nice if KLEE fails with a more meaningful error message. Something like: "Bitcode version is 15, while version 13 is expected, recompile your sources"
it would be nice if KLEE fails with a more meaningful error message
That's not an error message from KLEE but from LLVM's BitcodeReader and the version mismatch is in the error message: Producer: 'LLVM15.0.7' Reader: 'LLVM 13.0.1'
.
I think we can close this now.