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

Side by Side Diff: tools/llvm/llvm-fake.py

Issue 1613004: Issue a warning if naclsdk_mode=manual is specified with ARM. (Closed) Base URL: http://nativeclient.googlecode.com/svn/trunk/src/native_client/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « SConstruct ('k') | tools/llvm/toolchain-creator.sh » ('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 2009 The Native Client Authors. All rights reserved. 2 # Copyright 2009 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can 3 # Use of this source code is governed by a BSD-style license that can
4 # be found in the LICENSE file. 4 # be found in the LICENSE file.
5 5
6 # this script is a replacement for llvm-gcc and llvm-g++ driver. 6 # this script is a replacement for llvm-gcc and llvm-g++ driver.
7 # It detects automatically which role it is supposed to assume. 7 # It detects automatically which role it is supposed to assume.
8 # The point of the script is to redirect builds through our own tools, 8 # The point of the script is to redirect builds through our own tools,
9 # while making these tools appear like gnu tools. 9 # while making these tools appear like gnu tools.
10 # 10 #
11 # Compared to the gcc driver the usage patterns of this script 11 # Compared to the gcc driver the usage patterns of this script
12 # are somewhat restricted: 12 # are somewhat restricted:
13 # * you cannot compile and link at the same time 13 # * you cannot compile and link at the same time
14 # * you cannot specify multiple source files in one invocation 14 # * you cannot specify multiple source files in one invocation
15 # * ... 15 # * ...
16 # 16 #
17 17
18 18
19 import os 19 import os
20 import struct 20 import struct
21 import subprocess 21 import subprocess
22 import sys 22 import sys
23 23
24 # enable this for manual debugging of this script only 24 # enable this for manual debugging of this script only
25 # NOTE: this HAS to be zero in order to work with the llvm-gcc 25 # NOTE: this HAS to be zero in order to work with the llvm-gcc
26 # bootstrapping process 26 # bootstrapping process
27 VERBOSE = 0 27 VERBOSE = 1
28 TOLERATE_COMPILATION_OF_ASM_CODE = 1 28 TOLERATE_COMPILATION_OF_ASM_CODE = 1
29 # NOTE: set this to something like: 29 # NOTE: set this to something like:
30 OUT = open('/tmp/fake.log', 'a') 30 OUT = open('/tmp/fake.log', 'a')
31 # if you want a log of all the action. otherwise: 31 # if you want a log of all the action. otherwise:
32 #OUT = None 32 #OUT = None
33 33
34 ###################################################################### 34 ######################################################################
35 # Misc 35 # Misc
36 ###################################################################### 36 ######################################################################
37 37
38 BASE = os.path.dirname(os.path.dirname(sys.argv[0])) 38 BASE = os.path.dirname(os.path.dirname(sys.argv[0]))
39 39
40 LD_SCRIPT_ARM = BASE + '/arm-none-linux-gnueabi/ld_script_arm_untrusted' 40 LD_SCRIPT_ARM = BASE + '/arm-none-linux-gnueabi/ld_script_arm_untrusted'
41 41
42 # TODO(robertm) clean this up 42 # TODO(robertm) clean this up
43 LD_SCRIPT_X8632 = BASE + '/../../tools/llvm/ld_script_x86_untrusted' 43 LD_SCRIPT_X8632 = BASE + '/../../tools/llvm/ld_script_x86_untrusted'
44 44
45 # arm libgcc 45 # arm libgcc
46 LIBDIR_ARM_1 = BASE + '/armsfi-lib' 46 LIBDIR_ARM_1 = BASE + '/armsfi-lib'
47 47
48 # arm startup code + libs (+ bitcode when in bitcode mode) 48 # arm startup code + libs (+ bitcode when in bitcode mode)
49 LIBDIR_ARM_2 = BASE + '/arm-newlib/arm-none-linux-gnueabi/lib' 49 LIBDIR_ARM_2 = BASE + '/arm-newlib/arm-none-linux-gnueabi/lib'
50 50
51 # x86 libgcc 51 # x86 libgcc
52 LIBDIR_X8632_1 = BASE + '/../linux_x86/sdk/nacl-sdk/nacl64/lib/32' 52 LIBDIR_X8632_2 = BASE + '/../linux_x86/sdk/nacl-sdk/nacl64/lib/32'
53 53
54 # x86 startup code 54 # x86 startup code
55 LIBDIR_X8632_2 = BASE + '/../linux_x86/sdk/nacl-sdk/lib/gcc/nacl64/4.4.3/32/' 55 LIBDIR_X8632_1 = BASE + '/../linux_x86/sdk/nacl-sdk/lib/gcc/nacl64/4.4.3/32/'
56 56
57 # NOTE: ugly work around for some llvm-ld shortcomings: 57 # NOTE: ugly work around for some llvm-ld shortcomings:
58 # we need to keep some symbols alive which are referenced by 58 # we need to keep some symbols alive which are referenced by
59 # native code libraries linked in at the very end 59 # native code libraries linked in at the very end
60 REACHABLE_FUNCTION_SYMBOLS = LIBDIR_ARM_2 + '/reachable_function_symbols.o' 60 REACHABLE_FUNCTION_SYMBOLS = LIBDIR_ARM_2 + '/reachable_function_symbols.o'
61 61
62 # Note: this works around an assembler bug that has been fixed only recently 62 # Note: this works around an assembler bug that has been fixed only recently
63 # We probably can drop this once we have switched to codesourcery 2009Q4 63 # We probably can drop this once we have switched to codesourcery 2009Q4
64 HACK_ASM = ['sed', '-e', 's/vmrs.*apsr_nzcv, fpscr/fmrx r15, fpscr/g'] 64 HACK_ASM = ['sed', '-e', 's/vmrs.*apsr_nzcv, fpscr/fmrx r15, fpscr/g']
65 65
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 ###################################################################### 177 ######################################################################
178 178
179 LLVM_GCC = BASE + '/arm-none-linux-gnueabi/llvm-gcc-4.2/bin/llvm-gcc' 179 LLVM_GCC = BASE + '/arm-none-linux-gnueabi/llvm-gcc-4.2/bin/llvm-gcc'
180 180
181 LLVM_GXX = BASE + '/arm-none-linux-gnueabi/llvm-gcc-4.2/bin/llvm-g++' 181 LLVM_GXX = BASE + '/arm-none-linux-gnueabi/llvm-gcc-4.2/bin/llvm-g++'
182 182
183 LLC_ARM = BASE + '/arm-none-linux-gnueabi/llvm/bin/llc' 183 LLC_ARM = BASE + '/arm-none-linux-gnueabi/llvm/bin/llc'
184 184
185 LLC_SFI_ARM = BASE + '/arm-none-linux-gnueabi/llvm/bin/llc-sfi' 185 LLC_SFI_ARM = BASE + '/arm-none-linux-gnueabi/llvm/bin/llc-sfi'
186 186
187 # NOTE: patch your own llc in here 187 # Path to llc executable for x86-32.
188 LLC_SFI_X86 = None 188 LLC_SFI_X86 = os.getenv('LLC_SFI_X86', None)
189 189
190 LLVM_LINK = BASE + '/arm-none-linux-gnueabi/llvm/bin/llvm-link' 190 LLVM_LINK = BASE + '/arm-none-linux-gnueabi/llvm/bin/llvm-link'
191 191
192 LLVM_LD = BASE + '/arm-none-linux-gnueabi/llvm/bin/llvm-ld' 192 LLVM_LD = BASE + '/arm-none-linux-gnueabi/llvm/bin/llvm-ld'
193 193
194 OPT = BASE + '/arm-none-linux-gnueabi/llvm/bin/opt' 194 OPT = BASE + '/arm-none-linux-gnueabi/llvm/bin/opt'
195 195
196 # NOTE: from code sourcery 196 # NOTE: from code sourcery
197 AS_ARM = BASE + '/codesourcery/arm-2007q3/arm-none-linux-gnueabi/bin/as' 197 AS_ARM = BASE + '/codesourcery/arm-2007q3/arm-none-linux-gnueabi/bin/as'
198 198
199 # NOTE: hack, assuming presence of x86/32 toolchain expected 199 # NOTE: hack, assuming presence of x86/32 toolchain expected
200 # TODO(robertm): clean this up 200 # TODO(robertm): clean this up
201 AS_X8632 = BASE + '/../linux_x86/sdk/nacl-sdk/bin/nacl64-as' 201 AS_X8632 = BASE + '/../linux_x86/sdk/nacl-sdk/bin/nacl64-as'
202 202
203 # NOTE: from code sourcery 203 # NOTE: from code sourcery
204 # TODO(robertm): get rid of the use of gcc here this uses cpp + as 204 # TODO(robertm): get rid of the use of gcc here this uses cpp + as
205 CCAS_ARM = BASE + '/codesourcery/arm-2007q3/arm-none-linux-gnueabi/bin/gcc' 205 CCAS_ARM = BASE + '/codesourcery/arm-2007q3/arm-none-linux-gnueabi/bin/gcc'
206 206
207 # NOTE: hack, assuming presence of x86/32 toolchain expected 207 # NOTE: hack, assuming presence of x86/32 toolchain expected
208 # TODO(robertm): clean this up 208 # TODO(robertm): clean this up
209 CCAS_X8632 = BASE + '/../linux_x86-32/sdk/nacl-sdk/bin/nacl-gcc' 209 CCAS_X8632 = BASE + '/../linux_x86-32/sdk/nacl-sdk/bin/nacl-gcc'
210 210
211 LD_ARM = BASE + '/codesourcery/arm-2007q3/arm-none-linux-gnueabi/bin/ld' 211 LD_ARM = BASE + '/codesourcery/arm-2007q3/arm-none-linux-gnueabi/bin/ld'
212 212
213 # NOTE: hack, assuming presence of x86/32 toolchain expected 213 # NOTE: hack, assuming presence of x86/32 toolchain expected
214 # TODO(robertm): clean this up - we may not need separate linkers 214 # TODO(robertm): clean this up - we may not need separate linkers
215 # NOTE(robertm): the nacl linker sometimes creates empty sections like .plt 215 # NOTE(robertm): the nacl linker sometimes creates empty sections like .plt
216 # so we use the system linker for now 216 # so we use the system linker for now
217 #LD_X8632 = BASE + '/../linux_x86-32/sdk/nacl-sdk/bin/nacl-ld' 217 #LD_X8632 = BASE + '/../linux_x86-32/sdk/nacl-sdk/bin/nacl-ld'
218 LD_X8632 = 'ld' 218 LD_X8632 = '/usr/bin/ld'
219 # NOTE(adonovan): this should _not_ be the Gold linker, e.g. 2.18.*.
220 # Beware, one of the Chrome installation scripts may have changed
221 # /usr/bin/ld (which is evil).
219 222
220 ###################################################################### 223 ######################################################################
221 # Code 224 # Code
222 ###################################################################### 225 ######################################################################
223 226
224 def LogInfo(m): 227 def LogInfo(m):
225 if VERBOSE: 228 if VERBOSE:
226 print m 229 print m
227 if OUT: 230 if OUT:
228 print >> OUT, m 231 print >> OUT, m
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 LogFatal('Unexpected ld arg: %s' % a) 552 LogFatal('Unexpected ld arg: %s' % a)
550 553
551 assert output 554 assert output
552 555
553 # NOTE: LLVM_LD automagically appends .bc to the output 556 # NOTE: LLVM_LD automagically appends .bc to the output
554 # NOTE: without -disable-internalize only the symbol 'main' 557 # NOTE: without -disable-internalize only the symbol 'main'
555 # is exported, but we need some more for the startup code 558 # is exported, but we need some more for the startup code
556 # which kept alive via REACHABLE_FUNCTION_SYMBOLS 559 # which kept alive via REACHABLE_FUNCTION_SYMBOLS
557 if '-nostdlib' not in argv: 560 if '-nostdlib' not in argv:
558 if last_bitcode_pos != None: 561 if last_bitcode_pos != None:
562 # Splice in the extra symbols.
563 # TODO(adonovan): temp hack to avoid "multiple defns" error.
559 args_bit_ld = (args_bit_ld[:last_bitcode_pos] + 564 args_bit_ld = (args_bit_ld[:last_bitcode_pos] +
560 [REACHABLE_FUNCTION_SYMBOLS] + 565 # [REACHABLE_FUNCTION_SYMBOLS] +
561 args_bit_ld[last_bitcode_pos:]) 566 args_bit_ld[last_bitcode_pos:])
562 567
563 # NOTE: .bc will be appended output by LLVM_LD 568 # NOTE: .bc will be appended output by LLVM_LD
564 Run([LLVM_LD] + args_bit_ld + ['-disable-internalize', '-o', output]) 569 Run([LLVM_LD] + args_bit_ld + ['-disable-internalize', '-o', output])
565 return output, args_native_ld 570 return output, args_native_ld
566 571
567 572
568 def Incarnation_bcldarm(argv): 573 def Incarnation_bcldarm(argv):
569 """The ld step for bitcode is quite elaborate: 574 """The ld step for bitcode is quite elaborate:
570 1) Run llvm-ld to produce a single bitcode file 575 1) Run llvm-ld to produce a single bitcode file
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 621
617 TODO(robertm): llvm-ld does NOT complain when passed a native .o file. 622 TODO(robertm): llvm-ld does NOT complain when passed a native .o file.
618 It will discard it silently. 623 It will discard it silently.
619 """ 624 """
620 output, args_native_ld = GenerateCombinedBitcodeFile(argv) 625 output, args_native_ld = GenerateCombinedBitcodeFile(argv)
621 626
622 bitcode_combined = output + ".bc" 627 bitcode_combined = output + ".bc"
623 asm_combined = output + ".bc.s" 628 asm_combined = output + ".bc.s"
624 obj_combined = output + ".bc.o" 629 obj_combined = output + ".bc.o"
625 630
631 # TODO(adonovan): use external env var until we complete llc SFI for x86.
632 if not LLC_SFI_X86:
633 LogFatal('You must set LLC_SFI_X86 to your llc executable for x86-32.')
634
626 Run([LLC_SFI_X86] + 635 Run([LLC_SFI_X86] +
627 LLC_SHARED_FLAGS_X8632 + 636 LLC_SHARED_FLAGS_X8632 +
628 ['-f', bitcode_combined, '-o', asm_combined]) 637 ['-f', bitcode_combined, '-o', asm_combined])
629 638
630 Run([AS_X8632] + AS_FLAGS_X8632 + [asm_combined, '-o', obj_combined]) 639 Run([AS_X8632] + AS_FLAGS_X8632 + [asm_combined, '-o', obj_combined])
631 640
632 args_native_ld = MassageFinalLinkCommandX8632([obj_combined] + args_native_ld) 641 args_native_ld = MassageFinalLinkCommandX8632([obj_combined] + args_native_ld)
633 642
634 Run([LD_X8632] + args_native_ld) 643 Run([LD_X8632] + args_native_ld)
635 644
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 if basename not in INCARNATIONS: 691 if basename not in INCARNATIONS:
683 LogFatal("unknown command: " + StringifyCommand(argv)) 692 LogFatal("unknown command: " + StringifyCommand(argv))
684 693
685 694
686 INCARNATIONS[basename](argv) 695 INCARNATIONS[basename](argv)
687 return 0 696 return 0
688 697
689 698
690 if __name__ == "__main__": 699 if __name__ == "__main__":
691 sys.exit(main(sys.argv)) 700 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « SConstruct ('k') | tools/llvm/toolchain-creator.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698