1 #!/usr/bin/env python2 2 3 from collections import namedtuple 4 import glob 5 6 7 # Why have 'cross_headers': 8 # For some reason, clang doesn't know how to find some of the libstdc++ 9 # headers (c++config.h). Manually add in one of the paths: 10 # https://llvm.org/bugs/show_bug.cgi?id=22937 11 # Otherwise, we could assume the system has arm-linux-gnueabihf-g++ and 12 # use that instead of clang, but so far we've just been using clang for 13 # the unsandboxed build. 14 def FindARMCrossInclude(): 15 return glob.glob( 16 '/usr/arm-linux-gnueabihf/include/c++/*/arm-linux-gnueabihf')[-1] 17 18 def FindMIPSCrossInclude(): 19 globs = glob.glob('/usr/mipsel-linux-gnu/include/c++/*/mipsel-linux-gnu') 20 return globs[-1] if globs else '/invalid/mips/include/path' 21 22 TargetInfo = namedtuple('TargetInfo', 23 ['target', 'compiler_arch', 'triple', 'llc_flags', 24 'ld_emu', 'sb_emu', 'cross_headers']) 25 26 X8632Target = TargetInfo(target='x8632', 27 compiler_arch='x8632', 28 triple='i686-none-linux', 29 llc_flags=['-mcpu=pentium4m'], 30 ld_emu='elf_i386_nacl', 31 sb_emu='elf_i386_nacl', 32 cross_headers=[]) 33 34 X8664Target = TargetInfo(target='x8664', 35 compiler_arch='x8664', 36 triple='x86_64-none-linux-gnux32', 37 llc_flags=['-mcpu=x86-64'], 38 ld_emu='elf32_x86_64_nacl', 39 sb_emu='elf_x86_64_nacl', 40 cross_headers=[]) 41 42 ARM32Target = TargetInfo(target='arm32', 43 compiler_arch='armv7', 44 triple='armv7a-none-linux-gnueabihf', 45 llc_flags=['-mcpu=cortex-a9', 46 '-float-abi=hard', 47 '-mattr=+neon', 48 '-arm-enable-dwarf-eh=1'], 49 ld_emu='armelf_nacl', 50 sb_emu='armelf_nacl', 51 cross_headers=['-isystem', FindARMCrossInclude()]) 52 53 # Investigate: 54 # ld_emu script mips_nacl is not present in binutils. How to get it? 55 MIPS32Target = TargetInfo(target='mips32', 56 compiler_arch='mips32', 57 triple='mipsel-linux-gnu', 58 llc_flags=[], 59 ld_emu='mips_nacl', 60 sb_emu='mips_nacl', 61 cross_headers=['-isystem', FindMIPSCrossInclude()]) 62 63 def ConvertTripleToNaCl(nonsfi_triple): 64 return nonsfi_triple[:nonsfi_triple.find('-linux')] + '-nacl' 65