| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 declare_args() { | 5 declare_args() { |
| 6 # The optimization level to use for debug builds. | 6 # The optimization level to use for debug builds. |
| 7 if (is_android) { | 7 if (is_android) { |
| 8 # On Android we kind of optimize some things that don't affect debugging | 8 # On Android we kind of optimize some things that don't affect debugging |
| 9 # much even when optimization is disabled to get the binary size down. | 9 # much even when optimization is disabled to get the binary size down. |
| 10 debug_optimization_level = "s" | 10 debug_optimization_level = "s" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 # well-defined C/C++ and Clang can optimize such checks away in | 123 # well-defined C/C++ and Clang can optimize such checks away in |
| 124 # release builds, but they may be used in asserts in debug builds. | 124 # release builds, but they may be used in asserts in debug builds. |
| 125 extra_flags = [ | 125 extra_flags = [ |
| 126 "-Wno-undefined-bool-conversion", | 126 "-Wno-undefined-bool-conversion", |
| 127 "-Wno-tautological-undefined-compare", | 127 "-Wno-tautological-undefined-compare", |
| 128 ] | 128 ] |
| 129 cflags_cc += extra_flags | 129 cflags_cc += extra_flags |
| 130 cflags_objcc += extra_flags | 130 cflags_objcc += extra_flags |
| 131 } | 131 } |
| 132 | 132 |
| 133 if (is_clang) { | |
| 134 # This is here so that all files get recompiled after a clang roll and | |
| 135 # when turning clang on or off. (defines are passed via the command line, | |
| 136 # and build system rebuild things when their commandline changes). Nothing | |
| 137 # should ever read this define. | |
| 138 defines += | |
| 139 [ "CR_CLANG_REVISION=" + exec_script("//tools/clang/scripts/update.py", | |
| 140 [ "--print-revision" ], | |
| 141 "trim string") ] | |
| 142 } | |
| 143 | |
| 144 # Mac-specific compiler flags setup. | 133 # Mac-specific compiler flags setup. |
| 145 # ---------------------------------- | 134 # ---------------------------------- |
| 146 if (is_mac) { | 135 if (is_mac) { |
| 147 # These flags are shared between the C compiler and linker. | 136 # These flags are shared between the C compiler and linker. |
| 148 common_mac_flags = [ "-fno-exceptions" ] | 137 common_mac_flags = [ "-fno-exceptions" ] |
| 149 | 138 |
| 150 # CPU architecture. | 139 # CPU architecture. |
| 151 if (current_cpu == "x64") { | 140 if (current_cpu == "x64") { |
| 152 common_mac_flags += [ | 141 common_mac_flags += [ |
| 153 "-arch", | 142 "-arch", |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 cflags += [ "-mllvm -asan-globals=0" ] | 347 cflags += [ "-mllvm -asan-globals=0" ] |
| 359 } | 348 } |
| 360 | 349 |
| 361 defines += [ "ANDROID" ] | 350 defines += [ "ANDROID" ] |
| 362 | 351 |
| 363 # The NDK has these things, but doesn't define the constants | 352 # The NDK has these things, but doesn't define the constants |
| 364 # to say that it does. Define them here instead. | 353 # to say that it does. Define them here instead. |
| 365 defines += [ "HAVE_SYS_UIO_H" ] | 354 defines += [ "HAVE_SYS_UIO_H" ] |
| 366 | 355 |
| 367 # Use gold for Android for most CPU architectures. | 356 # Use gold for Android for most CPU architectures. |
| 368 if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") { | 357 if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm" || |
| 358 current_cpu == "arm64") { |
| 369 ldflags += [ "-fuse-ld=gold" ] | 359 ldflags += [ "-fuse-ld=gold" ] |
| 370 if (is_clang) { | 360 if (is_clang) { |
| 371 # Let clang find the ld.gold in the NDK. | 361 # Let clang find the ld.gold in the NDK. |
| 372 ldflags += [ "--gcc-toolchain=" + | 362 toolchain_root = rebase_path(android_toolchain_root, root_build_dir) |
| 373 rebase_path(android_toolchain_root, root_build_dir) ] | 363 ldflags += [ "--gcc-toolchain=$toolchain_root" ] |
| 364 ldflags += [ "-B${toolchain_root}/bin" ] |
| 374 } | 365 } |
| 375 } | 366 } |
| 376 | 367 |
| 377 ldflags += [ | 368 ldflags += [ |
| 378 # Don't allow visible symbols from libgcc or libc++ to be | 369 # Don't allow visible symbols from libgcc or libc++ to be |
| 379 # re-exported. | 370 # re-exported. |
| 380 "-Wl,--exclude-libs=libgcc.a", | 371 "-Wl,--exclude-libs=libgcc.a", |
| 381 "-Wl,--exclude-libs=libc++_static.a", | 372 "-Wl,--exclude-libs=libc++_static.a", |
| 382 ] | 373 ] |
| 383 if (current_cpu == "arm") { | 374 if (current_cpu == "arm") { |
| 384 ldflags += [ | 375 ldflags += [ |
| 385 # Enable identical code folding to reduce size. | 376 # Enable identical code folding to reduce size. |
| 386 "-Wl,--icf=safe", | 377 "-Wl,--icf=safe", |
| 387 ] | 378 ] |
| 388 } | 379 } |
| 389 | 380 |
| 390 if (is_clang) { | 381 if (is_clang) { |
| 391 if (current_cpu == "arm") { | 382 if (current_cpu == "arm") { |
| 392 cflags += [ "--target=arm-linux-androideabi" ] | 383 cflags += [ "--target=arm-linux-androideabi" ] |
| 393 ldflags += [ "--target=arm-linux-androideabi" ] | 384 ldflags += [ "--target=arm-linux-androideabi" ] |
| 385 } else if (current_cpu == "arm64") { |
| 386 cflags += [ "--target=aarch64-linux-android" ] |
| 387 ldflags += [ "--target=aarch64-linux-android" ] |
| 394 } else if (current_cpu == "x86") { | 388 } else if (current_cpu == "x86") { |
| 395 cflags += [ "--target=x86-linux-androideabi" ] | 389 cflags += [ "--target=i686-linux-androideabi" ] |
| 396 ldflags += [ "--target=x86-linux-androideabi" ] | 390 ldflags += [ "--target=i686-linux-androideabi" ] |
| 391 } else if (current_cpu == "x64") { |
| 392 cflags += [ "--target=x86_64-linux-androideabi" ] |
| 393 ldflags += [ "--target=x86_64-linux-androideabi" ] |
| 397 } | 394 } |
| 398 } | 395 } |
| 399 } | 396 } |
| 400 | 397 |
| 401 # Assign any flags set for the C compiler to asmflags so that they are sent | 398 # Assign any flags set for the C compiler to asmflags so that they are sent |
| 402 # to the assembler. The Windows assembler takes different types of flags | 399 # to the assembler. The Windows assembler takes different types of flags |
| 403 # so only do so for posix platforms. | 400 # so only do so for posix platforms. |
| 404 if (is_posix) { | 401 if (is_posix) { |
| 405 asmflags += cflags | 402 asmflags += cflags |
| 406 asmflags += cflags_c | 403 asmflags += cflags_c |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 "_SCL_SECURE_NO_DEPRECATE", | 442 "_SCL_SECURE_NO_DEPRECATE", |
| 446 ] | 443 ] |
| 447 } | 444 } |
| 448 | 445 |
| 449 # Android standard library setup. | 446 # Android standard library setup. |
| 450 if (is_android) { | 447 if (is_android) { |
| 451 if (is_clang) { | 448 if (is_clang) { |
| 452 # Work around incompatibilities between bionic and clang headers. | 449 # Work around incompatibilities between bionic and clang headers. |
| 453 defines += [ | 450 defines += [ |
| 454 "__compiler_offsetof=__builtin_offsetof", | 451 "__compiler_offsetof=__builtin_offsetof", |
| 455 "nan=__builtin_nan", | |
| 456 ] | 452 ] |
| 457 } | 453 } |
| 458 | 454 |
| 459 defines += [ "__GNU_SOURCE=1" ] # Necessary for clone(). | 455 defines += [ "__GNU_SOURCE=1" ] # Necessary for clone(). |
| 460 | 456 |
| 461 # TODO(jdduke) Re-enable on mips after resolving linking | 457 # TODO(jdduke) Re-enable on mips after resolving linking |
| 462 # issues with libc++ (crbug.com/456380). | 458 # issues with libc++ (crbug.com/456380). |
| 463 if (current_cpu != "mipsel" && current_cpu != "mips64el") { | 459 if (current_cpu != "mipsel" && current_cpu != "mips64el") { |
| 464 ldflags += [ "-Wl,--warn-shared-textrel" ] | 460 ldflags += [ "-Wl,--warn-shared-textrel" ] |
| 465 } | 461 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 476 rebase_path("$android_libcpp_root/libcxx/include", root_build_dir), | 472 rebase_path("$android_libcpp_root/libcxx/include", root_build_dir), |
| 477 "-isystem" + rebase_path( | 473 "-isystem" + rebase_path( |
| 478 "$android_ndk_root/sources/cxx-stl/llvm-libc++abi/libcxxabi/includ
e", | 474 "$android_ndk_root/sources/cxx-stl/llvm-libc++abi/libcxxabi/includ
e", |
| 479 root_build_dir), | 475 root_build_dir), |
| 480 "-isystem" + | 476 "-isystem" + |
| 481 rebase_path("$android_ndk_root/sources/android/support/include", | 477 rebase_path("$android_ndk_root/sources/android/support/include", |
| 482 root_build_dir), | 478 root_build_dir), |
| 483 ] | 479 ] |
| 484 | 480 |
| 485 lib_dirs += [ "$android_libcpp_root/libs/$android_app_abi" ] | 481 lib_dirs += [ "$android_libcpp_root/libs/$android_app_abi" ] |
| 486 libs += [ "$android_libcpp_library" ] | |
| 487 | 482 |
| 488 if (current_cpu == "mipsel") { | 483 libs += [ |
| 489 libs += [ | 484 "$android_libcpp_library", |
| 490 # ld linker is used for mips Android, and ld does not accept library | 485 "c++abi", |
| 491 # absolute path prefixed by "-l"; Since libgcc does not exist in mips | 486 "android_support", |
| 492 # sysroot the proper library will be linked. | 487 ] |
| 493 # TODO(gordanac): Remove once gold linker is used for mips Android. | 488 |
| 494 "gcc", | 489 if (current_cpu == "arm") { |
| 495 ] | 490 libs += [ "unwind" ] |
| 496 } else { | |
| 497 libs += [ | |
| 498 # Manually link the libgcc.a that the cross compiler uses. This is | |
| 499 # absolute because the linker will look inside the sysroot if it's not. | |
| 500 rebase_path(android_libgcc_file), | |
| 501 ] | |
| 502 } | 491 } |
| 503 | 492 |
| 504 libs += [ | 493 libs += [ |
| 494 "gcc", |
| 505 "c", | 495 "c", |
| 506 "dl", | 496 "dl", |
| 507 "m", | 497 "m", |
| 508 ] | 498 ] |
| 509 | 499 |
| 510 # Clang with libc++ does not require an explicit atomic library reference. | 500 # Clang with libc++ does not require an explicit atomic library reference. |
| 511 if (!is_clang) { | 501 if (!is_clang) { |
| 512 libs += [ "atomic" ] | 502 libs += [ "atomic" ] |
| 513 } | 503 } |
| 514 } | 504 } |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. | 776 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. |
| 787 } | 777 } |
| 788 ldflags = [ "/DEBUG" ] | 778 ldflags = [ "/DEBUG" ] |
| 789 } else { | 779 } else { |
| 790 cflags = [ | 780 cflags = [ |
| 791 "-g3", | 781 "-g3", |
| 792 "-ggdb3", | 782 "-ggdb3", |
| 793 ] | 783 ] |
| 794 } | 784 } |
| 795 } | 785 } |
| OLD | NEW |