Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2013 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2013 The Native Client Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Recipes for PNaCl target libs.""" | 6 """Recipes for PNaCl target libs.""" |
| 7 | 7 |
| 8 import fnmatch | 8 import fnmatch |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 623 | 623 |
| 624 When the commands are executed, temporary files are created in the current | 624 When the commands are executed, temporary files are created in the current |
| 625 directory, and .o files are created in the out_dir directory. If arch isn't | 625 directory, and .o files are created in the out_dir directory. If arch isn't |
| 626 among a whitelist, an empty list of commands is returned. | 626 among a whitelist, an empty list of commands is returned. |
| 627 """ | 627 """ |
| 628 # LlcArchArgs contains arguments extracted from pnacl-translate.py. | 628 # LlcArchArgs contains arguments extracted from pnacl-translate.py. |
| 629 if arch == 'x86-32-linux': | 629 if arch == 'x86-32-linux': |
| 630 LlcArchArgs = [ '-mtriple=i686-linux-gnu', '-mcpu=pentium4m'] | 630 LlcArchArgs = [ '-mtriple=i686-linux-gnu', '-mcpu=pentium4m'] |
| 631 elif arch == 'x86-32': | 631 elif arch == 'x86-32': |
| 632 LlcArchArgs = [ '-mtriple=i686-none-nacl-gnu', '-mcpu=pentium4m'] | 632 LlcArchArgs = [ '-mtriple=i686-none-nacl-gnu', '-mcpu=pentium4m'] |
| 633 if arch == 'arm-linux': | |
|
Jim Stichnoth
2015/10/31 16:21:23
elif ?
John
2015/10/31 17:22:24
doh!
| |
| 634 LlcArchArgs = [ '-mtriple=arm-linux-gnu', '-mcpu=cortex-a9'] | |
| 635 elif arch == 'arm': | |
| 636 LlcArchArgs = [ '-mtriple=arm-none-nacl-gnu', '-mcpu=cortex-a9'] | |
| 633 else: | 637 else: |
| 634 return [] | 638 return [] |
| 635 return [ | 639 return [ |
| 636 command.Command([ | 640 command.Command([ |
| 637 PnaclTool('clang'), '-O2', | 641 PnaclTool('clang'), '-O2', |
| 638 '-c', command.path.join('%(subzero_src)s', 'runtime', 'szrt.c'), | 642 '-c', command.path.join('%(subzero_src)s', 'runtime', 'szrt.c'), |
| 639 '-o', 'szrt.tmp.bc']), | 643 '-o', 'szrt.tmp.bc']), |
| 640 command.Command([ | 644 command.Command([ |
| 641 PnaclTool('opt'), '-pnacl-abi-simplify-preopt', | 645 PnaclTool('opt'), '-pnacl-abi-simplify-preopt', |
| 642 '-pnacl-abi-simplify-postopt', '-pnaclabi-allow-debug-metadata', | 646 '-pnacl-abi-simplify-postopt', '-pnaclabi-allow-debug-metadata', |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 806 'unwind-dw2-fde-glibc.o', arch, no_nacl_gcc), | 810 'unwind-dw2-fde-glibc.o', arch, no_nacl_gcc), |
| 807 command.Command([PnaclTool('ar'), 'rc', | 811 command.Command([PnaclTool('ar'), 'rc', |
| 808 command.path.join('%(output)s', 'libgcc_eh.a'), | 812 command.path.join('%(output)s', 'libgcc_eh.a'), |
| 809 'unwind-dw2.o', 'unwind-dw2-fde-glibc.o']), | 813 'unwind-dw2.o', 'unwind-dw2-fde-glibc.o']), |
| 810 ], | 814 ], |
| 811 }, | 815 }, |
| 812 }) | 816 }) |
| 813 return libs | 817 return libs |
| 814 | 818 |
| 815 def UnsandboxedRuntime(arch, is_canonical): | 819 def UnsandboxedRuntime(arch, is_canonical): |
| 820 prefix = { | |
| 821 'arm-linux': 'arm-linux-gnueabihf-', | |
| 822 'x86-32-linux': '', | |
| 823 }[arch] | |
|
Jim Stichnoth
2015/10/31 16:21:23
This fails e.g. when arch='x86-32-mac'. Maybe thi
John
2015/10/31 17:22:24
Done.
| |
| 824 arch_cflags = { | |
| 825 'arm-linux': ['-mcpu=cortex-a9', '-D__arm_nonsfi_linux__'], | |
| 826 'x86-32-linux': ['-m32'], | |
| 827 }[arch] | |
| 828 | |
| 816 libs = { | 829 libs = { |
| 817 GSDJoin('unsandboxed_runtime', arch): { | 830 GSDJoin('unsandboxed_runtime', arch): { |
| 818 'type': TargetLibBuildType(is_canonical), | 831 'type': TargetLibBuildType(is_canonical), |
| 819 'output_subdir': os.path.join('translator', arch, 'lib'), | 832 'output_subdir': os.path.join('translator', arch, 'lib'), |
| 820 'dependencies': [ 'subzero_src', 'target_lib_compiler'], | 833 'dependencies': [ 'subzero_src', 'target_lib_compiler'], |
| 821 # This lib #includes | 834 # This lib #includes |
| 822 # arbitrary stuff from native_client/src/{include,untrusted,trusted} | 835 # arbitrary stuff from native_client/src/{include,untrusted,trusted} |
| 823 'inputs': { 'support': os.path.join(NACL_DIR, 'src', 'nonsfi', 'irt'), | 836 'inputs': { 'support': os.path.join(NACL_DIR, 'src', 'nonsfi', 'irt'), |
| 824 'untrusted': os.path.join( | 837 'untrusted': os.path.join( |
| 825 NACL_DIR, 'src', 'untrusted', 'irt'), | 838 NACL_DIR, 'src', 'untrusted', 'irt'), |
| 826 'include': os.path.join(NACL_DIR, 'src'), }, | 839 'include': os.path.join(NACL_DIR, 'src'), }, |
| 827 'commands': [ | 840 'commands': [ |
| 828 # The NaCl headers insist on having a platform macro such as | 841 # The NaCl headers insist on having a platform macro such as |
| 829 # NACL_LINUX defined, but src/nonsfi/irt_interfaces.c does not | 842 # NACL_LINUX defined, but src/nonsfi/irt_interfaces.c does not |
| 830 # itself use any of these macros, so defining NACL_LINUX here | 843 # itself use any of these macros, so defining NACL_LINUX here |
| 831 # even on non-Linux systems is OK. | 844 # even on non-Linux systems is OK. |
| 832 # TODO(dschuff): this include path breaks the input encapsulation | 845 # TODO(dschuff): this include path breaks the input encapsulation |
| 833 # for build rules. | 846 # for build rules. |
| 834 command.Command([ | 847 command.Command([prefix + 'gcc'] + arch_cflags + ['-O2', '-Wall', |
| 835 'gcc', '-m32', '-O2', '-Wall', '-Werror', | 848 '-Werror', '-I%(top_srcdir)s/..', |
| 836 '-I%(top_srcdir)s/..', '-DNACL_LINUX=1', '-DDEFINE_MAIN', | 849 '-DNACL_LINUX=1', '-DDEFINE_MAIN', |
| 837 '-c', command.path.join('%(support)s', 'irt_interfaces.c'), | 850 '-c', command.path.join('%(support)s', 'irt_interfaces.c'), |
| 838 '-o', command.path.join('%(output)s', 'unsandboxed_irt.o')]), | 851 '-o', command.path.join('%(output)s', 'unsandboxed_irt.o')]), |
| 839 command.Command([ | 852 command.Command([prefix + 'gcc'] + arch_cflags + ['-O2', '-Wall', |
| 840 'gcc', '-m32', '-O2', '-Wall', '-Werror', | 853 '-Werror', '-I%(top_srcdir)s/..', |
| 841 '-I%(top_srcdir)s/..', | |
| 842 '-c', command.path.join('%(support)s', 'irt_random.c'), | 854 '-c', command.path.join('%(support)s', 'irt_random.c'), |
| 843 '-o', command.path.join('%(output)s', 'irt_random.o')]), | 855 '-o', command.path.join('%(output)s', 'irt_random.o')]), |
| 844 command.Command([ | 856 command.Command([prefix + 'gcc'] + arch_cflags + ['-O2', '-Wall', |
| 845 'gcc', '-m32', '-O2', '-Wall', '-Werror', | 857 '-Werror', '-I%(top_srcdir)s/..', |
| 846 '-I%(top_srcdir)s/..', | |
| 847 '-c', command.path.join('%(untrusted)s', 'irt_query_list.c'), | 858 '-c', command.path.join('%(untrusted)s', 'irt_query_list.c'), |
| 848 '-o', command.path.join('%(output)s', 'irt_query_list.o')]), | 859 '-o', command.path.join('%(output)s', 'irt_query_list.o')]), |
| 849 ] + SubzeroRuntimeCommands(arch, '%(output)s'), | 860 ] + SubzeroRuntimeCommands(arch, '%(output)s'), |
| 850 }, | 861 }, |
| 851 } | 862 } |
| 852 return libs | 863 return libs |
| 853 | 864 |
| 854 | 865 |
| 855 def SDKCompiler(arches): | 866 def SDKCompiler(arches): |
| 856 arch_packages = ([GSDJoin('newlib', arch) for arch in arches] + | 867 arch_packages = ([GSDJoin('newlib', arch) for arch in arches] + |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 895 'includedir=' +os.path.join('%(output)s', | 906 'includedir=' +os.path.join('%(output)s', |
| 896 TripleFromArch(MultilibArch(arch)), | 907 TripleFromArch(MultilibArch(arch)), |
| 897 'include'), | 908 'include'), |
| 898 'libdir=' + os.path.join('%(output)s', MultilibLibDir(arch)), | 909 'libdir=' + os.path.join('%(output)s', MultilibLibDir(arch)), |
| 899 'install'] + scons_flags, | 910 'install'] + scons_flags, |
| 900 cwd=NACL_DIR), | 911 cwd=NACL_DIR), |
| 901 ], | 912 ], |
| 902 } | 913 } |
| 903 } | 914 } |
| 904 return libs | 915 return libs |
| OLD | NEW |