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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 bitcode_type = 'pexe' | 330 bitcode_type = 'pexe' |
331 native_type = 'nexe' | 331 native_type = 'nexe' |
332 | 332 |
333 if native_objects and not allow_native: | 333 if native_objects and not allow_native: |
334 argstr = ' '.join(native_objects) | 334 argstr = ' '.join(native_objects) |
335 Log.Fatal("Native objects '%s' detected in the link. " | 335 Log.Fatal("Native objects '%s' detected in the link. " |
336 "To allow, specify --pnacl-allow-native" % argstr) | 336 "To allow, specify --pnacl-allow-native" % argstr) |
337 | 337 |
338 tng = TempNameGen([], output) | 338 tng = TempNameGen([], output) |
339 | 339 |
340 has_bitcode = HasBitcodeInputs(inputs) | |
340 # Do the bitcode link. | 341 # Do the bitcode link. |
341 if HasBitcodeInputs(inputs): | 342 if has_bitcode: |
342 chain = DriverChain(inputs, output, tng) | 343 chain = DriverChain(inputs, output, tng) |
343 chain.add(LinkBC, 'pre_opt.' + bitcode_type) | 344 chain.add(LinkBC, 'pre_opt.' + bitcode_type) |
344 | 345 |
345 # ABI simplification passes. These passes assume the whole | 346 # ABI simplification passes. These passes assume the whole |
346 # program is available and should not be used if we are linking .o | 347 # program is available and should not be used if we are linking .o |
347 # files, otherwise: | 348 # files, otherwise: |
348 # * -expand-varargs will mix calling conventions; | 349 # * -expand-varargs will mix calling conventions; |
349 # * -nacl-expand-ctors will drop constructors; | 350 # * -nacl-expand-ctors will drop constructors; |
350 # * -nacl-expand-tls leave TLS variables unconverted. | 351 # * -nacl-expand-tls leave TLS variables unconverted. |
351 if env.getbool('STATIC') and len(native_objects) == 0: | 352 if env.getbool('STATIC') and len(native_objects) == 0: |
(...skipping 18 matching lines...) Expand all Loading... | |
370 chain.add(DoLTO, 'opt.' + bitcode_type) | 371 chain.add(DoLTO, 'opt.' + bitcode_type) |
371 elif env.getone('STRIP_MODE') != 'none': | 372 elif env.getone('STRIP_MODE') != 'none': |
372 chain.add(DoStrip, 'stripped.' + bitcode_type) | 373 chain.add(DoStrip, 'stripped.' + bitcode_type) |
373 | 374 |
374 if env.getbool('STATIC'): | 375 if env.getbool('STATIC'): |
375 # ABI simplification passes. We should not place arbitrary | 376 # ABI simplification passes. We should not place arbitrary |
376 # passes after '-expand-constant-expr' because they might | 377 # passes after '-expand-constant-expr' because they might |
377 # reintroduce ConstantExprs. However, '-expand-getelementptr' | 378 # reintroduce ConstantExprs. However, '-expand-getelementptr' |
378 # must follow '-expand-constant-expr' to expand the | 379 # must follow '-expand-constant-expr' to expand the |
379 # getelementptr instructions it creates. | 380 # getelementptr instructions it creates. |
380 passes = ['-expand-constant-expr', | 381 # We place '-strip-metadata' after optimization passes are run |
382 # since optimizations depend on the metadata. | |
383 passes = ['-strip-metadata', | |
384 '-expand-constant-expr', | |
381 '-expand-getelementptr'] | 385 '-expand-getelementptr'] |
382 if (not env.getbool('DISABLE_ABI_CHECK') and | |
383 not env.getbool('ALLOW_CXX_EXCEPTIONS') and | |
384 len(native_objects) == 0): | |
385 passes += ['-verify-pnaclabi-module', | |
386 '-verify-pnaclabi-functions'] | |
387 chain.add(DoLLVMPasses(passes), | 386 chain.add(DoLLVMPasses(passes), |
388 'expand_features_after_opt.' + bitcode_type) | 387 'expand_features_after_opt.' + bitcode_type) |
389 else: | 388 else: |
390 chain = DriverChain('', output, tng) | 389 chain = DriverChain('', output, tng) |
391 | 390 |
392 # If -arch is also specified, invoke pnacl-translate afterwards. | 391 # If -arch is also specified, invoke pnacl-translate afterwards. |
393 if arch_flag_given: | 392 if arch_flag_given: |
394 env.set('NATIVE_OBJECTS', *native_objects) | 393 env.set('NATIVE_OBJECTS', *native_objects) |
395 chain.add(DoTranslate, native_type) | 394 chain.add(DoTranslate, native_type) |
396 | 395 |
397 chain.run() | 396 chain.run() |
398 | 397 |
398 if (has_bitcode and | |
399 env.getbool('STATIC') and | |
400 not env.getbool('DISABLE_ABI_CHECK') and | |
401 not env.getbool('ALLOW_CXX_EXCEPTIONS') and | |
402 len(native_objects) == 0): | |
403 RunDriver('abicheck', [output, '-allow-debug-metadata']) | |
Mark Seaborn
2013/04/25 18:03:35
Why a separate invocation? This will be slower.
jvoung (off chromium)
2013/04/26 21:24:49
Merged the check back into the other run of opt.
| |
404 | |
399 if bitcode_type == 'pexe' and not arch_flag_given: | 405 if bitcode_type == 'pexe' and not arch_flag_given: |
400 # Mark .pexe files as executable. | 406 # Mark .pexe files as executable. |
401 # Some versions of 'configure' expect this. | 407 # Some versions of 'configure' expect this. |
402 SetExecutableMode(output) | 408 SetExecutableMode(output) |
403 return 0 | 409 return 0 |
404 | 410 |
405 def RemoveNativeStdLibs(objs): | 411 def RemoveNativeStdLibs(objs): |
406 # For newlib, all standard libraries are already bitcode. | 412 # For newlib, all standard libraries are already bitcode. |
407 if env.getbool('LIBMODE_NEWLIB'): | 413 if env.getbool('LIBMODE_NEWLIB'): |
408 return objs | 414 return objs |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 -O<opt-level> Optimize output file | 539 -O<opt-level> Optimize output file |
534 -M, --print-map Print map file on standard output | 540 -M, --print-map Print map file on standard output |
535 --whole-archive Include all objects from following archives | 541 --whole-archive Include all objects from following archives |
536 --no-whole-archive Turn off --whole-archive | 542 --no-whole-archive Turn off --whole-archive |
537 -s, --strip-all Strip all symbols | 543 -s, --strip-all Strip all symbols |
538 -S, --strip-debug Strip debugging symbols | 544 -S, --strip-debug Strip debugging symbols |
539 --undefined SYMBOL Start with undefined reference to SYMBOL | 545 --undefined SYMBOL Start with undefined reference to SYMBOL |
540 | 546 |
541 -help | -h Output this help. | 547 -help | -h Output this help. |
542 """ | 548 """ |
OLD | NEW |