OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2013 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2013 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 """Recipes for PNaCl toolchain packages. | 6 """Recipes for PNaCl toolchain packages. |
7 | 7 |
8 Recipes consist of specially-structured dictionaries, with keys for package | 8 Recipes consist of specially-structured dictionaries, with keys for package |
9 name, type, commands to execute, etc. The structure is documented in the | 9 name, type, commands to execute, etc. The structure is documented in the |
10 PackageBuilder docstring in toolchain_main.py. | 10 PackageBuilder docstring in toolchain_main.py. |
11 | 11 |
12 The real entry plumbing and CLI flags are also in toolchain_main.py. | 12 The real entry plumbing and CLI flags are also in toolchain_main.py. |
13 """ | 13 """ |
14 | 14 |
15 import fnmatch | 15 import fnmatch |
16 import logging | 16 import logging |
17 import os | 17 import os |
18 import shutil | 18 import shutil |
| 19 import subprocess |
19 import sys | 20 import sys |
20 import zipfile | 21 import zipfile |
21 | 22 |
22 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 23 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
23 import pynacl.file_tools | 24 import pynacl.file_tools |
24 import pynacl.gsd_storage | 25 import pynacl.gsd_storage |
25 import pynacl.platform | 26 import pynacl.platform |
26 import pynacl.repo_tools | 27 import pynacl.repo_tools |
27 | 28 |
28 import command | 29 import command |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 # Path to the mingw cross-compiler libs on Ubuntu | 87 # Path to the mingw cross-compiler libs on Ubuntu |
87 CROSS_MINGW_LIBPATH = '/usr/lib/gcc/i686-w64-mingw32/4.6' | 88 CROSS_MINGW_LIBPATH = '/usr/lib/gcc/i686-w64-mingw32/4.6' |
88 # Path and version of the native mingw compiler to be installed on Windows hosts | 89 # Path and version of the native mingw compiler to be installed on Windows hosts |
89 MINGW_PATH = os.path.join(NACL_DIR, 'mingw32') | 90 MINGW_PATH = os.path.join(NACL_DIR, 'mingw32') |
90 MINGW_VERSION = 'i686-w64-mingw32-4.8.1' | 91 MINGW_VERSION = 'i686-w64-mingw32-4.8.1' |
91 | 92 |
92 CHROME_CLANG = os.path.join(os.path.dirname(NACL_DIR), 'third_party', | 93 CHROME_CLANG = os.path.join(os.path.dirname(NACL_DIR), 'third_party', |
93 'llvm-build', 'Release+Asserts', 'bin', 'clang') | 94 'llvm-build', 'Release+Asserts', 'bin', 'clang') |
94 CHROME_CLANGXX = CHROME_CLANG + '++' | 95 CHROME_CLANGXX = CHROME_CLANG + '++' |
95 | 96 |
| 97 # Required SDK version and target version for Mac builds. |
| 98 # See MAC_SDK_FLAGS, below. |
| 99 MAC_SDK_MIN = '10.10' |
| 100 MAC_DEPLOYMENT_TARGET = '10.6' |
| 101 |
96 # Redirectors are small shims acting like sym links with optional arguments. | 102 # Redirectors are small shims acting like sym links with optional arguments. |
97 # For mac/linux we simply use a shell script which create small redirector | 103 # For mac/linux we simply use a shell script which create small redirector |
98 # shell scripts. For windows we compile an executable which redirects to | 104 # shell scripts. For windows we compile an executable which redirects to |
99 # the target using a compiled in table. | 105 # the target using a compiled in table. |
100 REDIRECTOR_SCRIPT = os.path.join(NACL_TOOLS_DIR, 'create_redirector.sh') | 106 REDIRECTOR_SCRIPT = os.path.join(NACL_TOOLS_DIR, 'create_redirector.sh') |
101 REDIRECTOR_WIN32_SRC = os.path.join(NACL_TOOLS_DIR, 'redirector') | 107 REDIRECTOR_WIN32_SRC = os.path.join(NACL_TOOLS_DIR, 'redirector') |
102 | 108 |
103 TOOL_X64_I686_REDIRECTS = [ | 109 TOOL_X64_I686_REDIRECTS = [ |
104 #Toolname, Tool Args | 110 #Toolname, Tool Args |
105 ('as', '--32'), | 111 ('as', '--32'), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 149 |
144 def ProgramPath(program): | 150 def ProgramPath(program): |
145 """Returns the path for the given program, or None if it doesn't exist.""" | 151 """Returns the path for the given program, or None if it doesn't exist.""" |
146 try: | 152 try: |
147 return pynacl.file_tools.Which(program) | 153 return pynacl.file_tools.Which(program) |
148 except pynacl.file_tools.ExecutableNotFound: | 154 except pynacl.file_tools.ExecutableNotFound: |
149 pass | 155 pass |
150 return None | 156 return None |
151 | 157 |
152 | 158 |
| 159 # Determine the extra compiler flags necessary for Mac. Do this once at |
| 160 # top level, rather than every time in CompilersForHost, because running |
| 161 # the external script is costly. |
| 162 def MacSdkFlags(): |
| 163 if not pynacl.platform.IsMac(): |
| 164 return [] |
| 165 mac_sdk_sysroot, mac_sdk_version = subprocess.check_output([ |
| 166 sys.executable, |
| 167 os.path.join(os.path.dirname(NACL_DIR), 'build', 'mac', 'find_sdk.py'), |
| 168 '--print_sdk_path', |
| 169 MAC_SDK_MIN, |
| 170 ]).splitlines() |
| 171 return ['-isysroot', mac_sdk_sysroot, |
| 172 '-mmacosx-version-min=' + MAC_DEPLOYMENT_TARGET] |
| 173 |
| 174 MAC_SDK_FLAGS = MacSdkFlags() |
| 175 |
| 176 |
153 def InputsForCommands(commands): | 177 def InputsForCommands(commands): |
154 """Returns a dict of extra 'inputs' items for command names. | 178 """Returns a dict of extra 'inputs' items for command names. |
155 Each command name that is an absolute path gets an item named for | 179 Each command name that is an absolute path gets an item named for |
156 its basename. The logic here is that commands named by absolute | 180 its basename. The logic here is that commands named by absolute |
157 paths do not come from the system installation and hence those | 181 paths do not come from the system installation and hence those |
158 binaries themselves should be considered inputs for memoization. | 182 binaries themselves should be considered inputs for memoization. |
159 """ | 183 """ |
160 inputs = {} | 184 inputs = {} |
161 for command in commands: | 185 for command in commands: |
162 if os.path.isabs(command): | 186 if os.path.isabs(command): |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 joined_name = GSDJoin(component_name, host) | 246 joined_name = GSDJoin(component_name, host) |
223 if HostIsDebug(options): | 247 if HostIsDebug(options): |
224 joined_name= joined_name + '_debug' | 248 joined_name= joined_name + '_debug' |
225 return joined_name | 249 return joined_name |
226 | 250 |
227 | 251 |
228 def HostArchToolFlags(host, extra_cflags, opts): | 252 def HostArchToolFlags(host, extra_cflags, opts): |
229 """Return the appropriate CFLAGS, CXXFLAGS, and LDFLAGS based on host | 253 """Return the appropriate CFLAGS, CXXFLAGS, and LDFLAGS based on host |
230 and opts. Does not attempt to determine flags that are attached | 254 and opts. Does not attempt to determine flags that are attached |
231 to CC and CXX directly. | 255 to CC and CXX directly. |
| 256 |
| 257 Returns the tuple (flags, deps) where 'flags' is a dictionary mapping |
| 258 'CFLAGS' et al to a list of arguments, and 'deps' is a list of extra |
| 259 dependencies for a component using these flags. |
232 """ | 260 """ |
233 extra_cc_flags = list(extra_cflags) | 261 extra_cc_flags = list(extra_cflags) |
234 result = { 'LDFLAGS' : [], | 262 result = { 'LDFLAGS' : [], |
235 'CFLAGS' : [], | 263 'CFLAGS' : [], |
236 'CXXFLAGS' : []} | 264 'CXXFLAGS' : []} |
| 265 deps = [] |
237 if TripleIsWindows(host): | 266 if TripleIsWindows(host): |
238 result['LDFLAGS'] += ['-L%(abs_libdl)s', '-ldl'] | 267 result['LDFLAGS'] += ['-L%(abs_libdl)s', '-ldl'] |
239 result['CFLAGS'] += ['-isystem','%(abs_libdl)s'] | 268 result['CFLAGS'] += ['-isystem','%(abs_libdl)s'] |
240 result['CXXFLAGS'] += ['-isystem', '%(abs_libdl)s'] | 269 result['CXXFLAGS'] += ['-isystem', '%(abs_libdl)s'] |
| 270 deps.append('libdl') |
241 else: | 271 else: |
242 if TripleIsLinux(host) and not TripleIsX8664(host): | 272 if TripleIsLinux(host) and not TripleIsX8664(host): |
243 # Chrome clang defaults to 64-bit builds, even when run on 32-bit Linux. | 273 # Chrome clang defaults to 64-bit builds, even when run on 32-bit Linux. |
244 extra_cc_flags += ['-m32'] | 274 extra_cc_flags += ['-m32'] |
245 elif TripleIsMac(host): | |
246 # This is required for building with recent libc++ against OSX 10.6 | |
247 extra_cc_flags += ['-U__STRICT_ANSI__'] | |
248 if opts.gcc or host == 'le32-nacl': | 275 if opts.gcc or host == 'le32-nacl': |
249 result['CFLAGS'] += extra_cc_flags | 276 result['CFLAGS'] += extra_cc_flags |
250 result['CXXFLAGS'] += extra_cc_flags | 277 result['CXXFLAGS'] += extra_cc_flags |
251 else: | 278 else: |
252 result['CFLAGS'] += extra_cc_flags | 279 result['CFLAGS'] += extra_cc_flags |
253 result['LDFLAGS'] += ['-L%(' + FlavoredName('abs_libcxx', | 280 result['LDFLAGS'] += ['-L%(' + FlavoredName('abs_libcxx', |
254 host, opts) + ')s/lib'] | 281 host, opts) + ')s/lib'] |
255 result['CXXFLAGS'] += ([ | 282 result['CXXFLAGS'] += ([ |
256 '-stdlib=libc++', | 283 '-stdlib=libc++', |
257 '-I%(' + FlavoredName('abs_libcxx', host, opts) + ')s/include/c++/v1'] + | 284 '-I%(' + FlavoredName('abs_libcxx', host, opts) + ')s/include/c++/v1'] + |
258 extra_cc_flags) | 285 extra_cc_flags) |
259 return result | 286 deps.append(FlavoredName('libcxx', host, opts)) |
| 287 return result, deps |
260 | 288 |
261 | 289 |
262 def ConfigureHostArchFlags(host, extra_cflags, options, extra_configure=None, | 290 def ConfigureHostArchFlags(host, extra_cflags, options, extra_configure=None, |
263 use_afl_fuzz=False): | 291 use_afl_fuzz=False): |
264 """Return flags passed to LLVM and binutils configure for compilers and | 292 """Return flags passed to LLVM and binutils configure for compilers and |
265 compile flags. | 293 compile flags. |
266 | 294 |
267 Returns the tuple (flags, inputs) where 'flags' is a list of arguments to | 295 Returns the tuple (flags, inputs, deps) where 'flags' is a list of |
268 configure and 'inputs' is a dict of extra inputs to be hashed. | 296 arguments to configure, 'inputs' is a dict of extra inputs to be hashed, |
| 297 and 'deps' is a list of extra dependencies for a component using these flags. |
269 """ | 298 """ |
270 configure_args = [] | 299 configure_args = [] |
271 extra_cc_args = [] | 300 extra_cc_args = [] |
272 | 301 |
273 configure_args += options.extra_configure_args | 302 configure_args += options.extra_configure_args |
274 if extra_configure is not None: | 303 if extra_configure is not None: |
275 configure_args += extra_configure | 304 configure_args += extra_configure |
276 if options.extra_cc_args is not None: | 305 if options.extra_cc_args is not None: |
277 extra_cc_args += [options.extra_cc_args] | 306 extra_cc_args += [options.extra_cc_args] |
278 | 307 |
(...skipping 28 matching lines...) Expand all Loading... |
307 # ccache/clang++ interaction. Specifically, errors about | 336 # ccache/clang++ interaction. Specifically, errors about |
308 # "argument unused during compilation". | 337 # "argument unused during compilation". |
309 os.environ['CCACHE_CPP2'] = 'yes' | 338 os.environ['CCACHE_CPP2'] = 'yes' |
310 cc_list = ['ccache', cc] | 339 cc_list = ['ccache', cc] |
311 cxx_list = ['ccache', cxx] | 340 cxx_list = ['ccache', cxx] |
312 extra_cc_args += ['-Qunused-arguments'] | 341 extra_cc_args += ['-Qunused-arguments'] |
313 extra_cxx_args += ['-Qunused-arguments'] | 342 extra_cxx_args += ['-Qunused-arguments'] |
314 else: | 343 else: |
315 cc_list = [cc] | 344 cc_list = [cc] |
316 cxx_list = [cxx] | 345 cxx_list = [cxx] |
| 346 |
| 347 if TripleIsMac(host): |
| 348 cc_list += MAC_SDK_FLAGS |
| 349 cxx_list += MAC_SDK_FLAGS |
| 350 |
317 configure_args.append('CC=' + ' '.join(cc_list + extra_cc_args)) | 351 configure_args.append('CC=' + ' '.join(cc_list + extra_cc_args)) |
318 configure_args.append('CXX=' + ' '.join(cxx_list + extra_cxx_args)) | 352 configure_args.append('CXX=' + ' '.join(cxx_list + extra_cxx_args)) |
319 configure_args.append('AR=' + ar) | 353 configure_args.append('AR=' + ar) |
320 configure_args.append('RANLIB=' + ranlib) | 354 configure_args.append('RANLIB=' + ranlib) |
321 | 355 |
322 tool_flags = HostArchToolFlags(host, extra_cflags, options) | 356 tool_flags, tool_deps = HostArchToolFlags(host, extra_cflags, options) |
323 configure_args.extend( | 357 configure_args.extend( |
324 ['CFLAGS=' + ' '.join(tool_flags['CFLAGS']), | 358 ['CFLAGS=' + ' '.join(tool_flags['CFLAGS']), |
325 'CXXFLAGS=' + ' '.join(tool_flags['CXXFLAGS']), | 359 'CXXFLAGS=' + ' '.join(tool_flags['CXXFLAGS']), |
326 'LDFLAGS=' + ' '.join(tool_flags['LDFLAGS']), | 360 'LDFLAGS=' + ' '.join(tool_flags['LDFLAGS']), |
327 ]) | 361 ]) |
328 if TripleIsWindows(host): | 362 if TripleIsWindows(host): |
329 # The i18n support brings in runtime dependencies on MinGW DLLs | 363 # The i18n support brings in runtime dependencies on MinGW DLLs |
330 # that we don't want to have to distribute alongside our binaries. | 364 # that we don't want to have to distribute alongside our binaries. |
331 # So just disable it, and compiler messages will always be in US English. | 365 # So just disable it, and compiler messages will always be in US English. |
332 configure_args.append('--disable-nls') | 366 configure_args.append('--disable-nls') |
333 if is_cross: | 367 if is_cross: |
334 # LLVM's linux->mingw cross build needs this | 368 # LLVM's linux->mingw cross build needs this |
335 configure_args.append('CC_FOR_BUILD=gcc') | 369 configure_args.append('CC_FOR_BUILD=gcc') |
336 return configure_args, InputsForCommands(hashables) | 370 return configure_args, InputsForCommands(hashables), tool_deps |
337 | 371 |
338 | 372 |
339 def LibCxxHostArchFlags(host): | 373 def LibCxxHostArchFlags(host): |
340 cc, cxx, _, _ = CompilersForHost(host) | 374 cc, cxx, _, _ = CompilersForHost(host) |
341 hashables = [cc, cxx] | 375 hashables = [cc, cxx] |
342 cmake_flags = [] | 376 cmake_flags = [] |
343 cmake_flags.extend(['-DCMAKE_C_COMPILER='+cc, '-DCMAKE_CXX_COMPILER='+cxx]) | 377 cmake_flags.extend(['-DCMAKE_C_COMPILER='+cc, '-DCMAKE_CXX_COMPILER='+cxx]) |
344 if TripleIsLinux(host) and not TripleIsX8664(host): | 378 if TripleIsLinux(host) and not TripleIsX8664(host): |
345 # Chrome clang defaults to 64-bit builds, even when run on 32-bit Linux | 379 # Chrome clang defaults to 64-bit builds, even when run on 32-bit Linux |
346 cmake_flags.extend(['-DCMAKE_C_FLAGS=-m32', | 380 cmake_flags.extend(['-DCMAKE_C_FLAGS=-m32', |
347 '-DCMAKE_CXX_FLAGS=-m32']) | 381 '-DCMAKE_CXX_FLAGS=-m32']) |
| 382 elif TripleIsMac(host): |
| 383 sdk_flags = ' '.join(MAC_SDK_FLAGS) |
| 384 cmake_flags.extend(['-DCMAKE_C_FLAGS=' + sdk_flags, |
| 385 '-DCMAKE_CXX_FLAGS=' + sdk_flags]) |
348 return cmake_flags, InputsForCommands(hashables) | 386 return cmake_flags, InputsForCommands(hashables) |
349 | 387 |
350 | 388 |
351 def CmakeHostArchFlags(host, options): | 389 def CmakeHostArchFlags(host, options): |
352 """Set flags passed to LLVM cmake for compilers and compile flags. | 390 """Set flags passed to LLVM cmake for compilers and compile flags. |
353 | 391 |
354 Returns the tuple (flags, inputs) where 'flags' is a list of arguments to | 392 Returns the tuple (flags, inputs, deps) where 'flags' is a list of |
355 cmake and 'inputs' is a dict of extra inputs to be hashed. | 393 arguments to cmake, 'inputs' is a dict of extra inputs to be hashed, |
| 394 and 'deps' is a list of extra dependencies for a component using these flags. |
356 """ | 395 """ |
357 cmake_flags = [] | 396 cmake_flags = [] |
358 if options.afl_fuzz_dir: | 397 if options.afl_fuzz_dir: |
359 cc, cxx = AflFuzzCompilers(options.afl_fuzz_dir) | 398 cc, cxx = AflFuzzCompilers(options.afl_fuzz_dir) |
360 else: | 399 else: |
361 cc, cxx, _, _ = CompilersForHost(host) | 400 cc, cxx, _, _ = CompilersForHost(host) |
362 hashables = [cc, cxx] | 401 hashables = [cc, cxx] |
363 | 402 |
364 cmake_flags.extend(['-DCMAKE_C_COMPILER='+cc, '-DCMAKE_CXX_COMPILER='+cxx]) | 403 cmake_flags.extend(['-DCMAKE_C_COMPILER='+cc, '-DCMAKE_CXX_COMPILER='+cxx]) |
365 if ProgramPath('ccache'): | 404 if ProgramPath('ccache'): |
366 cmake_flags.extend(['-DSYSTEM_HAS_CCACHE=ON']) | 405 cmake_flags.extend(['-DSYSTEM_HAS_CCACHE=ON']) |
367 | 406 |
368 # There seems to be a bug in chrome clang where it exposes the msan interface | 407 # There seems to be a bug in chrome clang where it exposes the msan interface |
369 # (even when compiling without msan) but then does not link with an | 408 # (even when compiling without msan) but then does not link with an |
370 # msan-enabled compiler_rt, leaving references to __msan_allocated_memory | 409 # msan-enabled compiler_rt, leaving references to __msan_allocated_memory |
371 # undefined. | 410 # undefined. |
372 cmake_flags.append('-DHAVE_SANITIZER_MSAN_INTERFACE_H=FALSE') | 411 cmake_flags.append('-DHAVE_SANITIZER_MSAN_INTERFACE_H=FALSE') |
373 tool_flags = HostArchToolFlags(host, [], options) | 412 tool_flags, tool_deps = HostArchToolFlags(host, [], options) |
374 cmake_flags.extend(['-DCMAKE_C_FLAGS=' + ' '.join(tool_flags['CFLAGS'])]) | 413 cflags = tool_flags['CFLAGS'] |
375 cmake_flags.extend(['-DCMAKE_CXX_FLAGS=' + ' '.join(tool_flags['CXXFLAGS'])]) | 414 cxxflags = tool_flags['CXXFLAGS'] |
| 415 if TripleIsMac(host): |
| 416 cflags = MAC_SDK_FLAGS + cflags |
| 417 cxxflags = MAC_SDK_FLAGS + cxxflags |
| 418 cmake_flags.append('-DCMAKE_C_FLAGS=' + ' '.join(cflags)) |
| 419 cmake_flags.append('-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags)) |
376 for linker_type in ['EXE', 'SHARED', 'MODULE']: | 420 for linker_type in ['EXE', 'SHARED', 'MODULE']: |
377 cmake_flags.extend([('-DCMAKE_%s_LINKER_FLAGS=' % linker_type) + | 421 cmake_flags.extend([('-DCMAKE_%s_LINKER_FLAGS=' % linker_type) + |
378 ' '.join(tool_flags['LDFLAGS'])]) | 422 ' '.join(tool_flags['LDFLAGS'])]) |
379 return cmake_flags, InputsForCommands(hashables) | 423 return cmake_flags, InputsForCommands(hashables), tool_deps |
380 | 424 |
381 | 425 |
382 def ConfigureBinutilsCommon(): | 426 def ConfigureBinutilsCommon(host, options, is_pnacl): |
383 return ['--with-pkgversion=' + PACKAGE_NAME, | 427 # Binutils still has some warnings when building with clang |
384 '--with-bugurl=' + BUG_URL, | 428 if not options.gcc: |
385 '--without-zlib', | 429 warning_flags = ['-Wno-extended-offsetof', '-Wno-absolute-value', |
386 '--prefix=', | 430 '-Wno-unused-function', '-Wno-unused-const-variable', |
387 '--disable-silent-rules', | 431 '-Wno-unneeded-internal-declaration', |
388 '--enable-deterministic-archives', | 432 '-Wno-unused-private-field', '-Wno-format-security'] |
389 ] | 433 else: |
| 434 warning_flags = ['-Wno-unused-function', '-Wno-unused-value'] |
| 435 |
| 436 host_arch_flags, inputs, deps = ConfigureHostArchFlags( |
| 437 host, warning_flags, options, |
| 438 options.binutils_pnacl_extra_configure if is_pnacl else None) |
| 439 |
| 440 flags = [ |
| 441 '--with-pkgversion=' + PACKAGE_NAME, |
| 442 '--with-bugurl=' + BUG_URL, |
| 443 '--without-zlib', |
| 444 '--prefix=', |
| 445 '--disable-silent-rules', |
| 446 '--enable-deterministic-archives', |
| 447 ] + host_arch_flags |
| 448 |
| 449 return flags, inputs, deps |
390 | 450 |
391 def LLVMConfigureAssertionsFlags(options): | 451 def LLVMConfigureAssertionsFlags(options): |
392 if options.enable_llvm_assertions: | 452 if options.enable_llvm_assertions: |
393 return [] | 453 return [] |
394 else: | 454 else: |
395 return ['--disable-debug', '--disable-assertions'] | 455 return ['--disable-debug', '--disable-assertions'] |
396 | 456 |
397 | 457 |
398 def MakeCommand(host): | 458 def MakeCommand(host): |
399 make_command = ['make'] | 459 make_command = ['make'] |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 # TODO(mcgrathr): With post-3.7 Clang, binutils (opcodes) build gets: | 675 # TODO(mcgrathr): With post-3.7 Clang, binutils (opcodes) build gets: |
616 # error: shifting a negative signed value is undefined | 676 # error: shifting a negative signed value is undefined |
617 # [-Werror,-Wshift-negative-value] | 677 # [-Werror,-Wshift-negative-value] |
618 binutils_do_werror = False | 678 binutils_do_werror = False |
619 extra_gold_deps = [] | 679 extra_gold_deps = [] |
620 if host == 'le32-nacl': | 680 if host == 'le32-nacl': |
621 # TODO(bradnelson): Fix warnings so this can go away. | 681 # TODO(bradnelson): Fix warnings so this can go away. |
622 binutils_do_werror = False | 682 binutils_do_werror = False |
623 extra_gold_deps = [H('llvm')] | 683 extra_gold_deps = [H('llvm')] |
624 | 684 |
625 # Binutils still has some warnings when building with clang | |
626 if not options.gcc: | |
627 warning_flags = ['-Wno-extended-offsetof', '-Wno-absolute-value', | |
628 '-Wno-unused-function', '-Wno-unused-const-variable', | |
629 '-Wno-unneeded-internal-declaration', | |
630 '-Wno-unused-private-field', '-Wno-format-security'] | |
631 else: | |
632 warning_flags = ['-Wno-unused-function', '-Wno-unused-value'] | |
633 | |
634 # The binutils git checkout includes all the directories in the | 685 # The binutils git checkout includes all the directories in the |
635 # upstream binutils-gdb.git repository, but some of these | 686 # upstream binutils-gdb.git repository, but some of these |
636 # directories are not included in a binutils release tarball. The | 687 # directories are not included in a binutils release tarball. The |
637 # top-level Makefile will try to build whichever of the whole set | 688 # top-level Makefile will try to build whichever of the whole set |
638 # exist, but we don't want these extra directories built. So we | 689 # exist, but we don't want these extra directories built. So we |
639 # stub them out by creating dummy <subdir>/Makefile files; having | 690 # stub them out by creating dummy <subdir>/Makefile files; having |
640 # these exist before the configure-<subdir> target in the | 691 # these exist before the configure-<subdir> target in the |
641 # top-level Makefile runs prevents it from doing anything. | 692 # top-level Makefile runs prevents it from doing anything. |
642 binutils_dummy_dirs = ['gdb', 'libdecnumber', 'readline', 'sim'] | 693 binutils_dummy_dirs = ['gdb', 'libdecnumber', 'readline', 'sim'] |
643 def DummyDirCommands(dirs): | 694 def DummyDirCommands(dirs): |
644 dummy_makefile = """\ | 695 dummy_makefile = """\ |
645 .DEFAULT:;@echo Ignoring $@ | 696 .DEFAULT:;@echo Ignoring $@ |
646 """ | 697 """ |
647 commands = [] | 698 commands = [] |
648 for dir in dirs: | 699 for dir in dirs: |
649 commands.append(command.Mkdir(dir)) | 700 commands.append(command.Mkdir(dir)) |
650 commands.append(command.WriteData( | 701 commands.append(command.WriteData( |
651 dummy_makefile, command.path.join(dir, 'Makefile'))) | 702 dummy_makefile, command.path.join(dir, 'Makefile'))) |
652 return commands | 703 return commands |
653 | 704 |
654 binutils_host_arch_flags, binutils_inputs = ConfigureHostArchFlags( | 705 binutils_flags, binutils_inputs, binutils_deps = ConfigureBinutilsCommon( |
655 host, warning_flags, options, options.binutils_pnacl_extra_configure) | 706 host, options, True) |
656 binutils_inputs.update({'macros': os.path.join( | 707 binutils_inputs['macros'] = os.path.join( |
657 NACL_DIR, 'pnacl', 'support', 'clang_direct', 'nacl-arm-macros.s')}) | 708 NACL_DIR, 'pnacl', 'support', 'clang_direct', 'nacl-arm-macros.s') |
658 tools = { | 709 tools = { |
659 # The binutils_pnacl package is used both for bitcode linking (gold) and | 710 # The binutils_pnacl package is used both for bitcode linking (gold) and |
660 # for its conventional use with arm-nacl-clang. | 711 # for its conventional use with arm-nacl-clang. |
661 H('binutils_pnacl'): { | 712 H('binutils_pnacl'): { |
662 'dependencies': ['binutils_pnacl_src'] + extra_gold_deps, | 713 'dependencies': (['binutils_pnacl_src'] + |
| 714 extra_gold_deps + binutils_deps), |
663 'type': 'build', | 715 'type': 'build', |
664 'inputs' : binutils_inputs, | 716 'inputs' : binutils_inputs, |
665 'commands': [ | 717 'commands': [ |
666 command.SkipForIncrementalCommand([ | 718 command.SkipForIncrementalCommand([ |
667 'sh', | 719 'sh', |
668 '%(binutils_pnacl_src)s/configure'] + | 720 '%(binutils_pnacl_src)s/configure'] + binutils_flags + |
669 ConfigureBinutilsCommon() + binutils_host_arch_flags + | |
670 [ | 721 [ |
671 '--enable-gold=yes', | 722 '--enable-gold=yes', |
672 '--enable-plugins', | 723 '--enable-plugins', |
673 '--enable-shared=no', | 724 '--enable-shared=no', |
674 '--enable-targets=arm-nacl,i686-nacl,x86_64-nacl,mipsel-nacl', | 725 '--enable-targets=arm-nacl,i686-nacl,x86_64-nacl,mipsel-nacl', |
675 '--enable-werror=' + ('yes' if binutils_do_werror else 'no'), | 726 '--enable-werror=' + ('yes' if binutils_do_werror else 'no'), |
676 '--program-prefix=le32-nacl-', | 727 '--program-prefix=le32-nacl-', |
677 '--target=arm-nacl', | 728 '--target=arm-nacl', |
678 '--with-sysroot=/le32-nacl', | 729 '--with-sysroot=/le32-nacl', |
679 '--without-gas' | 730 '--without-gas' |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 # TODO(mcgrathr): The latest Clang gets -Wredunant-move errors under | 790 # TODO(mcgrathr): The latest Clang gets -Wredunant-move errors under |
740 # -Werror, and llvm's configure makes it difficult to get -Wno-... options | 791 # -Werror, and llvm's configure makes it difficult to get -Wno-... options |
741 # in the place they need to be, so just disable -Werror for now. | 792 # in the place they need to be, so just disable -Werror for now. |
742 # After the next LLVM merge, the LLVM sources will probably be compatible | 793 # After the next LLVM merge, the LLVM sources will probably be compatible |
743 # with the latest Clang and -Werror. | 794 # with the latest Clang and -Werror. |
744 llvm_do_werror = False and not (TripleIsWindows(host) or options.gcc) | 795 llvm_do_werror = False and not (TripleIsWindows(host) or options.gcc) |
745 | 796 |
746 # Older CMake ignore CMAKE_*_LINKER_FLAGS during config step. | 797 # Older CMake ignore CMAKE_*_LINKER_FLAGS during config step. |
747 # https://public.kitware.com/Bug/view.php?id=14066 | 798 # https://public.kitware.com/Bug/view.php?id=14066 |
748 # The workaround is to set LDFLAGS in the environment. | 799 # The workaround is to set LDFLAGS in the environment. |
749 llvm_cmake_config_env = {'LDFLAGS': ' '.join( | 800 tool_flags, tool_deps = HostArchToolFlags(host, [], options) |
750 HostArchToolFlags(host, [], options)['LDFLAGS'])} | 801 llvm_cmake_config_env = {'LDFLAGS': ' '.join(tool_flags['LDFLAGS'])} |
751 llvm_cmake_config_env.update(AflFuzzEnvMap(host, options)) | 802 llvm_cmake_config_env.update(AflFuzzEnvMap(host, options)) |
752 | 803 |
753 llvm_host_arch_flags, llvm_inputs = CmakeHostArchFlags(host, options) | 804 llvm_host_arch_flags, llvm_inputs, llvm_deps = CmakeHostArchFlags( |
754 llvm_inputs.update({'test_xfails': os.path.join(NACL_DIR, | 805 host, options) |
755 'pnacl', 'scripts')}) | 806 llvm_deps = list(set(tool_deps + llvm_deps)) |
| 807 llvm_inputs['test_xfails'] = os.path.join(NACL_DIR, 'pnacl', 'scripts') |
756 llvm_cmake = { | 808 llvm_cmake = { |
757 H('llvm'): { | 809 H('llvm'): { |
758 'dependencies': ['clang_src', 'llvm_src', 'binutils_pnacl_src', | 810 'dependencies': ['clang_src', 'llvm_src', 'binutils_pnacl_src', |
759 'subzero_src'], | 811 'subzero_src'] + llvm_deps, |
760 'inputs': llvm_inputs, | 812 'inputs': llvm_inputs, |
761 'type': 'build', | 813 'type': 'build', |
762 'commands': [ | 814 'commands': [ |
763 command.SkipForIncrementalCommand([ | 815 command.SkipForIncrementalCommand([ |
764 'cmake', '-G', 'Ninja'] + | 816 'cmake', '-G', 'Ninja'] + |
765 llvm_host_arch_flags + asan_flags + | 817 llvm_host_arch_flags + asan_flags + |
766 [ | 818 [ |
767 '-DBUILD_SHARED_LIBS=ON', | 819 '-DBUILD_SHARED_LIBS=ON', |
768 '-DCMAKE_BUILD_TYPE=' + ('Debug' if HostIsDebug(options) | 820 '-DCMAKE_BUILD_TYPE=' + ('Debug' if HostIsDebug(options) |
769 else 'Release'), | 821 else 'Release'), |
(...skipping 21 matching lines...) Expand all Loading... |
791 }, | 843 }, |
792 } | 844 } |
793 cleanup_static_libs = [] | 845 cleanup_static_libs = [] |
794 shared = [] | 846 shared = [] |
795 if host != 'le32-nacl': | 847 if host != 'le32-nacl': |
796 shared = ['--enable-shared'] | 848 shared = ['--enable-shared'] |
797 cleanup_static_libs = [ | 849 cleanup_static_libs = [ |
798 command.Remove(*[os.path.join('%(output)s', 'lib', f) for f | 850 command.Remove(*[os.path.join('%(output)s', 'lib', f) for f |
799 in '*.a', '*Hello.*', 'BugpointPasses.*']), | 851 in '*.a', '*Hello.*', 'BugpointPasses.*']), |
800 ] | 852 ] |
801 llvm_host_arch_flags, llvm_inputs = ConfigureHostArchFlags( | 853 llvm_host_arch_flags, llvm_inputs, llvm_deps = ConfigureHostArchFlags( |
802 host, [], options, use_afl_fuzz=options.afl_fuzz_dir) | 854 host, [], options, use_afl_fuzz=options.afl_fuzz_dir) |
803 llvm_inputs.update({'test_xfails': os.path.join(NACL_DIR, | 855 llvm_inputs.update({'test_xfails': os.path.join(NACL_DIR, |
804 'pnacl', 'scripts')}) | 856 'pnacl', 'scripts')}) |
805 llvm_autoconf = { | 857 llvm_autoconf = { |
806 H('llvm'): { | 858 H('llvm'): { |
807 'dependencies': ['clang_src', 'llvm_src', 'binutils_pnacl_src', | 859 'dependencies': ['clang_src', 'llvm_src', 'binutils_pnacl_src', |
808 'subzero_src'], | 860 'subzero_src'] + llvm_deps, |
809 'inputs': llvm_inputs, | 861 'inputs': llvm_inputs, |
810 'type': 'build', | 862 'type': 'build', |
811 'commands': [ | 863 'commands': [ |
812 command.SkipForIncrementalCommand([ | 864 command.SkipForIncrementalCommand([ |
813 'sh', | 865 'sh', |
814 '%(llvm_src)s/configure'] + | 866 '%(llvm_src)s/configure'] + |
815 AflFuzzEnvList(host, options) + | 867 AflFuzzEnvList(host, options) + |
816 llvm_host_arch_flags + | 868 llvm_host_arch_flags + |
817 LLVMConfigureAssertionsFlags(options) + | 869 LLVMConfigureAssertionsFlags(options) + |
818 [ | 870 [ |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 Exe('c-index-test'), Exe('clang-tblgen'), | 908 Exe('c-index-test'), Exe('clang-tblgen'), |
857 Exe('llvm-tblgen')])] + | 909 Exe('llvm-tblgen')])] + |
858 CreateSymLinksToDirectToNaClTools(host) + | 910 CreateSymLinksToDirectToNaClTools(host) + |
859 CopyWindowsHostLibs(host), | 911 CopyWindowsHostLibs(host), |
860 }, | 912 }, |
861 } | 913 } |
862 if options.cmake: | 914 if options.cmake: |
863 tools.update(llvm_cmake) | 915 tools.update(llvm_cmake) |
864 else: | 916 else: |
865 tools.update(llvm_autoconf) | 917 tools.update(llvm_autoconf) |
866 if TripleIsWindows(host): | |
867 tools[H('binutils_pnacl')]['dependencies'].append('libdl') | |
868 tools[H('llvm')]['dependencies'].append('libdl') | |
869 elif not options.gcc and host != 'le32-nacl': | |
870 tools[H('binutils_pnacl')]['dependencies'].append(H('libcxx')) | |
871 tools[H('llvm')]['dependencies'].append(H('libcxx')) | |
872 return tools | 918 return tools |
873 | 919 |
874 | 920 |
875 def TargetLibCompiler(host, options): | 921 def TargetLibCompiler(host, options): |
876 def H(component_name): | 922 def H(component_name): |
877 return FlavoredName(component_name, host, options) | 923 return FlavoredName(component_name, host, options) |
878 compiler = { | 924 compiler = { |
879 # Because target_lib_compiler is not a memoized target, its name doesn't | 925 # Because target_lib_compiler is not a memoized target, its name doesn't |
880 # need to have the host appended to it (it can be different on different | 926 # need to have the host appended to it (it can be different on different |
881 # hosts), which means that target library build rules don't have to care | 927 # hosts), which means that target library build rules don't have to care |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 redirect_deps = [] | 1016 redirect_deps = [] |
971 redirect_inputs = { 'redirector_script': REDIRECTOR_SCRIPT } | 1017 redirect_inputs = { 'redirector_script': REDIRECTOR_SCRIPT } |
972 redirect_cmds = [ | 1018 redirect_cmds = [ |
973 command.Command([ | 1019 command.Command([ |
974 '%(abs_redirector_script)s', | 1020 '%(abs_redirector_script)s', |
975 command.path.join('%(output)s', 'bin', 'i686-nacl-' + tool), | 1021 command.path.join('%(output)s', 'bin', 'i686-nacl-' + tool), |
976 'x86_64-nacl-' + tool, | 1022 'x86_64-nacl-' + tool, |
977 args]) | 1023 args]) |
978 for tool, args in TOOL_X64_I686_REDIRECTS] | 1024 for tool, args in TOOL_X64_I686_REDIRECTS] |
979 | 1025 |
| 1026 binutils_flags, binutils_inputs, binutils_deps = ConfigureBinutilsCommon( |
| 1027 host, options, False) |
| 1028 redirect_inputs.update(binutils_inputs) |
980 tools.update({ | 1029 tools.update({ |
981 H('binutils_x86'): { | 1030 H('binutils_x86'): { |
982 'type': 'build', | 1031 'type': 'build', |
983 'dependencies': ['binutils_x86_src'] + redirect_deps, | 1032 'dependencies': ['binutils_x86_src'] + redirect_deps + binutils_deps, |
984 'inputs': redirect_inputs, | 1033 'inputs': redirect_inputs, |
985 'commands': [ | 1034 'commands': [ |
986 command.SkipForIncrementalCommand( | 1035 command.SkipForIncrementalCommand( |
987 ['sh', '%(binutils_x86_src)s/configure'] + | 1036 ['sh', '%(binutils_x86_src)s/configure'] + binutils_flags + |
988 ConfigureBinutilsCommon() + | |
989 ['--target=x86_64-nacl', | 1037 ['--target=x86_64-nacl', |
990 '--enable-gold', | 1038 # TODO(mcgrathr): Enable gold if we rebase to 2.25. |
| 1039 # The 2.24 gold sources are not compatible with the libc++ |
| 1040 # version we use to build. |
| 1041 '--disable-gold', |
991 '--enable-targets=x86_64-nacl,i686-nacl', | 1042 '--enable-targets=x86_64-nacl,i686-nacl', |
992 '--disable-werror']), | 1043 '--disable-werror']), |
993 command.Command(MakeCommand(host)), | 1044 command.Command(MakeCommand(host)), |
994 command.Command(MAKE_DESTDIR_CMD + ['install-strip'])] + | 1045 command.Command(MAKE_DESTDIR_CMD + ['install-strip'])] + |
995 # Remove the share dir from this binutils build and leave the one | 1046 # Remove the share dir from this binutils build and leave the one |
996 # from the newer version used for bitcode linking. Always remove | 1047 # from the newer version used for bitcode linking. Always remove |
997 # the lib dirs, which have unneeded host libs. | 1048 # the lib dirs, which have unneeded host libs. |
998 [command.RemoveDirectory(os.path.join('%(output)s', dir)) | 1049 [command.RemoveDirectory(os.path.join('%(output)s', dir)) |
999 for dir in ('lib', 'lib32', 'lib64', 'share')] + | 1050 for dir in ('lib', 'lib32', 'lib64', 'share')] + |
1000 # Create the set of directories for target libs and includes, for | 1051 # Create the set of directories for target libs and includes, for |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 SANDBOXED_TRANSLATOR_ARCHES)) | 1342 SANDBOXED_TRANSLATOR_ARCHES)) |
1292 | 1343 |
1293 tb = toolchain_main.PackageBuilder(packages, | 1344 tb = toolchain_main.PackageBuilder(packages, |
1294 upload_packages, | 1345 upload_packages, |
1295 leftover_args) | 1346 leftover_args) |
1296 return tb.Main() | 1347 return tb.Main() |
1297 | 1348 |
1298 | 1349 |
1299 if __name__ == '__main__': | 1350 if __name__ == '__main__': |
1300 sys.exit(main()) | 1351 sys.exit(main()) |
OLD | NEW |