Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: pnacl/driver/pnacl-ld.py

Issue 1825893002: PNaCl Dynamic Linking: Added portable dependencies to shared objects. (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Bumping Feature Version Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pnacl/driver/filetype.py ('k') | src/untrusted/pll_loader/pll_loader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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') and plls != []:
353 Log.Fatal('Passing a PLL to the linker requires the "-shared" option.')
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
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 # ConvertToPso takes a list of comma-separated PLL dependencies as an
414 # argument.
415 if plls != []:
416 pre_simplify_shared += ['-convert-to-pso-deps=' + ','.join(plls)]
407 opt_args.append(pre_simplify_shared) 417 opt_args.append(pre_simplify_shared)
408 # Post-opt is required, since '-convert-to-pso' adds metadata which must 418 # Post-opt is required, since '-convert-to-pso' adds metadata which must
409 # be simplified before finalization. Additionally, all functions must be 419 # be simplified before finalization. Additionally, all functions must be
410 # simplified in the post-opt passes. 420 # simplified in the post-opt passes.
411 abi_simplify = True 421 abi_simplify = True
412 elif abi_simplify: 422 elif abi_simplify:
413 pre_simplify = ['-pnacl-abi-simplify-preopt'] 423 pre_simplify = ['-pnacl-abi-simplify-preopt']
414 if env.getone('CXX_EH_MODE') == 'sjlj': 424 if env.getone('CXX_EH_MODE') == 'sjlj':
415 pre_simplify += ['-enable-pnacl-sjlj-eh'] 425 pre_simplify += ['-enable-pnacl-sjlj-eh']
416 else: 426 else:
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 result_libs = [] 514 result_libs = []
505 for user_lib in user_libs: 515 for user_lib in user_libs:
506 if user_lib in public_libs: 516 if user_lib in public_libs:
507 result_libs.append(private_lib_for(user_lib)) 517 result_libs.append(private_lib_for(user_lib))
508 if can_coexist(user_lib): 518 if can_coexist(user_lib):
509 result_libs.append(user_lib) 519 result_libs.append(user_lib)
510 else: 520 else:
511 result_libs.append(user_lib) 521 result_libs.append(user_lib)
512 return result_libs 522 return result_libs
513 523
524 def FilterPlls(inputs):
525 """ Split the input list into PLLs and other objects.
526 """
527 plls = []
528 other = []
529
530 for f in inputs:
531 if ldtools.IsFlag(f) or not filetype.IsPll(f):
532 other.append(f)
533 else:
534 plls.append(f)
535 return (plls, other)
536
514 def SplitLinkLine(inputs): 537 def SplitLinkLine(inputs):
515 """ Split the input list into bitcode and native objects (.o, .a) 538 """ Split the input list into bitcode and native objects (.o, .a)
516 """ 539 """
517 normal = [] 540 normal = []
518 native = [] 541 native = []
519 # Group flags need special handling because they need to go into the right 542 # 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 543 # 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 544 # native and bitcode files (which is unfortunately the case for
522 # irt_browser_lib) then the group flags need to go in both lists. 545 # irt_browser_lib) then the group flags need to go in both lists.
523 if '--start-group' in inputs: 546 if '--start-group' in inputs:
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 -O<opt-level> Optimize output file 647 -O<opt-level> Optimize output file
625 -M, --print-map Print map file on standard output 648 -M, --print-map Print map file on standard output
626 --whole-archive Include all objects from following archives 649 --whole-archive Include all objects from following archives
627 --no-whole-archive Turn off --whole-archive 650 --no-whole-archive Turn off --whole-archive
628 -s, --strip-all Strip all symbols 651 -s, --strip-all Strip all symbols
629 -S, --strip-debug Strip debugging symbols 652 -S, --strip-debug Strip debugging symbols
630 -u SYM, --undefined=SYM Start with undefined reference to SYM 653 -u SYM, --undefined=SYM Start with undefined reference to SYM
631 654
632 -help | -h Output this help. 655 -help | -h Output this help.
633 """ 656 """
OLDNEW
« no previous file with comments | « pnacl/driver/filetype.py ('k') | src/untrusted/pll_loader/pll_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698