Beispiel #1
0
def compile_assembly(compiler: Compiler,
                     reporter: Reporter,
                     tests: List[str],
                     config: Config,
                     timeout: Optional[float] = None) -> bool:
    reporter.log('Compiling to assembly', 'title')
    compiler = config.find_compiler() if compiler is None else compiler
    if compiler is None:
        raise RuntimeError("Could not find a suitable compiler")
    compiler = config.common_flags(compiler).add_flag('-O3').add_flag(
        '-S').add_flag('-fverbose-asm')

    rep = reporter.analysis_group('assembly')
    output = rep.compilation(compiler.add_source(
        config.source)).compile(out_file=config.binary)
    if not output.is_success():
        return False

    rep.analyze(open(config.binary, 'r').read())

    return True
Beispiel #2
0
def compile_assembly(compiler: Compiler,
                     reporter: Reporter,
                     tests: List[str],
                     config: Config,
                     timeout: Optional[float] = None) -> bool:
    reporter.log('Compiling to assembly', 'title')
    compiler = config.find_compiler() if compiler is None else compiler
    if compiler is None:
        raise RuntimeError("Could not find a suitable compiler")
    compiler = config.common_flags(compiler).add_flag('-O3').add_flag(
        '-S').add_flag('-fverbose-asm')

    rep = reporter.analysis_group('assembly')
    output = rep.compilation(compiler.add_source(
        config.source)).compile(out_file=config.binary)
    if not output.is_success():
        return False

    assembly = open(config.binary, 'r').read()
    if len(assembly.encode('utf-8')) > MAX_ASSEMBLY_OUTPUT:
        assembly = "Generated assembly was too long and wasn't stored"
    rep.analyze(assembly)

    return True