| 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 ldflags += [ "--gcc-toolchain=" + |
| 373 rebase_path(android_toolchain_root, root_build_dir) ] | 363 rebase_path(android_toolchain_root, root_build_dir) ] |
| 374 } | 364 } |
| 375 } | 365 } |
| 376 | 366 |
| 377 ldflags += [ | 367 ldflags += [ |
| 378 # Don't allow visible symbols from libgcc or libc++ to be | 368 # Don't re-export visible symbols from libraries. |
| 379 # re-exported. | 369 "-Wl,--exclude-libs,ALL", |
| 380 "-Wl,--exclude-libs=libgcc.a", | |
| 381 "-Wl,--exclude-libs=libc++_static.a", | |
| 382 ] | 370 ] |
| 383 if (current_cpu == "arm") { | 371 if (current_cpu == "arm") { |
| 384 ldflags += [ | 372 ldflags += [ |
| 385 # Enable identical code folding to reduce size. | 373 # Enable identical code folding to reduce size. |
| 386 "-Wl,--icf=safe", | 374 "-Wl,--icf=safe", |
| 387 ] | 375 ] |
| 388 } | 376 } |
| 389 | 377 |
| 390 if (is_clang) { | 378 if (is_clang) { |
| 391 if (current_cpu == "arm") { | 379 if (current_cpu == "arm") { |
| 392 cflags += [ "--target=arm-linux-androideabi" ] | 380 cflags += [ "--target=arm-linux-androideabi" ] |
| 393 ldflags += [ "--target=arm-linux-androideabi" ] | 381 ldflags += [ "--target=arm-linux-androideabi" ] |
| 382 } else if (current_cpu == "arm64") { |
| 383 cflags += [ "--target=aarch64-linux-android" ] |
| 384 ldflags += [ "--target=aarch64-linux-android" ] |
| 394 } else if (current_cpu == "x86") { | 385 } else if (current_cpu == "x86") { |
| 395 cflags += [ "--target=x86-linux-androideabi" ] | 386 cflags += [ "--target=i686-linux-androideabi" ] |
| 396 ldflags += [ "--target=x86-linux-androideabi" ] | 387 ldflags += [ "--target=i686-linux-androideabi" ] |
| 388 } else if (current_cpu == "x64") { |
| 389 cflags += [ "--target=x86_64-linux-androideabi" ] |
| 390 ldflags += [ "--target=x86_64-linux-androideabi" ] |
| 397 } | 391 } |
| 398 } | 392 } |
| 399 } | 393 } |
| 400 | 394 |
| 401 # Assign any flags set for the C compiler to asmflags so that they are sent | 395 # 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 | 396 # to the assembler. The Windows assembler takes different types of flags |
| 403 # so only do so for posix platforms. | 397 # so only do so for posix platforms. |
| 404 if (is_posix) { | 398 if (is_posix) { |
| 405 asmflags += cflags | 399 asmflags += cflags |
| 406 asmflags += cflags_c | 400 asmflags += cflags_c |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 rebase_path("$android_libcpp_root/libcxx/include", root_build_dir), | 470 rebase_path("$android_libcpp_root/libcxx/include", root_build_dir), |
| 477 "-isystem" + rebase_path( | 471 "-isystem" + rebase_path( |
| 478 "$android_ndk_root/sources/cxx-stl/llvm-libc++abi/libcxxabi/includ
e", | 472 "$android_ndk_root/sources/cxx-stl/llvm-libc++abi/libcxxabi/includ
e", |
| 479 root_build_dir), | 473 root_build_dir), |
| 480 "-isystem" + | 474 "-isystem" + |
| 481 rebase_path("$android_ndk_root/sources/android/support/include", | 475 rebase_path("$android_ndk_root/sources/android/support/include", |
| 482 root_build_dir), | 476 root_build_dir), |
| 483 ] | 477 ] |
| 484 | 478 |
| 485 lib_dirs += [ "$android_libcpp_root/libs/$android_app_abi" ] | 479 lib_dirs += [ "$android_libcpp_root/libs/$android_app_abi" ] |
| 486 libs += [ "$android_libcpp_library" ] | |
| 487 | 480 |
| 488 if (current_cpu == "mipsel") { | 481 libs += [ |
| 489 libs += [ | 482 "$android_libcpp_library", |
| 490 # ld linker is used for mips Android, and ld does not accept library | 483 "c++abi", |
| 491 # absolute path prefixed by "-l"; Since libgcc does not exist in mips | 484 "android_support", |
| 492 # sysroot the proper library will be linked. | 485 ] |
| 493 # TODO(gordanac): Remove once gold linker is used for mips Android. | 486 |
| 494 "gcc", | 487 if (current_cpu == "arm") { |
| 495 ] | 488 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 } | 489 } |
| 503 | 490 |
| 504 libs += [ | 491 libs += [ |
| 492 "gcc", |
| 505 "c", | 493 "c", |
| 506 "dl", | 494 "dl", |
| 507 "m", | 495 "m", |
| 508 ] | 496 ] |
| 509 | 497 |
| 510 # Clang with libc++ does not require an explicit atomic library reference. | 498 # Clang with libc++ does not require an explicit atomic library reference. |
| 511 if (!is_clang) { | 499 if (!is_clang) { |
| 512 libs += [ "atomic" ] | 500 libs += [ "atomic" ] |
| 513 } | 501 } |
| 514 } | 502 } |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. | 774 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. |
| 787 } | 775 } |
| 788 ldflags = [ "/DEBUG" ] | 776 ldflags = [ "/DEBUG" ] |
| 789 } else { | 777 } else { |
| 790 cflags = [ | 778 cflags = [ |
| 791 "-g3", | 779 "-g3", |
| 792 "-ggdb3", | 780 "-ggdb3", |
| 793 ] | 781 ] |
| 794 } | 782 } |
| 795 } | 783 } |
| OLD | NEW |