| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python | |
| 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 # | |
| 6 # IMPORTANT NOTE: If you make local mods to this file, you must run: | |
| 7 # % tools/llvm/utman.sh driver | |
| 8 # in order for them to take effect in the scons build. This command | |
| 9 # updates the copy in the toolchain/ tree. | |
| 10 # | |
| 11 | |
| 12 from driver_tools import * | |
| 13 | |
| 14 EXTRA_ENV = { | |
| 15 'SINGLE_BC_LIBS': '0', # 'archive' bitcode libs as single bitcode file | |
| 16 } | |
| 17 env.update(EXTRA_ENV) | |
| 18 | |
| 19 def main(argv): | |
| 20 env.set('ARGV', *argv) | |
| 21 if env.getbool('SINGLE_BC_LIBS'): return ExperimentalArHack(argv) | |
| 22 return RunWithLog('${AR} ${ARGV}', errexit = False) | |
| 23 | |
| 24 # The ar/ranlib hacks are an attempt to iron out problems with shared | |
| 25 # libraries e.g. duplicate symbols in different libraries, before we have | |
| 26 # fully functional shared libs in pnacl. | |
| 27 def ExperimentalArHack(argv): | |
| 28 mode = argv[0] | |
| 29 output = argv[1] | |
| 30 inputs = argv[2:] | |
| 31 # NOTE: The checks below are a little on the paranoid side | |
| 32 # in most cases exceptions can be tolerated. | |
| 33 # It is probably still worth having a look at them first | |
| 34 # so we assert on everything unusual for now. | |
| 35 if mode in ['x']: | |
| 36 # This is used by by newlib to repackage a bunch of given archives | |
| 37 # into a new archive. It assumes all the objectfiles can be found | |
| 38 # via the glob, *.o | |
| 39 assert len(inputs) == 0 | |
| 40 shutil.copyfile(output, output.replace('..','').replace('/','_') + '.o') | |
| 41 return 0 | |
| 42 elif mode in ['cru']: | |
| 43 # NOTE: we treat cru just like rc which just so happens to work | |
| 44 # with newlib but does not work in the general case. | |
| 45 # However, due to some idiosyncrasiers in newlib we need to prune | |
| 46 # duplicates. | |
| 47 inputs = list(set(inputs)) | |
| 48 elif mode not in ['rc']: | |
| 49 Log.Fatal('Unexpected "ar" mode %s', mode) | |
| 50 if not output.endswith('.a'): | |
| 51 Log.Fatal('Unexpected "ar" lib %s', output) | |
| 52 not_bitcode = [f for f in inputs if 'po' != FileType(f)] | |
| 53 # NOTE: end of paranoid checks | |
| 54 for f in not_bitcode: | |
| 55 # This is for the last remaining native lib build via scons: libcrt_platform | |
| 56 if not f.endswith('tls.o') and not f.endswith('setjmp.o'): | |
| 57 Log.Fatal('Unexpected "ar" arg %s', f) | |
| 58 if not_bitcode: | |
| 59 RunWithLog('${AR} ${ARGV}', errexit = False) | |
| 60 else: | |
| 61 RunWithEnv('${LLVM_LINK} ${inputs} -o ${output}', | |
| 62 inputs=shell.join(inputs), output=shell.escape(output)) | |
| 63 return 0 | |
| 64 | |
| 65 if __name__ == "__main__": | |
| 66 DriverMain(main) | |
| OLD | NEW |