Example #1
0
def getWrapper(realCmd):
    if type(realCmd) == str:
        realCmd = realCmd.split()
    wrapper = CompilerWrapper(realCmd)
    wrapper.computeWrapperCommand()
    # we only want the executable name not the full path
    wrapper.generateIrCommand[0] = os.path.basename(wrapper.generateIrCommand[0])
    return wrapper
Example #2
0
# TODO: rewrite this in C++, the python startup time of ~100-300ms per command really kills ./configure and make

# TODO: do we need to wrap objcopy?

executable = os.path.basename(sys.argv[0])
if executable in ('gcc', 'cc'):
    executable = 'clang'
if executable in ('g++', 'c++'):
    executable = 'clang++'
sys.argv[0] = executable

wrapper = None
if executable in ('clang', 'clang++'):
    # -c -> object file, -S -> generate ASM, -E -> run preprocessor only
    if any(x in sys.argv for x in ("-c", "-S", "-E")):
        wrapper = CompilerWrapper(sys.argv)
    else:
        wrapper = LinkerWrapper(sys.argv)
elif executable == 'ar':
    wrapper = ArWrapper(sys.argv)
elif executable == 'ranlib':
    # ranlib creates an index in the .a file -> we can skip this since we have created a llvm bitcode file
    wrapper = RanlibWrapper(sys.argv)
# direct invocation of the linker: can be ld, gold or lld
elif executable in ('ld', 'lld', 'gold'):
    wrapper = LinkerWrapper(sys.argv)
# we also need to wrap mv, ln and cp commands to make sure that our bitcode files end up in the right dir
elif executable == 'mv':
    wrapper = MvWrapper(sys.argv)
elif executable == 'ln':
    wrapper = LnWrapper(sys.argv)