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 elif arch == 'arm-linux': |
| 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 if arch not in ('arm-linux', 'x86-32-linux'): |
| 821 return {} |
| 822 |
| 823 prefix = { |
| 824 'arm-linux': 'arm-linux-gnueabihf-', |
| 825 'x86-32-linux': '', |
| 826 }[arch] |
| 827 arch_cflags = { |
| 828 'arm-linux': ['-mcpu=cortex-a9', '-D__arm_nonsfi_linux__'], |
| 829 'x86-32-linux': ['-m32'], |
| 830 }[arch] |
| 831 |
816 libs = { | 832 libs = { |
817 GSDJoin('unsandboxed_runtime', arch): { | 833 GSDJoin('unsandboxed_runtime', arch): { |
818 'type': TargetLibBuildType(is_canonical), | 834 'type': TargetLibBuildType(is_canonical), |
819 'output_subdir': os.path.join('translator', arch, 'lib'), | 835 'output_subdir': os.path.join('translator', arch, 'lib'), |
820 'dependencies': [ 'subzero_src', 'target_lib_compiler'], | 836 'dependencies': [ 'subzero_src', 'target_lib_compiler'], |
821 # This lib #includes | 837 # This lib #includes |
822 # arbitrary stuff from native_client/src/{include,untrusted,trusted} | 838 # arbitrary stuff from native_client/src/{include,untrusted,trusted} |
823 'inputs': { 'support': os.path.join(NACL_DIR, 'src', 'nonsfi', 'irt'), | 839 'inputs': { 'support': os.path.join(NACL_DIR, 'src', 'nonsfi', 'irt'), |
824 'untrusted': os.path.join( | 840 'untrusted': os.path.join( |
825 NACL_DIR, 'src', 'untrusted', 'irt'), | 841 NACL_DIR, 'src', 'untrusted', 'irt'), |
826 'include': os.path.join(NACL_DIR, 'src'), }, | 842 'include': os.path.join(NACL_DIR, 'src'), }, |
827 'commands': [ | 843 'commands': [ |
828 # The NaCl headers insist on having a platform macro such as | 844 # The NaCl headers insist on having a platform macro such as |
829 # NACL_LINUX defined, but src/nonsfi/irt_interfaces.c does not | 845 # NACL_LINUX defined, but src/nonsfi/irt_interfaces.c does not |
830 # itself use any of these macros, so defining NACL_LINUX here | 846 # itself use any of these macros, so defining NACL_LINUX here |
831 # even on non-Linux systems is OK. | 847 # even on non-Linux systems is OK. |
832 # TODO(dschuff): this include path breaks the input encapsulation | 848 # TODO(dschuff): this include path breaks the input encapsulation |
833 # for build rules. | 849 # for build rules. |
834 command.Command([ | 850 command.Command([prefix + 'gcc'] + arch_cflags + ['-O2', '-Wall', |
835 'gcc', '-m32', '-O2', '-Wall', '-Werror', | 851 '-Werror', '-I%(top_srcdir)s/..', |
836 '-I%(top_srcdir)s/..', '-DNACL_LINUX=1', '-DDEFINE_MAIN', | 852 '-DNACL_LINUX=1', '-DDEFINE_MAIN', |
837 '-c', command.path.join('%(support)s', 'irt_interfaces.c'), | 853 '-c', command.path.join('%(support)s', 'irt_interfaces.c'), |
838 '-o', command.path.join('%(output)s', 'unsandboxed_irt.o')]), | 854 '-o', command.path.join('%(output)s', 'unsandboxed_irt.o')]), |
839 command.Command([ | 855 command.Command([prefix + 'gcc'] + arch_cflags + ['-O2', '-Wall', |
840 'gcc', '-m32', '-O2', '-Wall', '-Werror', | 856 '-Werror', '-I%(top_srcdir)s/..', |
841 '-I%(top_srcdir)s/..', | |
842 '-c', command.path.join('%(support)s', 'irt_random.c'), | 857 '-c', command.path.join('%(support)s', 'irt_random.c'), |
843 '-o', command.path.join('%(output)s', 'irt_random.o')]), | 858 '-o', command.path.join('%(output)s', 'irt_random.o')]), |
844 command.Command([ | 859 command.Command([prefix + 'gcc'] + arch_cflags + ['-O2', '-Wall', |
845 'gcc', '-m32', '-O2', '-Wall', '-Werror', | 860 '-Werror', '-I%(top_srcdir)s/..', |
846 '-I%(top_srcdir)s/..', | |
847 '-c', command.path.join('%(untrusted)s', 'irt_query_list.c'), | 861 '-c', command.path.join('%(untrusted)s', 'irt_query_list.c'), |
848 '-o', command.path.join('%(output)s', 'irt_query_list.o')]), | 862 '-o', command.path.join('%(output)s', 'irt_query_list.o')]), |
849 ] + SubzeroRuntimeCommands(arch, '%(output)s'), | 863 ] + SubzeroRuntimeCommands(arch, '%(output)s'), |
850 }, | 864 }, |
851 } | 865 } |
852 return libs | 866 return libs |
853 | 867 |
854 | 868 |
855 def SDKCompiler(arches): | 869 def SDKCompiler(arches): |
856 arch_packages = ([GSDJoin('newlib', arch) for arch in arches] + | 870 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', | 909 'includedir=' +os.path.join('%(output)s', |
896 TripleFromArch(MultilibArch(arch)), | 910 TripleFromArch(MultilibArch(arch)), |
897 'include'), | 911 'include'), |
898 'libdir=' + os.path.join('%(output)s', MultilibLibDir(arch)), | 912 'libdir=' + os.path.join('%(output)s', MultilibLibDir(arch)), |
899 'install'] + scons_flags, | 913 'install'] + scons_flags, |
900 cwd=NACL_DIR), | 914 cwd=NACL_DIR), |
901 ], | 915 ], |
902 } | 916 } |
903 } | 917 } |
904 return libs | 918 return libs |
OLD | NEW |