def RunSandboxedCompiler(use_sz): driver_tools.CheckTranslatorPrerequisites() infile = env.getone('input') is_pnacl = filetype.IsPNaClBitcode(infile) if not is_pnacl and not env.getbool('ALLOW_LLVM_BITCODE_INPUT'): Log.Fatal('Translator expects finalized PNaCl bitcode. ' 'Pass --allow-llvm-bitcode-input to override.') threads = int(env.getone('SPLIT_MODULE')) command = [driver_tools.SelLdrCommand(), '-a', # Allow file access '-E NACL_IRT_PNACL_TRANSLATOR_COMPILE_INPUT=%s' % infile] driver_tools.AddListToEnv(command, 'NACL_IRT_PNACL_TRANSLATOR_COMPILE_OUTPUT', GetObjectFiles(use_sz)) driver_tools.AddListToEnv(command, 'NACL_IRT_PNACL_TRANSLATOR_COMPILE_ARG', BuildOverrideCompilerCommandLine(is_pnacl, use_sz)) command.extend(['-E NACL_IRT_PNACL_TRANSLATOR_COMPILE_THREADS=%d' % threads, '--']) if use_sz: command.append('${PNACL_SZ_SB}') else: command.append('${LLC_SB}') driver_tools.Run(' '.join(command), # stdout/stderr will be automatically dumped # upon failure redirect_stderr=subprocess.PIPE, redirect_stdout=subprocess.PIPE)
def RunLLCSandboxed(): driver_tools.CheckTranslatorPrerequisites() infile = env.getone('input') outfile = env.getone('output') if not driver_tools.IsPNaClBitcode(infile): Log.Fatal('Input to sandboxed translator must be PNaCl bitcode') script = MakeSelUniversalScriptForLLC(infile, outfile) command = ( '${SEL_UNIVERSAL_PREFIX} ${SEL_UNIVERSAL} ${SEL_UNIVERSAL_FLAGS} ' '-- ${LLC_SB}') _, stdout, _ = driver_tools.Run( command, stdin_contents=script, # stdout/stderr will be automatically dumped # upon failure redirect_stderr=subprocess.PIPE, redirect_stdout=subprocess.PIPE) # Get the values returned from the llc RPC to use in input to ld is_shared = re.search(r'output\s+0:\s+i\(([0|1])\)', stdout).group(1) is_shared = (is_shared == '1') soname = re.search(r'output\s+1:\s+s\("(.*)"\)', stdout).group(1) needed_str = re.search(r'output\s+2:\s+s\("(.*)"\)', stdout).group(1) # If the delimiter changes, this line needs to change needed_libs = [lib for lib in needed_str.split(r'\n') if lib] return is_shared, soname, needed_libs
def RunLLCSandboxed(): driver_tools.CheckTranslatorPrerequisites() infile = env.getone('input') outfile = env.getone('output') if not filetype.IsPNaClBitcode(infile): Log.Fatal('Input to sandboxed translator must be PNaCl bitcode') script = MakeSelUniversalScriptForLLC(infile, outfile) command = ( '${SEL_UNIVERSAL_PREFIX} ${SEL_UNIVERSAL} ${SEL_UNIVERSAL_FLAGS} ' '-- ${LLC_SB}') driver_tools.Run( command, stdin_contents=script, # stdout/stderr will be automatically dumped # upon failure redirect_stderr=subprocess.PIPE, redirect_stdout=subprocess.PIPE)
def RunLLCSandboxed(): driver_tools.CheckTranslatorPrerequisites() infile = env.getone('input') outfile = env.getone('output') is_pnacl = filetype.IsPNaClBitcode(infile) if not is_pnacl and not env.getbool('ALLOW_LLVM_BITCODE_INPUT'): Log.Fatal('Translator expects finalized PNaCl bitcode. ' 'Pass --allow-llvm-bitcode-input to override.') script = MakeSelUniversalScriptForLLC(infile, outfile, is_pnacl) command = ( '${SEL_UNIVERSAL_PREFIX} ${SEL_UNIVERSAL} ${SEL_UNIVERSAL_FLAGS} ' '-- ${LLC_SB}') driver_tools.Run( command, stdin_contents=script, # stdout/stderr will be automatically dumped # upon failure redirect_stderr=subprocess.PIPE, redirect_stdout=subprocess.PIPE)