| 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 |
| 11 | 11 |
| 12 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 12 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 13 import pynacl.gsd_storage | 13 import pynacl.gsd_storage |
| 14 import pynacl.platform | 14 import pynacl.platform |
| 15 | 15 |
| 16 import command | 16 import command |
| 17 import pnacl_commands | 17 import pnacl_commands |
| 18 | 18 |
| 19 | 19 |
| 20 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 20 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 21 NACL_DIR = os.path.dirname(SCRIPT_DIR) | 21 NACL_DIR = os.path.dirname(SCRIPT_DIR) |
| 22 | 22 |
| 23 CLANG_VER = '3.4' |
| 23 | 24 |
| 24 # Return the path to the local copy of the driver script. | 25 # Return the path to the local copy of the driver script. |
| 25 # msys should be false if the path will be called directly rather than passed to | 26 # msys should be false if the path will be called directly rather than passed to |
| 26 # an msys or cygwin tool such as sh or make. | 27 # an msys or cygwin tool such as sh or make. |
| 27 def PnaclTool(toolname, msys=True): | 28 def PnaclTool(toolname, msys=True): |
| 28 if not msys and pynacl.platform.IsWindows(): | 29 if not msys and pynacl.platform.IsWindows(): |
| 29 ext = '.bat' | 30 ext = '.bat' |
| 30 else: | 31 else: |
| 31 ext = '' | 32 ext = '' |
| 32 return command.path.join('%(abs_target_lib_compiler)s', | 33 return command.path.join('%(abs_target_lib_compiler)s', |
| (...skipping 12 matching lines...) Expand all Loading... |
| 45 if not pynacl.platform.IsWindows(): | 46 if not pynacl.platform.IsWindows(): |
| 46 # The make that ships with msys sometimes hangs when run with -j. | 47 # The make that ships with msys sometimes hangs when run with -j. |
| 47 # The ming32-make that comes with the compiler itself reportedly doesn't | 48 # The ming32-make that comes with the compiler itself reportedly doesn't |
| 48 # have this problem, but it has issues with pathnames with LLVM's build. | 49 # have this problem, but it has issues with pathnames with LLVM's build. |
| 49 make_command.append('-j%(cores)s') | 50 make_command.append('-j%(cores)s') |
| 50 return make_command | 51 return make_command |
| 51 | 52 |
| 52 # Return the component name to use for a component name with | 53 # Return the component name to use for a component name with |
| 53 # a host triple. GNU configuration triples contain dashes, which are converted | 54 # a host triple. GNU configuration triples contain dashes, which are converted |
| 54 # to underscores so the names are legal for Google Storage. | 55 # to underscores so the names are legal for Google Storage. |
| 55 def Mangle(component_name, extra): | 56 def GSDJoin(*args): |
| 56 return component_name + '_' + pynacl.gsd_storage.LegalizeName(extra) | 57 return '_'.join([pynacl.gsd_storage.LegalizeName(arg) for arg in args]) |
| 57 | 58 |
| 58 | 59 |
| 59 # Copy the compiled bitcode archives used for linking C programs into the the | 60 # Copy the compiled bitcode archives used for linking C programs into the the |
| 60 # current working directory. This allows the driver in the working directory to | 61 # current working directory. This allows the driver in the working directory to |
| 61 # be used in cases which need the ability to link pexes (e.g. CMake | 62 # be used in cases which need the ability to link pexes (e.g. CMake |
| 62 # try-compiles, LLVM testsuite, or libc++ testsuite). For now this also requires | 63 # try-compiles, LLVM testsuite, or libc++ testsuite). For now this also requires |
| 63 # a build of libnacl however, which is driven by the buildbot script or | 64 # a build of libnacl however, which is driven by the buildbot script or |
| 64 # external test script. TODO(dschuff): add support to drive the LLVM and libcxx | 65 # external test script. TODO(dschuff): add support to drive the LLVM and libcxx |
| 65 # test suites from toolchain_build rules. | 66 # test suites from toolchain_build rules. |
| 66 def CopyBitcodeCLibs(bias_arch): | 67 def CopyBitcodeCLibs(bias_arch): |
| 67 return [ | 68 return [ |
| 68 command.RemoveDirectory('usr'), | 69 command.RemoveDirectory('usr'), |
| 69 command.Mkdir('usr'), | 70 command.Mkdir('usr'), |
| 70 command.Command('cp -r %(' + | 71 command.Command('cp -r %(' + |
| 71 Mangle('abs_libs_support_bitcode', bias_arch) + | 72 GSDJoin('abs_libs_support_bitcode', bias_arch) + |
| 72 ')s usr', shell=True), | 73 ')s usr', shell=True), |
| 73 command.Command('cp -r %(' + Mangle('abs_newlib', bias_arch) + | 74 command.Command('cp -r %(' + GSDJoin('abs_newlib', bias_arch) + |
| 74 ')s/* usr', shell=True), | 75 ')s/* usr', shell=True), |
| 75 ] | 76 ] |
| 76 | 77 |
| 77 | 78 |
| 79 def BiasedBitcodeTriple(bias_arch): |
| 80 return 'le32-nacl' if bias_arch == 'le32' else bias_arch + '_bc-nacl' |
| 81 |
| 78 def BiasedBitcodeTargetFlag(arch): | 82 def BiasedBitcodeTargetFlag(arch): |
| 79 flagmap = { | 83 flagmap = { |
| 80 # Arch Target Extra flags. | 84 # Arch Target Extra flags. |
| 81 'x86-64': ('x86_64-unknown-nacl', []), | 85 'x86-64': ('x86_64-unknown-nacl', []), |
| 82 'x86-32': ('i686-unknown-nacl', []), | 86 'x86-32': ('i686-unknown-nacl', []), |
| 83 'arm': ('armv7-unknown-nacl-gnueabihf', ['-mfloat-abi=hard']), | 87 'arm': ('armv7-unknown-nacl-gnueabihf', ['-mfloat-abi=hard']), |
| 84 # MIPS doesn't use biased bitcode: | 88 # MIPS doesn't use biased bitcode: |
| 85 'mips32': ('le32-unknown-nacl', []), | 89 'mips32': ('le32-unknown-nacl', []), |
| 86 } | 90 } |
| 87 return ['--target=%s' % flagmap[arch][0]] + flagmap[arch][1] | 91 return ['--target=%s' % flagmap[arch][0]] + flagmap[arch][1] |
| 88 | 92 |
| 89 | 93 |
| 90 def TargetBCLibCflags(bias_arch): | 94 def TargetBCLibCflags(bias_arch): |
| 91 flags = '-g -O2 -mllvm -inline-threshold=5' | 95 flags = '-g -O2 -mllvm -inline-threshold=5' |
| 92 if bias_arch != 'portable': | 96 if bias_arch != 'le32': |
| 93 flags += ' ' + ' '.join(BiasedBitcodeTargetFlag(bias_arch)) | 97 flags += ' ' + ' '.join(BiasedBitcodeTargetFlag(bias_arch)) |
| 94 return flags | 98 return flags |
| 95 | 99 |
| 96 def NewlibIsystemCflags(bias_arch): | 100 def NewlibIsystemCflags(bias_arch): |
| 97 return ' '.join([ | 101 return ' '.join([ |
| 98 '-isystem', | 102 '-isystem', |
| 99 command.path.join('%(' + Mangle('abs_newlib', bias_arch) +')s', 'include')]) | 103 command.path.join('%(' + GSDJoin('abs_newlib', bias_arch) +')s', |
| 104 BiasedBitcodeTriple(bias_arch), 'include')]) |
| 100 | 105 |
| 101 def LibCxxCflags(bias_arch): | 106 def LibCxxCflags(bias_arch): |
| 102 # HAS_THREAD_LOCAL is used by libc++abi's exception storage, the fallback is | 107 # HAS_THREAD_LOCAL is used by libc++abi's exception storage, the fallback is |
| 103 # pthread otherwise. | 108 # pthread otherwise. |
| 104 return ' '.join([TargetBCLibCflags(bias_arch), NewlibIsystemCflags(bias_arch), | 109 return ' '.join([TargetBCLibCflags(bias_arch), NewlibIsystemCflags(bias_arch), |
| 105 '-DHAS_THREAD_LOCAL=1']) | 110 '-DHAS_THREAD_LOCAL=1']) |
| 106 | 111 |
| 107 | 112 |
| 108 def LibStdcxxCflags(bias_arch): | 113 def LibStdcxxCflags(bias_arch): |
| 109 return ' '.join([TargetBCLibCflags(bias_arch), | 114 return ' '.join([TargetBCLibCflags(bias_arch), |
| 110 NewlibIsystemCflags(bias_arch)]) | 115 NewlibIsystemCflags(bias_arch)]) |
| 111 | 116 |
| 112 | 117 |
| 113 # Build a single object file as bitcode. | 118 # Build a single object file as bitcode. |
| 114 def BuildTargetBitcodeCmd(source, output, bias_arch, output_dir='%(cwd)s'): | 119 def BuildTargetBitcodeCmd(source, output, bias_arch, output_dir='%(cwd)s'): |
| 115 flags = ['-Wall', '-Werror', '-O2', '-c'] | 120 flags = ['-Wall', '-Werror', '-O2', '-c'] |
| 116 if bias_arch != 'portable': | 121 if bias_arch != 'le32': |
| 117 [flags.append(flag) for flag in BiasedBitcodeTargetFlag(bias_arch)] | 122 flags.extend(BiasedBitcodeTargetFlag(bias_arch)) |
| 118 sysinclude = Mangle('newlib', bias_arch) | 123 flags.extend(NewlibIsystemCflags(bias_arch).split()) |
| 119 return command.Command( | 124 return command.Command( |
| 120 [PnaclTool('clang', msys=False)] + flags + [ | 125 [PnaclTool('clang', msys=False)] + flags + [ |
| 121 '-isystem', '%(' + sysinclude + ')s/include', | 126 command.path.join('%(src)s', source), |
| 122 command.path.join('%(src)s', source), | |
| 123 '-o', command.path.join(output_dir, output)]) | 127 '-o', command.path.join(output_dir, output)]) |
| 124 | 128 |
| 125 | 129 |
| 126 # Build a single object file as native code. | 130 # Build a single object file as native code. |
| 127 def BuildTargetNativeCmd(sourcefile, output, arch, extra_flags=[], | 131 def BuildTargetNativeCmd(sourcefile, output, arch, extra_flags=[], |
| 128 source_dir='%(src)s', output_dir='%(cwd)s'): | 132 source_dir='%(src)s', output_dir='%(cwd)s'): |
| 129 return command.Command( | 133 return command.Command( |
| 130 [PnaclTool('clang', msys=False), | 134 [PnaclTool('clang', msys=False), |
| 131 '--pnacl-allow-native', '--pnacl-allow-translate', '-Wall', '-Werror', | 135 '--pnacl-allow-native', '--pnacl-allow-translate', '-Wall', '-Werror', |
| 132 '-arch', arch, '--pnacl-bias=' + arch, '-O3', | 136 '-arch', arch, '--pnacl-bias=' + arch, '-O3', |
| 133 # TODO(dschuff): this include breaks the input encapsulation for build | 137 # TODO(dschuff): this include breaks the input encapsulation for build |
| 134 # rules. | 138 # rules. |
| 135 '-I%(top_srcdir)s/..', '-isystem', '%(newlib_portable)s/include', '-c'] + | 139 '-I%(top_srcdir)s/..','-c'] + |
| 140 NewlibIsystemCflags('le32').split() + |
| 136 extra_flags + | 141 extra_flags + |
| 137 [command.path.join(source_dir, sourcefile), | 142 [command.path.join(source_dir, sourcefile), |
| 138 '-o', command.path.join(output_dir, output)]) | 143 '-o', command.path.join(output_dir, output)]) |
| 139 | 144 |
| 140 | 145 |
| 141 def BuildLibgccEhCmd(sourcefile, output, arch): | 146 def BuildLibgccEhCmd(sourcefile, output, arch): |
| 142 # Return a command to compile a file from libgcc_eh (see comments in at the | 147 # Return a command to compile a file from libgcc_eh (see comments in at the |
| 143 # rule definition below). | 148 # rule definition below). |
| 144 flags_common = ['-DENABLE_RUNTIME_CHECKING', '-g', '-O2', '-W', '-Wall', | 149 flags_common = ['-DENABLE_RUNTIME_CHECKING', '-g', '-O2', '-W', '-Wall', |
| 145 '-Wwrite-strings', '-Wcast-qual', '-Wstrict-prototypes', | 150 '-Wwrite-strings', '-Wcast-qual', '-Wstrict-prototypes', |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 'type': 'source', | 232 'type': 'source', |
| 228 'output_dirname': 'pnacl-gcc', | 233 'output_dirname': 'pnacl-gcc', |
| 229 'commands': GitSyncCmds('gcc'), | 234 'commands': GitSyncCmds('gcc'), |
| 230 }, | 235 }, |
| 231 } | 236 } |
| 232 return source | 237 return source |
| 233 | 238 |
| 234 | 239 |
| 235 def BitcodeLibs(bias_arch, is_canonical): | 240 def BitcodeLibs(bias_arch, is_canonical): |
| 236 def B(component_name): | 241 def B(component_name): |
| 237 return Mangle(component_name, bias_arch) | 242 return GSDJoin(component_name, bias_arch) |
| 238 def BcSubdir(subdir, bias_arch): | 243 bc_triple = BiasedBitcodeTriple(bias_arch) |
| 239 if bias_arch == 'portable': | 244 |
| 240 return subdir | |
| 241 else: | |
| 242 return subdir + '-bc-' + bias_arch | |
| 243 libs = { | 245 libs = { |
| 244 B('newlib'): { | 246 B('newlib'): { |
| 245 'type': 'build' if is_canonical else 'work', | 247 'type': 'build' if is_canonical else 'work', |
| 246 'output_subdir': BcSubdir('usr', bias_arch), | |
| 247 'dependencies': [ 'newlib_src', 'target_lib_compiler'], | 248 'dependencies': [ 'newlib_src', 'target_lib_compiler'], |
| 248 'commands' : [ | 249 'commands' : [ |
| 249 command.SkipForIncrementalCommand( | 250 command.SkipForIncrementalCommand( |
| 250 ['sh', '%(newlib_src)s/configure'] + | 251 ['sh', '%(newlib_src)s/configure'] + |
| 251 TARGET_TOOLS + | 252 TARGET_TOOLS + |
| 252 ['CFLAGS_FOR_TARGET=' + TargetBCLibCflags(bias_arch) + | 253 ['CFLAGS_FOR_TARGET=' + TargetBCLibCflags(bias_arch) + |
| 253 ' -allow-asm', | 254 ' -allow-asm', |
| 254 '--disable-multilib', | 255 '--disable-multilib', |
| 255 '--prefix=', | 256 '--prefix=', |
| 256 '--disable-newlib-supplied-syscalls', | 257 '--disable-newlib-supplied-syscalls', |
| 257 '--disable-texinfo', | 258 '--disable-texinfo', |
| 258 '--disable-libgloss', | 259 '--disable-libgloss', |
| 259 '--enable-newlib-iconv', | 260 '--enable-newlib-iconv', |
| 260 '--enable-newlib-iconv-from-encodings=' + | 261 '--enable-newlib-iconv-from-encodings=' + |
| 261 'UTF-8,UTF-16LE,UCS-4LE,UTF-16,UCS-4', | 262 'UTF-8,UTF-16LE,UCS-4LE,UTF-16,UCS-4', |
| 262 '--enable-newlib-iconv-to-encodings=' + | 263 '--enable-newlib-iconv-to-encodings=' + |
| 263 'UTF-8,UTF-16LE,UCS-4LE,UTF-16,UCS-4', | 264 'UTF-8,UTF-16LE,UCS-4LE,UTF-16,UCS-4', |
| 264 '--enable-newlib-io-long-long', | 265 '--enable-newlib-io-long-long', |
| 265 '--enable-newlib-io-long-double', | 266 '--enable-newlib-io-long-double', |
| 266 '--enable-newlib-io-c99-formats', | 267 '--enable-newlib-io-c99-formats', |
| 267 '--enable-newlib-mb', | 268 '--enable-newlib-mb', |
| 268 '--target=le32-nacl' | 269 '--target=le32-nacl' |
| 269 ]), | 270 ]), |
| 270 command.Command(MakeCommand()), | 271 command.Command(MakeCommand()), |
| 271 command.Command(['make', 'DESTDIR=%(abs_output)s', 'install']), | 272 command.Command(['make', 'DESTDIR=%(abs_output)s', 'install']), |
| 272 command.CopyTree(command.path.join('%(output)s', 'le32-nacl', | 273 # We configured newlib with target=le32-nacl to get its pure C |
| 273 'lib'), | 274 # implementation, so rename its output dir (which matches the |
| 274 command.path.join('%(output)s', 'lib')), | 275 # target to the output dir for the package we are building) |
| 275 command.CopyTree( | 276 command.Rename(os.path.join('%(output)s', 'le32-nacl'), |
| 276 command.path.join('%(output)s','le32-nacl', 'include'), | 277 os.path.join('%(output)s', bc_triple)), |
| 277 command.path.join('%(output)s','include')), | |
| 278 command.RemoveDirectory(command.path.join('%(output)s', | |
| 279 'le32-nacl')), | |
| 280 command.Mkdir(os.path.join('%(output)s', 'include', 'nacl')), | |
| 281 # Copy nacl_random.h, used by libc++. It uses the IRT, so should | 278 # Copy nacl_random.h, used by libc++. It uses the IRT, so should |
| 282 # be safe to include in the toolchain. | 279 # be safe to include in the toolchain. |
| 280 command.Mkdir( |
| 281 os.path.join('%(output)s', bc_triple, 'include', 'nacl')), |
| 283 command.Copy(os.path.join('%(top_srcdir)s', 'src', 'untrusted', | 282 command.Copy(os.path.join('%(top_srcdir)s', 'src', 'untrusted', |
| 284 'nacl', 'nacl_random.h'), | 283 'nacl', 'nacl_random.h'), |
| 285 os.path.join('%(output)s', 'include', 'nacl', | 284 os.path.join( |
| 286 'nacl_random.h')), | 285 '%(output)s', bc_triple, 'include', 'nacl', |
| 286 'nacl_random.h')), |
| 287 # Remove the 'share' directory from the biased builds; the data is |
| 288 # duplicated exactly and takes up 2MB per package. |
| 289 command.RemoveDirectory(os.path.join('%(output)s', 'share'), |
| 290 run_cond = lambda x: bias_arch != 'le32'), |
| 287 ], | 291 ], |
| 288 }, | 292 }, |
| 289 B('libcxx'): { | 293 B('libcxx'): { |
| 290 'type': 'build' if is_canonical else 'work', | 294 'type': 'build' if is_canonical else 'work', |
| 291 'output_subdir': BcSubdir('usr', bias_arch), | |
| 292 'dependencies': ['libcxx_src', 'libcxxabi_src', 'llvm_src', 'gcc_src', | 295 'dependencies': ['libcxx_src', 'libcxxabi_src', 'llvm_src', 'gcc_src', |
| 293 'target_lib_compiler', B('newlib'), | 296 'target_lib_compiler', B('newlib'), |
| 294 B('libs_support_bitcode')], | 297 B('libs_support_bitcode')], |
| 295 'commands' : | 298 'commands' : |
| 296 CopyBitcodeCLibs(bias_arch) + [ | 299 CopyBitcodeCLibs(bias_arch) + [ |
| 297 command.SkipForIncrementalCommand( | 300 command.SkipForIncrementalCommand( |
| 298 ['cmake', '-G', 'Unix Makefiles', | 301 ['cmake', '-G', 'Unix Makefiles', |
| 299 '-DCMAKE_C_COMPILER_WORKS=1', | 302 '-DCMAKE_C_COMPILER_WORKS=1', |
| 300 '-DCMAKE_CXX_COMPILER_WORKS=1', | 303 '-DCMAKE_CXX_COMPILER_WORKS=1', |
| 301 '-DCMAKE_INSTALL_PREFIX=', | 304 '-DCMAKE_INSTALL_PREFIX=', |
| (...skipping 23 matching lines...) Expand all Loading... |
| 325 '-DLIBCXX_ENABLE_CXX0X=0', | 328 '-DLIBCXX_ENABLE_CXX0X=0', |
| 326 '-DLIBCXX_ENABLE_SHARED=0', | 329 '-DLIBCXX_ENABLE_SHARED=0', |
| 327 '-DLIBCXX_CXX_ABI=libcxxabi', | 330 '-DLIBCXX_CXX_ABI=libcxxabi', |
| 328 '-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=' + command.path.join( | 331 '-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=' + command.path.join( |
| 329 '%(abs_libcxxabi_src)s', 'include'), | 332 '%(abs_libcxxabi_src)s', 'include'), |
| 330 '%(libcxx_src)s']), | 333 '%(libcxx_src)s']), |
| 331 command.Copy(os.path.join('%(gcc_src)s', 'gcc', | 334 command.Copy(os.path.join('%(gcc_src)s', 'gcc', |
| 332 'unwind-generic.h'), | 335 'unwind-generic.h'), |
| 333 os.path.join('include', 'unwind.h')), | 336 os.path.join('include', 'unwind.h')), |
| 334 command.Command(MakeCommand() + ['VERBOSE=1']), | 337 command.Command(MakeCommand() + ['VERBOSE=1']), |
| 335 command.Command(['make', 'DESTDIR=%(abs_output)s', 'VERBOSE=1', | 338 command.Command([ |
| 336 'install']), | 339 'make', |
| 340 'DESTDIR=' + os.path.join('%(abs_output)s', bc_triple), |
| 341 'VERBOSE=1', |
| 342 'install']), |
| 337 ], | 343 ], |
| 338 }, | 344 }, |
| 339 B('libstdcxx'): { | 345 B('libstdcxx'): { |
| 340 'type': 'build' if is_canonical else 'work', | 346 'type': 'build' if is_canonical else 'work', |
| 341 'output_subdir': BcSubdir('usr', bias_arch), | |
| 342 'dependencies': ['gcc_src', 'gcc_src', 'target_lib_compiler', | 347 'dependencies': ['gcc_src', 'gcc_src', 'target_lib_compiler', |
| 343 B('newlib')], | 348 B('newlib')], |
| 344 'commands' : [ | 349 'commands' : [ |
| 345 command.SkipForIncrementalCommand([ | 350 command.SkipForIncrementalCommand([ |
| 346 'sh', | 351 'sh', |
| 347 command.path.join('%(gcc_src)s', 'libstdc++-v3', | 352 command.path.join('%(gcc_src)s', 'libstdc++-v3', |
| 348 'configure')] + | 353 'configure')] + |
| 349 TARGET_TOOLS + [ | 354 TARGET_TOOLS + [ |
| 350 'CC_FOR_BUILD=cc', | 355 'CC_FOR_BUILD=cc', |
| 351 'CC=' + PnaclTool('clang'), | 356 'CC=' + PnaclTool('clang'), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 368 '--disable-libstdcxx-time', | 373 '--disable-libstdcxx-time', |
| 369 '--disable-sjlj-exceptions', | 374 '--disable-sjlj-exceptions', |
| 370 '--disable-libstdcxx-pch', | 375 '--disable-libstdcxx-pch', |
| 371 '--with-newlib', | 376 '--with-newlib', |
| 372 '--disable-shared', | 377 '--disable-shared', |
| 373 '--disable-rpath']), | 378 '--disable-rpath']), |
| 374 command.Copy(os.path.join('%(gcc_src)s', 'gcc', | 379 command.Copy(os.path.join('%(gcc_src)s', 'gcc', |
| 375 'unwind-generic.h'), | 380 'unwind-generic.h'), |
| 376 os.path.join('include', 'unwind.h')), | 381 os.path.join('include', 'unwind.h')), |
| 377 command.Command(MakeCommand()), | 382 command.Command(MakeCommand()), |
| 378 command.Command(['make', 'DESTDIR=%(abs_output)s', | 383 command.Command([ |
| 379 'install-data']), | 384 'make', |
| 380 command.RemoveDirectory(os.path.join('%(output)s', 'share')), | 385 'DESTDIR=' + os.path.join('%(abs_output)s', bc_triple), |
| 381 command.Remove(os.path.join('%(output)s', 'lib', | 386 'install-data']), |
| 387 command.RemoveDirectory( |
| 388 os.path.join('%(output)s', bc_triple, 'share')), |
| 389 command.Remove(os.path.join('%(output)s', bc_triple, 'lib', |
| 382 'libstdc++*-gdb.py')), | 390 'libstdc++*-gdb.py')), |
| 383 command.Copy(os.path.join('src', '.libs', 'libstdc++.a'), | 391 command.Copy( |
| 384 os.path.join('%(output)s', 'lib', 'libstdc++.a')), | 392 os.path.join('src', '.libs', 'libstdc++.a'), |
| 393 os.path.join('%(output)s', bc_triple, 'lib', 'libstdc++.a')), |
| 385 ], | 394 ], |
| 386 }, | 395 }, |
| 387 B('libs_support_bitcode'): { | 396 B('libs_support_bitcode'): { |
| 388 'type': 'build' if is_canonical else 'work', | 397 'type': 'build' if is_canonical else 'work', |
| 389 'output_subdir': BcSubdir('lib', bias_arch), | 398 'output_subdir': os.path.join( |
| 399 'lib', 'clang', CLANG_VER, 'lib', bc_triple), |
| 390 'dependencies': [ B('newlib'), 'target_lib_compiler'], | 400 'dependencies': [ B('newlib'), 'target_lib_compiler'], |
| 391 'inputs': { 'src': os.path.join(NACL_DIR, | 401 'inputs': { 'src': os.path.join(NACL_DIR, |
| 392 'pnacl', 'support', 'bitcode')}, | 402 'pnacl', 'support', 'bitcode')}, |
| 393 'commands': [ | 403 'commands': [ |
| 394 # Two versions of crt1.x exist, for different scenarios (with and | 404 # Two versions of crt1.x exist, for different scenarios (with and |
| 395 # without EH). See: | 405 # without EH). See: |
| 396 # https://code.google.com/p/nativeclient/issues/detail?id=3069 | 406 # https://code.google.com/p/nativeclient/issues/detail?id=3069 |
| 397 command.Copy(command.path.join('%(src)s', 'crt1.x'), | 407 command.Copy(command.path.join('%(src)s', 'crt1.x'), |
| 398 command.path.join('%(output)s', 'crt1.x')), | 408 command.path.join('%(output)s', 'crt1.x')), |
| 399 command.Copy(command.path.join('%(src)s', 'crt1_for_eh.x'), | 409 command.Copy(command.path.join('%(src)s', 'crt1_for_eh.x'), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 elif arch == 'x86-32-nonsfi': | 445 elif arch == 'x86-32-nonsfi': |
| 436 arch_cmds.extend( | 446 arch_cmds.extend( |
| 437 [BuildTargetNativeCmd('entry_linux.c', 'entry_linux.o', arch), | 447 [BuildTargetNativeCmd('entry_linux.c', 'entry_linux.o', arch), |
| 438 BuildTargetNativeCmd('entry_linux_x86_32.S', 'entry_linux_asm.o', | 448 BuildTargetNativeCmd('entry_linux_x86_32.S', 'entry_linux_asm.o', |
| 439 arch)]) | 449 arch)]) |
| 440 elif arch == 'arm-nonsfi': | 450 elif arch == 'arm-nonsfi': |
| 441 arch_cmds.extend( | 451 arch_cmds.extend( |
| 442 [BuildTargetNativeCmd('entry_linux.c', 'entry_linux.o', arch), | 452 [BuildTargetNativeCmd('entry_linux.c', 'entry_linux.o', arch), |
| 443 BuildTargetNativeCmd('entry_linux_arm.S', 'entry_linux_asm.o', | 453 BuildTargetNativeCmd('entry_linux_arm.S', 'entry_linux_asm.o', |
| 444 arch)]) | 454 arch)]) |
| 455 native_lib_dir = os.path.join('translator', arch, 'lib') |
| 445 | 456 |
| 446 libs = { | 457 libs = { |
| 447 Mangle('libs_support_native', arch): { | 458 GSDJoin('libs_support_native', arch): { |
| 448 'type': 'build' if is_canonical else 'work', | 459 'type': 'build' if is_canonical else 'work', |
| 449 'output_subdir': 'lib-' + arch, | 460 'output_subdir': native_lib_dir, |
| 450 'dependencies': [ 'newlib_src', 'newlib_portable', | 461 'dependencies': [ 'newlib_src', 'newlib_le32', |
| 451 'target_lib_compiler'], | 462 'target_lib_compiler'], |
| 452 # These libs include | 463 # These libs include |
| 453 # arbitrary stuff from native_client/src/{include,untrusted,trusted} | 464 # arbitrary stuff from native_client/src/{include,untrusted,trusted} |
| 454 'inputs': { 'src': os.path.join(NACL_DIR, 'pnacl', 'support'), | 465 'inputs': { 'src': os.path.join(NACL_DIR, 'pnacl', 'support'), |
| 455 'include': os.path.join(NACL_DIR, 'src'), | 466 'include': os.path.join(NACL_DIR, 'src'), |
| 456 'newlib_subset': os.path.join( | 467 'newlib_subset': os.path.join( |
| 457 NACL_DIR, 'src', 'third_party', | 468 NACL_DIR, 'src', 'third_party', |
| 458 'pnacl_native_newlib_subset')}, | 469 'pnacl_native_newlib_subset')}, |
| 459 'commands': [ | 470 'commands': [ |
| 460 BuildTargetNativeCmd('crtbegin.c', 'crtbegin.o', arch, | 471 BuildTargetNativeCmd('crtbegin.c', 'crtbegin.o', arch, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 '*.o']), shell=True), | 503 '*.o']), shell=True), |
| 493 # Dummy IRT shim | 504 # Dummy IRT shim |
| 494 BuildTargetNativeCmd('dummy_shim_entry.c', 'dummy_shim_entry.o', | 505 BuildTargetNativeCmd('dummy_shim_entry.c', 'dummy_shim_entry.o', |
| 495 arch), | 506 arch), |
| 496 command.Command([PnaclTool('ar'), 'rc', | 507 command.Command([PnaclTool('ar'), 'rc', |
| 497 command.path.join('%(output)s', | 508 command.path.join('%(output)s', |
| 498 'libpnacl_irt_shim_dummy.a'), | 509 'libpnacl_irt_shim_dummy.a'), |
| 499 'dummy_shim_entry.o']), | 510 'dummy_shim_entry.o']), |
| 500 ], | 511 ], |
| 501 }, | 512 }, |
| 502 Mangle('compiler_rt', arch): { | 513 GSDJoin('compiler_rt', arch): { |
| 503 'type': 'build' if is_canonical else 'work', | 514 'type': 'build' if is_canonical else 'work', |
| 504 'output_subdir': 'lib-' + arch, | 515 'output_subdir': native_lib_dir, |
| 505 'dependencies': ['compiler_rt_src', 'target_lib_compiler', | 516 'dependencies': ['compiler_rt_src', 'target_lib_compiler', |
| 506 'newlib_portable'], | 517 'newlib_le32'], |
| 507 'commands': [ | 518 'commands': [ |
| 508 command.Command(MakeCommand() + [ | 519 command.Command(MakeCommand() + [ |
| 509 '-f', | 520 '-f', |
| 510 command.path.join('%(compiler_rt_src)s', 'lib', | 521 command.path.join('%(compiler_rt_src)s', 'lib', |
| 511 'Makefile-pnacl'), | 522 'Makefile-pnacl'), |
| 512 'libgcc.a', 'CC=' + PnaclTool('clang'), | 523 'libgcc.a', 'CC=' + PnaclTool('clang'), |
| 513 'AR=' + PnaclTool('ar')] + | 524 'AR=' + PnaclTool('ar')] + |
| 514 ['SRC_DIR=' + command.path.join('%(abs_compiler_rt_src)s', | 525 ['SRC_DIR=' + command.path.join('%(abs_compiler_rt_src)s', |
| 515 'lib'), | 526 'lib'), |
| 516 'CFLAGS=-arch ' + arch + ' -DPNACL_' + | 527 'CFLAGS=-arch ' + arch + ' -DPNACL_' + |
| 517 arch.replace('-', '_') + ' --pnacl-allow-translate -O3' + | 528 arch.replace('-', '_') + ' --pnacl-allow-translate -O3 ' + |
| 518 ' -isystem %(newlib_portable)s/include']), | 529 NewlibIsystemCflags('le32')]), |
| 519 command.Copy('libgcc.a', os.path.join('%(output)s', 'libgcc.a')), | 530 command.Copy('libgcc.a', os.path.join('%(output)s', 'libgcc.a')), |
| 520 ], | 531 ], |
| 521 }, | 532 }, |
| 522 } | 533 } |
| 523 if not arch.endswith('-nonsfi'): | 534 if not arch.endswith('-nonsfi'): |
| 524 libs.update({ | 535 libs.update({ |
| 525 Mangle('libgcc_eh', arch): { | 536 GSDJoin('libgcc_eh', arch): { |
| 526 'type': 'build' if is_canonical else 'work', | 537 'type': 'build' if is_canonical else 'work', |
| 527 'output_subdir': 'lib-' + arch, | 538 'output_subdir': native_lib_dir, |
| 528 'dependencies': [ 'gcc_src', 'target_lib_compiler'], | 539 'dependencies': [ 'gcc_src', 'target_lib_compiler'], |
| 529 'inputs': { 'scripts': os.path.join(NACL_DIR, 'pnacl', 'scripts')}, | 540 'inputs': { 'scripts': os.path.join(NACL_DIR, 'pnacl', 'scripts')}, |
| 530 'commands': [ | 541 'commands': [ |
| 531 # Instead of trying to use gcc's build system to build only | 542 # Instead of trying to use gcc's build system to build only |
| 532 # libgcc_eh, we just build the C files and archive them manually. | 543 # libgcc_eh, we just build the C files and archive them manually. |
| 533 command.RemoveDirectory('include'), | 544 command.RemoveDirectory('include'), |
| 534 command.Mkdir('include'), | 545 command.Mkdir('include'), |
| 535 command.Copy(os.path.join('%(gcc_src)s', 'gcc', | 546 command.Copy(os.path.join('%(gcc_src)s', 'gcc', |
| 536 'unwind-generic.h'), | 547 'unwind-generic.h'), |
| 537 os.path.join('include', 'unwind.h')), | 548 os.path.join('include', 'unwind.h')), |
| 538 command.Copy(os.path.join('%(scripts)s', 'libgcc-tconfig.h'), | 549 command.Copy(os.path.join('%(scripts)s', 'libgcc-tconfig.h'), |
| 539 'tconfig.h'), | 550 'tconfig.h'), |
| 540 command.WriteData('', 'tm.h'), | 551 command.WriteData('', 'tm.h'), |
| 541 BuildLibgccEhCmd('unwind-dw2.c', 'unwind-dw2.o', arch), | 552 BuildLibgccEhCmd('unwind-dw2.c', 'unwind-dw2.o', arch), |
| 542 BuildLibgccEhCmd('unwind-dw2-fde-glibc.c', | 553 BuildLibgccEhCmd('unwind-dw2-fde-glibc.c', |
| 543 'unwind-dw2-fde-glibc.o', arch), | 554 'unwind-dw2-fde-glibc.o', arch), |
| 544 command.Command([PnaclTool('ar'), 'rc', | 555 command.Command([PnaclTool('ar'), 'rc', |
| 545 command.path.join('%(output)s', 'libgcc_eh.a'), | 556 command.path.join('%(output)s', 'libgcc_eh.a'), |
| 546 'unwind-dw2.o', 'unwind-dw2-fde-glibc.o']), | 557 'unwind-dw2.o', 'unwind-dw2-fde-glibc.o']), |
| 547 ], | 558 ], |
| 548 }, | 559 }, |
| 549 }) | 560 }) |
| 550 return libs | 561 return libs |
| 551 | 562 |
| 552 def UnsandboxedIRT(arch): | 563 def UnsandboxedIRT(arch): |
| 553 libs = { | 564 libs = { |
| 554 Mangle('unsandboxed_irt', arch): { | 565 GSDJoin('unsandboxed_irt', arch): { |
| 555 'type': 'build', | 566 'type': 'build', |
| 556 'output_subdir': 'lib-' + arch, | 567 'output_subdir': os.path.join('translator', arch, 'lib'), |
| 557 # This lib #includes | 568 # This lib #includes |
| 558 # arbitrary stuff from native_client/src/{include,untrusted,trusted} | 569 # arbitrary stuff from native_client/src/{include,untrusted,trusted} |
| 559 'inputs': { 'support': os.path.join(NACL_DIR, 'src', 'nonsfi', 'irt'), | 570 'inputs': { 'support': os.path.join(NACL_DIR, 'src', 'nonsfi', 'irt'), |
| 560 'untrusted': os.path.join( | 571 'untrusted': os.path.join( |
| 561 NACL_DIR, 'src', 'untrusted', 'irt'), | 572 NACL_DIR, 'src', 'untrusted', 'irt'), |
| 562 'include': os.path.join(NACL_DIR, 'src'), }, | 573 'include': os.path.join(NACL_DIR, 'src'), }, |
| 563 'commands': [ | 574 'commands': [ |
| 564 # The NaCl headers insist on having a platform macro such as | 575 # The NaCl headers insist on having a platform macro such as |
| 565 # NACL_LINUX defined, but src/nonsfi/irt_interfaces.c does not | 576 # NACL_LINUX defined, but src/nonsfi/irt_interfaces.c does not |
| 566 # itself use any of these macros, so defining NACL_LINUX here | 577 # itself use any of these macros, so defining NACL_LINUX here |
| 567 # even on non-Linux systems is OK. | 578 # even on non-Linux systems is OK. |
| 568 # TODO(dschuff): this include path breaks the input encapsulation | 579 # TODO(dschuff): this include path breaks the input encapsulation |
| 569 # for build rules. | 580 # for build rules. |
| 570 command.Command([ | 581 command.Command([ |
| 571 'gcc', '-m32', '-O2', '-Wall', '-Werror', | 582 'gcc', '-m32', '-O2', '-Wall', '-Werror', |
| 572 '-I%(top_srcdir)s/..', '-DNACL_LINUX=1', '-DDEFINE_MAIN', | 583 '-I%(top_srcdir)s/..', '-DNACL_LINUX=1', '-DDEFINE_MAIN', |
| 573 '-c', command.path.join('%(support)s', 'irt_interfaces.c'), | 584 '-c', command.path.join('%(support)s', 'irt_interfaces.c'), |
| 574 '-o', command.path.join('%(output)s', 'unsandboxed_irt.o')]), | 585 '-o', command.path.join('%(output)s', 'unsandboxed_irt.o')]), |
| 575 command.Command([ | 586 command.Command([ |
| 576 'gcc', '-m32', '-O2', '-Wall', '-Werror', | 587 'gcc', '-m32', '-O2', '-Wall', '-Werror', |
| 577 '-I%(top_srcdir)s/..', | 588 '-I%(top_srcdir)s/..', |
| 578 '-c', command.path.join('%(untrusted)s', 'irt_query_list.c'), | 589 '-c', command.path.join('%(untrusted)s', 'irt_query_list.c'), |
| 579 '-o', command.path.join('%(output)s', 'irt_query_list.o')]), | 590 '-o', command.path.join('%(output)s', 'irt_query_list.o')]), |
| 580 ], | 591 ], |
| 581 }, | 592 }, |
| 582 } | 593 } |
| 583 return libs | 594 return libs |
| OLD | NEW |