about summary refs log tree commit diff homepage
path: root/scripts/klee-gcc
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-26 06:35:21 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-26 06:35:21 +0000
commit74480f5d9823df8aed13f9e573f5683da2fe2d19 (patch)
treed93dec385ec10af53ec176a738a3efc6fa6fb3ba /scripts/klee-gcc
parentf8f6c637b24f11703a9991361df8c4260242dbd9 (diff)
downloadklee-74480f5d9823df8aed13f9e573f5683da2fe2d19.tar.gz
Ok, I caved. klee-gcc is useful, at least for now.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@77136 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'scripts/klee-gcc')
-rwxr-xr-xscripts/klee-gcc35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/klee-gcc b/scripts/klee-gcc
new file mode 100755
index 00000000..3ed4c23a
--- /dev/null
+++ b/scripts/klee-gcc
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+
+import os, sys
+
+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():
+    if not isLinkCommand():
+        os.execvp("llvm-gcc", ["llvm-gcc", "-emit-llvm"] + 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
+
+        linkArgs.append(a)
+    
+    os.execvp("llvm-ld", ["llvm-ld", "--disable-opt"] + linkArgs)
+    return 1
+
+if __name__ == '__main__':
+    main()
+