aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorMartinNowack <martin.nowack@gmail.com>2015-12-04 12:21:20 +0100
committerMartinNowack <martin.nowack@gmail.com>2015-12-04 12:21:20 +0100
commiteb4f9b5b6e674530fa1a011889380d0cce76caef (patch)
tree7a03e051e0c2865cd254c273262aeebdefc47e81 /scripts
parent1445935b5e77dc882a686d32c6e629afb899c5b2 (diff)
parentcd2ccf035d5e5abaa3851da5d0ee88ca7cd97d40 (diff)
downloadklee-eb4f9b5b6e674530fa1a011889380d0cce76caef.tar.gz
Merge pull request #310 from msoos/fix-klee-clang-script2
Fixing klee-clang to strip all flags not understood by llvm-link
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/klee-clang41
1 files changed, 31 insertions, 10 deletions
diff --git a/scripts/klee-clang b/scripts/klee-clang
index 2584024d..212bc8ed 100755
--- a/scripts/klee-clang
+++ b/scripts/klee-clang
@@ -2,6 +2,8 @@
import os, sys
import subprocess
+import re
+
def isLinkCommand():
# Look for '-Wl,' as a signal that we are calling the linker. What a hack.
@@ -9,6 +11,19 @@ def isLinkCommand():
if arg.startswith('-Wl,'):
return True
+link_exact_filter = ['-g', '-W', '-O', '-D', '-f',
+ '-fnested-functions', '-pthread', '-fPIC', '-g',
+ '-pedantic', '-shared', '-rdynamic', '-nodefaultlibs']
+
+link_regexp_filter_patts = ['^-Wl.*', '^-l.*', '^-W.*', '^-O\d', '^-gg.*',
+ '^-mtune.*', '^-std=c.*', '^-f.*frame-pointer',
+ '^-fvisibility.*']
+link_regexp_filters = []
+for patt in link_regexp_filter_patts:
+ prog = re.compile(patt)
+ link_regexp_filters.append(prog)
+
+
def main():
llvm_path = subprocess.Popen(["llvm-config", "--bindir"], stdout=subprocess.PIPE).communicate()[0].strip()
@@ -22,23 +37,29 @@ def main():
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,'):
+ a = a.strip()
+ if a in link_exact_filter:
continue
- if a in linkArgs:
- continue
+ match = False
+ for filt in link_regexp_filters:
+ # print "matching %s on filter" % a
+ if filt.match(a):
+ # print "MATCHED %s" % a
+ match = True
+ break
- if a.startswith('-l'):
- continue
+ if match:
+ continue
+
+ if a in linkArgs:
+ continue
linkArgs.append(a)
-
+
os.execvp(llvm_path+"/llvm-link", [llvm_path+"/llvm-link"] + linkArgs)
return 1
+
if __name__ == '__main__':
main()
-