From cd2ccf035d5e5abaa3851da5d0ee88ca7cd97d40 Mon Sep 17 00:00:00 2001 From: Mate Soos Date: Fri, 4 Dec 2015 00:05:53 +0000 Subject: Fixing klee-clang to strip all flags not understood by llvm-link --- scripts/klee-clang | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'scripts') 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() - -- cgit 1.4.1