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
4 # found in the LICENSE file.
6 # IMPORTANT NOTE: If you make local mods to this file, you must run:
7 # % pnacl/build.sh driver
8 # in order for them to take effect in the scons build. This command
9 # updates the copy in the toolchain/ tree.
13 from driver_env import env
14 from driver_log import Log
21 'MC_FLAGS' : '-assemble -filetype=obj ${MC_FLAGS_%ARCH%}',
22 'MC_FLAGS_ARM' : ('-arch=arm -triple=armv7a-nacl -mcpu=cortex-a9 ' +
24 'MC_FLAGS_X8632' : '-arch=x86 -triple=i686-nacl',
25 'MC_FLAGS_X8664' : '-arch=x86-64 -triple=x86_64-nacl',
26 'MC_FLAGS_MIPS32': '-arch=mipsel -triple=mipsel-nacl',
27 'MC_FLAGS_ARM_NONSFI': ('-arch=arm -triple=armv7a -mcpu=cortex-a9 '
29 'MC_FLAGS_X8632_NONSFI': '-arch=x86 -triple=i686',
31 'RUN_LLVM_AS' : '${LLVM_AS} ${input} -o ${output}',
32 'RUN_LLVM_MC' : '${LLVM_MC} ${MC_FLAGS} ${input} -o ${output}',
35 VERSION_STR = """Portable Native Client assembler
37 GNU assembler version 2.21.51 (pnacl-pc-nacl) using BFD version (GNU Binutils) 2.21.51.20110525
38 Low Level Virtual Machine (http://llvm.org/)
41 def DumpVersionDebug():
42 sys.stderr.write(VERSION_STR)
44 def DumpVersionAndExit():
45 sys.stdout.write(VERSION_STR)
46 driver_tools.DriverExit(0)
49 ( '-o(.+)', "env.set('OUTPUT', pathtools.normalize($0))"),
50 ( ('-o', '(.+)'), "env.set('OUTPUT', pathtools.normalize($0))"),
52 ( '-v', DumpVersionDebug),
53 ( '--version', DumpVersionAndExit),
55 # Ignore these assembler flags
57 ( ('(--traditional-format)', '.*'), ""),
62 ( '(--fatal-warnings)', ""),
67 ( '(-.+)', driver_tools.UnrecognizedOption),
69 # Unmatched parameters should be treated as
70 # assembly inputs by the "as" incarnation.
71 ( '(-)', "env.append('INPUTS', $0)"),
72 ( '(.*)', "env.append('INPUTS', pathtools.normalize($0))"),
77 driver_tools.ParseArgs(argv, ASPatterns)
78 arch = driver_tools.GetArch()
80 inputs = env.get('INPUTS')
81 output = env.getone('OUTPUT')
83 num_inputs = len(inputs)
85 Log.Fatal('Expecting exactly one input file')
102 env.set('input', the_input)
103 env.set('output', output)
105 if output_type == 'po':
107 driver_tools.Run("${RUN_LLVM_AS}")
110 driver_tools.Run("${RUN_LLVM_MC}")
112 # only reached in case of no errors
117 LLVM Assembler for PNaCl
118 Transform LLVM assembly (.ll) to LLVM bitcode.
120 Usage: pnacl-as [options] <input .ll file> -o <output.po>
123 -o <file> Output to file
124 --version Display version information
125 -help | -h Output this help.