about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2015-04-18 23:47:55 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2015-04-18 23:47:55 +0100
commit5f4673e68a5dceb92fb933fa56d04125cb155dfd (patch)
tree1a400a2a971a83fc353e20c50d5f4f3b62aa4b04
parente5ae98b78fcc9259ce0211bdc00852e2f74121ea (diff)
parentab5399ebe814aef1b083b29f82db52cdb3ed9a27 (diff)
downloadklee-5f4673e68a5dceb92fb933fa56d04125cb155dfd.tar.gz
Merge pull request #213 from MartinNowack/klee-clang
Add klee-clang as alternative to klee-gcc
-rwxr-xr-xscripts/klee-clang44
1 files changed, 44 insertions, 0 deletions
diff --git a/scripts/klee-clang b/scripts/klee-clang
new file mode 100755
index 00000000..2584024d
--- /dev/null
+++ b/scripts/klee-clang
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+
+import os, sys
+import subprocess
+
+def isLinkCommand():
+    # Look for '-Wl,' as a signal that we are calling the linker. What a hack.
+    for arg in sys.argv:
+        if arg.startswith('-Wl,'):
+            return True
+
+def main():
+    llvm_path = subprocess.Popen(["llvm-config", "--bindir"], stdout=subprocess.PIPE).communicate()[0].strip()
+
+    if not isLinkCommand():
+        os.execvp(llvm_path+"/clang", ["clang", "-emit-llvm", "-c"] + sys.argv[1:])
+        return 1
+
+    # Otherwise, strip out arguments that llvm-ld doesn't understand. I don't
+    # want my previous explicit declaration of hackyness to imply that this bit
+    # of code here is not also a complete and total hack, it is.
+    args = sys.argv[1:]
+    linkArgs = []
+    for a in args:
+        if a in ('-g', '-W', '-O', '-D', '-f',
+                 '-fnested-functions', '-pthread'):
+            continue
+        elif a.startswith('-Wl,'):
+            continue
+
+	if a in linkArgs:
+	    continue
+
+        if a.startswith('-l'):
+	    continue
+
+        linkArgs.append(a)
+    
+    os.execvp(llvm_path+"/llvm-link", [llvm_path+"/llvm-link"] + linkArgs)
+    return 1
+
+if __name__ == '__main__':
+    main()
+