| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 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 # IMPORTANT NOTE: If you make local mods to this file, you must run: | 6 # IMPORTANT NOTE: If you make local mods to this file, you must run: |
| 7 # % pnacl/build.sh driver | 7 # % pnacl/build.sh driver |
| 8 # in order for them to take effect in the scons build. This command | 8 # in order for them to take effect in the scons build. This command |
| 9 # updates the copy in the toolchain/ tree. | 9 # updates the copy in the toolchain/ tree. |
| 10 # | 10 # |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 'STRIP_MODE' : 'none', | 33 'STRIP_MODE' : 'none', |
| 34 | 34 |
| 35 'STRIP_FLAGS' : '--do-not-wrap ${STRIP_FLAGS_%STRIP_MODE%}', | 35 'STRIP_FLAGS' : '--do-not-wrap ${STRIP_FLAGS_%STRIP_MODE%}', |
| 36 'STRIP_FLAGS_all' : '-s', | 36 'STRIP_FLAGS_all' : '-s', |
| 37 'STRIP_FLAGS_debug': '-S', | 37 'STRIP_FLAGS_debug': '-S', |
| 38 | 38 |
| 39 'OPT_INLINE_THRESHOLD': '100', | 39 'OPT_INLINE_THRESHOLD': '100', |
| 40 'OPT_LEVEL': '', # Default opt is 0, but we need to know if it's explicitly | 40 'OPT_LEVEL': '', # Default opt is 0, but we need to know if it's explicitly |
| 41 # requested or not, since we don't want to propagate | 41 # requested or not, since we don't want to propagate |
| 42 # the value to TRANSLATE_FLAGS if it wasn't explicitly set. | 42 # the value to TRANSLATE_FLAGS if it wasn't explicitly set. |
| 43 'OPT_FLAGS': '-O${#OPT_LEVEL ? ${OPT_LEVEL} : 0} ${OPT_STRIP_%STRIP_MODE%} ' + | 43 'OPT_LTO_FLAGS': '-std-link-opts -disable-internalize', |
| 44 'OPT_FLAGS': '${#OPT_LEVEL && !OPT_LEVEL == 0 ? ${OPT_LTO_FLAGS}} ${OPT_STRIP_
%STRIP_MODE%} ' + |
| 44 '-inline-threshold=${OPT_INLINE_THRESHOLD} ' + | 45 '-inline-threshold=${OPT_INLINE_THRESHOLD} ' + |
| 45 '--do-not-wrap', | 46 '--do-not-wrap', |
| 46 'OPT_STRIP_none': '', | 47 'OPT_STRIP_none': '', |
| 47 'OPT_STRIP_all': '-disable-opt --strip', | 48 'OPT_STRIP_all': '-disable-opt --strip', |
| 48 'OPT_STRIP_debug': '-disable-opt --strip-debug', | 49 'OPT_STRIP_debug': '-disable-opt --strip-debug', |
| 49 | 50 |
| 50 'TRANSLATE_FLAGS': '${PIC ? -fPIC} ${!STDLIB ? -nostdlib} ' + | 51 'TRANSLATE_FLAGS': '${PIC ? -fPIC} ${!STDLIB ? -nostdlib} ' + |
| 51 '${STATIC ? -static} ' + | 52 '${STATIC ? -static} ' + |
| 52 '${SHARED ? -shared} ' + | 53 '${SHARED ? -shared} ' + |
| 53 '${#SONAME ? -Wl,--soname=${SONAME}} ' + | 54 '${#SONAME ? -Wl,--soname=${SONAME}} ' + |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 # program is available and should not be used if we are linking .o | 343 # program is available and should not be used if we are linking .o |
| 343 # files, otherwise: | 344 # files, otherwise: |
| 344 # * -nacl-expand-ctors will drop constructors; | 345 # * -nacl-expand-ctors will drop constructors; |
| 345 # * -nacl-expand-tls leave TLS variables unconverted. | 346 # * -nacl-expand-tls leave TLS variables unconverted. |
| 346 if env.getbool('STATIC') and len(native_objects) == 0: | 347 if env.getbool('STATIC') and len(native_objects) == 0: |
| 347 passes = ['-nacl-expand-ctors', | 348 passes = ['-nacl-expand-ctors', |
| 348 '-nacl-expand-tls'] | 349 '-nacl-expand-tls'] |
| 349 chain.add(DoLLVMPasses(passes), 'expand_features.' + bitcode_type) | 350 chain.add(DoLLVMPasses(passes), 'expand_features.' + bitcode_type) |
| 350 | 351 |
| 351 if env.getone('OPT_LEVEL') != '' and env.getone('OPT_LEVEL') != '0': | 352 if env.getone('OPT_LEVEL') != '' and env.getone('OPT_LEVEL') != '0': |
| 352 chain.add(DoOPT, 'opt.' + bitcode_type) | 353 chain.add(DoLTO, 'opt.' + bitcode_type) |
| 353 elif env.getone('STRIP_MODE') != 'none': | 354 elif env.getone('STRIP_MODE') != 'none': |
| 354 chain.add(DoStrip, 'stripped.' + bitcode_type) | 355 chain.add(DoStrip, 'stripped.' + bitcode_type) |
| 355 | 356 |
| 356 if env.getbool('STATIC'): | 357 if env.getbool('STATIC'): |
| 357 # ABI simplification pass. This should come last because other | 358 # ABI simplification pass. This should come last because other |
| 358 # LLVM passes might reintroduce ConstantExprs. | 359 # LLVM passes might reintroduce ConstantExprs. |
| 359 chain.add(DoLLVMPasses(['-expand-constant-expr']), | 360 chain.add(DoLLVMPasses(['-expand-constant-expr']), |
| 360 'expand_constant_exprs.' + bitcode_type) | 361 'expand_constant_exprs.' + bitcode_type) |
| 361 else: | 362 else: |
| 362 chain = DriverChain('', output, tng) | 363 chain = DriverChain('', output, tng) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 pathtools.touser(f), FileType(f)) | 453 pathtools.touser(f), FileType(f)) |
| 453 count += 1 | 454 count += 1 |
| 454 | 455 |
| 455 if count == 0: | 456 if count == 0: |
| 456 Log.Fatal("no input files") | 457 Log.Fatal("no input files") |
| 457 | 458 |
| 458 def DoLLVMPasses(pass_list): | 459 def DoLLVMPasses(pass_list): |
| 459 def Func(infile, outfile): | 460 def Func(infile, outfile): |
| 460 filtered_list = [pass_option for pass_option in pass_list | 461 filtered_list = [pass_option for pass_option in pass_list |
| 461 if pass_option not in env.get('LLVM_PASSES_TO_DISABLE')] | 462 if pass_option not in env.get('LLVM_PASSES_TO_DISABLE')] |
| 462 RunDriver('opt', filtered_list + [infile, '-o', outfile]) | 463 RunDriver('opt', filtered_list + [infile, '-o', outfile, '--do-not-wrap']) |
| 463 return Func | 464 return Func |
| 464 | 465 |
| 465 def DoOPT(infile, outfile): | 466 def DoLTO(infile, outfile): |
| 466 opt_flags = env.get('OPT_FLAGS') | 467 opt_flags = env.get('OPT_FLAGS') |
| 467 RunDriver('opt', opt_flags + [ infile, '-o', outfile ]) | 468 RunDriver('opt', opt_flags + [ infile, '-o', outfile ]) |
| 468 | 469 |
| 469 def DoStrip(infile, outfile): | 470 def DoStrip(infile, outfile): |
| 470 strip_flags = env.get('STRIP_FLAGS') | 471 strip_flags = env.get('STRIP_FLAGS') |
| 471 RunDriver('strip', strip_flags + [ infile, '-o', outfile ]) | 472 RunDriver('strip', strip_flags + [ infile, '-o', outfile ]) |
| 472 | 473 |
| 473 def DoTranslate(infile, outfile): | 474 def DoTranslate(infile, outfile): |
| 474 args = env.get('TRANSLATE_FLAGS') | 475 args = env.get('TRANSLATE_FLAGS') |
| 475 args += ['-Wl,'+s for s in env.get('LD_FLAGS_NATIVE')] | 476 args += ['-Wl,'+s for s in env.get('LD_FLAGS_NATIVE')] |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 -O<opt-level> Optimize output file | 508 -O<opt-level> Optimize output file |
| 508 -M, --print-map Print map file on standard output | 509 -M, --print-map Print map file on standard output |
| 509 --whole-archive Include all objects from following archives | 510 --whole-archive Include all objects from following archives |
| 510 --no-whole-archive Turn off --whole-archive | 511 --no-whole-archive Turn off --whole-archive |
| 511 -s, --strip-all Strip all symbols | 512 -s, --strip-all Strip all symbols |
| 512 -S, --strip-debug Strip debugging symbols | 513 -S, --strip-debug Strip debugging symbols |
| 513 --undefined SYMBOL Start with undefined reference to SYMBOL | 514 --undefined SYMBOL Start with undefined reference to SYMBOL |
| 514 | 515 |
| 515 -help | -h Output this help. | 516 -help | -h Output this help. |
| 516 """ | 517 """ |
| OLD | NEW |