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 from driver_tools import ArchMerge, DriverChain, GetArch, \ | 6 from driver_tools import ArchMerge, DriverChain, GetArch, \ |
7 ParseArgs, ParseTriple, RunDriver, RunWithEnv, SetArch, \ | 7 ParseArgs, ParseTriple, RunDriver, RunWithEnv, SetArch, \ |
8 SetExecutableMode, TempNameGen, UnrecognizedOption | 8 SetExecutableMode, TempNameGen, UnrecognizedOption |
9 from driver_env import env | 9 from driver_env import env |
10 from driver_log import Log | 10 from driver_log import Log |
11 import filetype | 11 import filetype |
12 import ldtools | 12 import ldtools |
13 import os | |
13 import pathtools | 14 import pathtools |
14 | 15 |
15 EXTRA_ENV = { | 16 EXTRA_ENV = { |
16 'ALLOW_NATIVE': '0', # Allow LD args which will change the behavior | 17 'ALLOW_NATIVE': '0', # Allow LD args which will change the behavior |
17 # of native linking. This must be accompanied by | 18 # of native linking. This must be accompanied by |
18 # -arch to produce a .nexe. | 19 # -arch to produce a .nexe. |
19 'USE_IRT': '1', # Use stable IRT interfaces. | 20 'USE_IRT': '1', # Use stable IRT interfaces. |
20 | 21 |
21 'INPUTS' : '', | 22 'INPUTS' : '', |
22 'OUTPUT' : '', | 23 'OUTPUT' : '', |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 inputs = ldtools.ExpandInputs(inputs, | 339 inputs = ldtools.ExpandInputs(inputs, |
339 env.get('SEARCH_DIRS'), | 340 env.get('SEARCH_DIRS'), |
340 env.getbool('STATIC'), | 341 env.getbool('STATIC'), |
341 # Once all glibc bitcode link is purely | 342 # Once all glibc bitcode link is purely |
342 # bitcode (e.g., even libc_nonshared.a) | 343 # bitcode (e.g., even libc_nonshared.a) |
343 # we may be able to restrict this more. | 344 # we may be able to restrict this more. |
344 # This is also currently used by | 345 # This is also currently used by |
345 # pnacl_generate_pexe=0 with glibc, | 346 # pnacl_generate_pexe=0 with glibc, |
346 # for user libraries. | 347 # for user libraries. |
347 ldtools.LibraryTypes.ANY) | 348 ldtools.LibraryTypes.ANY) |
349 (plls, inputs) = FilterPlls(inputs) | |
350 plls = [os.path.basename(pll) for pll in plls] | |
351 | |
352 if not env.getbool('SHARED'): | |
353 assert(plls == []) | |
348 | 354 |
349 # Make sure the inputs have matching arch. | 355 # Make sure the inputs have matching arch. |
350 CheckInputsArch(inputs) | 356 CheckInputsArch(inputs) |
351 | 357 |
352 regular_inputs, native_objects = SplitLinkLine(inputs) | 358 regular_inputs, native_objects = SplitLinkLine(inputs) |
353 | 359 |
354 if env.getbool('RELOCATABLE'): | 360 if env.getbool('RELOCATABLE'): |
355 bitcode_type = 'po' | 361 bitcode_type = 'po' |
356 native_type = 'o' | 362 native_type = 'o' |
357 else: | 363 else: |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 pre_simplify_shared = [ | 403 pre_simplify_shared = [ |
398 # The following is a subset of "-pnacl-abi-simplify-preopt". We don't | 404 # The following is a subset of "-pnacl-abi-simplify-preopt". We don't |
399 # want to run the full "-pnacl-abi-simplify-preopt" because it | 405 # want to run the full "-pnacl-abi-simplify-preopt" because it |
400 # internalizes symbols that we want to export via "-convert-to-pso". | 406 # internalizes symbols that we want to export via "-convert-to-pso". |
401 '-nacl-global-cleanup', | 407 '-nacl-global-cleanup', |
402 '-expand-varargs', | 408 '-expand-varargs', |
403 '-rewrite-pnacl-library-calls', | 409 '-rewrite-pnacl-library-calls', |
404 '-rewrite-llvm-intrinsic-calls', | 410 '-rewrite-llvm-intrinsic-calls', |
405 '-convert-to-pso', | 411 '-convert-to-pso', |
406 ] | 412 ] |
413 | |
414 # ConvertToPso takes a list of comma-separated PLL dependencies as an | |
415 # argument. | |
416 if plls != []: | |
417 pre_simplify_shared += ['-convert-to-pso-deps=' + ','.join(plls)] | |
407 opt_args.append(pre_simplify_shared) | 418 opt_args.append(pre_simplify_shared) |
408 # Post-opt is required, since '-convert-to-pso' adds metadata which must | 419 # Post-opt is required, since '-convert-to-pso' adds metadata which must |
409 # be simplified before finalization. Additionally, all functions must be | 420 # be simplified before finalization. Additionally, all functions must be |
410 # simplified in the post-opt passes. | 421 # simplified in the post-opt passes. |
411 abi_simplify = True | 422 abi_simplify = True |
412 elif abi_simplify: | 423 elif abi_simplify: |
413 pre_simplify = ['-pnacl-abi-simplify-preopt'] | 424 pre_simplify = ['-pnacl-abi-simplify-preopt'] |
414 if env.getone('CXX_EH_MODE') == 'sjlj': | 425 if env.getone('CXX_EH_MODE') == 'sjlj': |
415 pre_simplify += ['-enable-pnacl-sjlj-eh'] | 426 pre_simplify += ['-enable-pnacl-sjlj-eh'] |
416 else: | 427 else: |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 result_libs = [] | 515 result_libs = [] |
505 for user_lib in user_libs: | 516 for user_lib in user_libs: |
506 if user_lib in public_libs: | 517 if user_lib in public_libs: |
507 result_libs.append(private_lib_for(user_lib)) | 518 result_libs.append(private_lib_for(user_lib)) |
508 if can_coexist(user_lib): | 519 if can_coexist(user_lib): |
509 result_libs.append(user_lib) | 520 result_libs.append(user_lib) |
510 else: | 521 else: |
511 result_libs.append(user_lib) | 522 result_libs.append(user_lib) |
512 return result_libs | 523 return result_libs |
513 | 524 |
525 def FilterPlls(inputs): | |
526 """ Split the input list into PLLs and other objects (.pll, other) | |
527 """ | |
528 pll = [] | |
Mark Seaborn
2016/03/30 23:24:57
Nit: "plls" plural?
Sean Klein
2016/04/01 23:12:24
Done.
| |
529 other = [] | |
530 | |
531 for f in inputs: | |
532 if ldtools.IsFlag(f): | |
Mark Seaborn
2016/03/30 23:24:57
How about simplifying to "if ldtools.IsFlag(f) and
Sean Klein
2016/04/01 23:12:24
I'm pretty sure you mean "or", not "and". Updating
| |
533 other.append(f) | |
534 elif filetype.IsPll(f): | |
535 pll.append(f) | |
536 else: | |
537 other.append(f) | |
538 return (pll, other) | |
539 | |
514 def SplitLinkLine(inputs): | 540 def SplitLinkLine(inputs): |
515 """ Split the input list into bitcode and native objects (.o, .a) | 541 """ Split the input list into bitcode and native objects (.o, .a) |
516 """ | 542 """ |
517 normal = [] | 543 normal = [] |
518 native = [] | 544 native = [] |
519 # Group flags need special handling because they need to go into the right | 545 # Group flags need special handling because they need to go into the right |
520 # list based on the type of the inputs in the group. If the group has both | 546 # list based on the type of the inputs in the group. If the group has both |
521 # native and bitcode files (which is unfortunately the case for | 547 # native and bitcode files (which is unfortunately the case for |
522 # irt_browser_lib) then the group flags need to go in both lists. | 548 # irt_browser_lib) then the group flags need to go in both lists. |
523 if '--start-group' in inputs: | 549 if '--start-group' in inputs: |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
624 -O<opt-level> Optimize output file | 650 -O<opt-level> Optimize output file |
625 -M, --print-map Print map file on standard output | 651 -M, --print-map Print map file on standard output |
626 --whole-archive Include all objects from following archives | 652 --whole-archive Include all objects from following archives |
627 --no-whole-archive Turn off --whole-archive | 653 --no-whole-archive Turn off --whole-archive |
628 -s, --strip-all Strip all symbols | 654 -s, --strip-all Strip all symbols |
629 -S, --strip-debug Strip debugging symbols | 655 -S, --strip-debug Strip debugging symbols |
630 -u SYM, --undefined=SYM Start with undefined reference to SYM | 656 -u SYM, --undefined=SYM Start with undefined reference to SYM |
631 | 657 |
632 -help | -h Output this help. | 658 -help | -h Output this help. |
633 """ | 659 """ |
OLD | NEW |