 Chromium Code Reviews
 Chromium Code Reviews Issue 1285623003:
  clang: Compiler tweaks to make android build for x64  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1285623003:
  clang: Compiler tweaks to make android build for x64  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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 import("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") | 
| 6 import("//build/config/chrome_build.gni") | 6 import("//build/config/chrome_build.gni") | 
| 7 if (current_cpu == "arm") { | 7 if (current_cpu == "arm") { | 
| 8 import("//build/config/arm.gni") | 8 import("//build/config/arm.gni") | 
| 9 } | 9 } | 
| 10 if (current_cpu == "mipsel" || current_cpu == "mips64el") { | 10 if (current_cpu == "mipsel" || current_cpu == "mips64el") { | 
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 528 } | 528 } | 
| 529 | 529 | 
| 530 # Android-specific flags setup. | 530 # Android-specific flags setup. | 
| 531 # ----------------------------- | 531 # ----------------------------- | 
| 532 if (is_android) { | 532 if (is_android) { | 
| 533 cflags += [ | 533 cflags += [ | 
| 534 "-ffunction-sections", | 534 "-ffunction-sections", | 
| 535 "-funwind-tables", | 535 "-funwind-tables", | 
| 536 "-fno-short-enums", | 536 "-fno-short-enums", | 
| 537 ] | 537 ] | 
| 538 if (!is_clang) { | |
| 539 # Clang doesn't support these flags. | |
| 540 cflags += [ "-finline-limit=64" ] | |
| 541 } | |
| 538 if (is_clang) { | 542 if (is_clang) { | 
| 539 rebased_android_toolchain_root = | 543 rebased_android_toolchain_root = | 
| 540 rebase_path(android_toolchain_root, root_build_dir) | 544 rebase_path(android_toolchain_root, root_build_dir) | 
| 541 cflags += [ | 545 if (current_cpu == "arm") { | 
| 542 # TODO(hans) Enable integrated-as (crbug.com/124610). | 546 cflags += [ | 
| 543 "-no-integrated-as", | 547 # TODO(hans) Enable integrated-as (crbug.com/124610). | 
| 544 "-B${rebased_android_toolchain_root}/bin", # Else /usr/bin/as gets pick ed up. | 548 "-no-integrated-as", | 
| 545 ] | 549 "-B${rebased_android_toolchain_root}/bin", # Else /usr/bin/as gets pi cked up. | 
| 546 } else { | 550 ] | 
| 547 # Clang doesn't support these flags. | 551 } | 
| 548 cflags += [ "-finline-limit=64" ] | |
| 549 } | 552 } | 
| 550 if (is_asan) { | 553 if (is_asan) { | 
| 551 # Android build relies on -Wl,--gc-sections removing unreachable code. | 554 # Android build relies on -Wl,--gc-sections removing unreachable code. | 
| 552 # ASan instrumentation for globals inhibits this and results in a library | 555 # ASan instrumentation for globals inhibits this and results in a library | 
| 553 # with unresolvable relocations. | 556 # with unresolvable relocations. | 
| 554 # TODO(eugenis): find a way to reenable this. | 557 # TODO(eugenis): find a way to reenable this. | 
| 555 cflags += [ "-mllvm -asan-globals=0" ] | 558 cflags += [ "-mllvm -asan-globals=0" ] | 
| 556 } | 559 } | 
| 557 | 560 | 
| 558 defines += [ "ANDROID" ] | 561 defines += [ "ANDROID" ] | 
| 562 if (is_clang) { | |
| 563 # GCC provides this as a built-in macro, but clang does not. | |
| 
Nico
2015/08/11 21:06:14
Under which circumstances? Based on the triple? Is
 | |
| 564 defines += [ "__ANDROID__" ] | |
| 565 } | |
| 559 | 566 | 
| 560 # The NDK has these things, but doesn't define the constants | 567 # The NDK has these things, but doesn't define the constants | 
| 561 # to say that it does. Define them here instead. | 568 # to say that it does. Define them here instead. | 
| 562 defines += [ "HAVE_SYS_UIO_H" ] | 569 defines += [ "HAVE_SYS_UIO_H" ] | 
| 563 | 570 | 
| 564 # Use gold for Android for most CPU architectures. | 571 # Use gold for Android for most CPU architectures. | 
| 565 if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") { | 572 if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") { | 
| 566 ldflags += [ "-fuse-ld=gold" ] | 573 ldflags += [ "-fuse-ld=gold" ] | 
| 567 if (is_clang) { | 574 if (is_clang) { | 
| 568 # Let clang find the ld.gold in the NDK. | 575 # Let clang find the ld.gold in the NDK. | 
| (...skipping 16 matching lines...) Expand all Loading... | |
| 585 ] | 592 ] | 
| 586 if (current_cpu == "arm") { | 593 if (current_cpu == "arm") { | 
| 587 ldflags += [ | 594 ldflags += [ | 
| 588 # Enable identical code folding to reduce size. | 595 # Enable identical code folding to reduce size. | 
| 589 "-Wl,--icf=safe", | 596 "-Wl,--icf=safe", | 
| 590 ] | 597 ] | 
| 591 } | 598 } | 
| 592 | 599 | 
| 593 if (is_clang) { | 600 if (is_clang) { | 
| 594 if (current_cpu == "arm") { | 601 if (current_cpu == "arm") { | 
| 595 cflags += [ | 602 _abi_target = "arm-linux-androideabi" | 
| 596 "-target", | |
| 597 "arm-linux-androideabi", | |
| 598 ] | |
| 599 ldflags += [ | |
| 600 "-target", | |
| 601 "arm-linux-androideabi", | |
| 602 ] | |
| 603 } else if (current_cpu == "x86") { | 603 } else if (current_cpu == "x86") { | 
| 604 cflags += [ | 604 _abi_target = "i686-linux-androideabi" | 
| 605 "-target", | 605 } else if (current_cpu == "arm64") { | 
| 606 "i686-linux-androideabi", | 606 # Place holder for arm64 support, not tested. | 
| 607 ] | 607 _abi_target = "aarch64-linux-androideabi" | 
| 608 ldflags += [ | 608 } else if (current_cpu == "x64") { | 
| 609 "-target", | 609 # Place holder for x64 support, not tested. | 
| 610 "i686-linux-androideabi", | 610 # TODO: Enable clang support for Android x64. http://crbug.com/346626 | 
| 611 ] | 611 _abi_target = "x86_64-linux-androideabi" | 
| 612 } else if (current_cpu == "mipsel") { | |
| 613 # Place holder for mips support, not tested. | |
| 614 _abi_target = "mipsel-linux-androideabi" | |
| 615 } else if (current_cpu == "mips64el") { | |
| 616 # Place holder for mips64 support, not tested. | |
| 617 _abi_target = "mips64el-linux-androideabi" | |
| 618 } else { | |
| 619 assert(false, "Architecture not supported") | |
| 612 } | 620 } | 
| 621 cflags += [ | |
| 622 "-target", | |
| 623 _abi_target, | |
| 624 ] | |
| 625 ldflags += [ | |
| 626 "-target", | |
| 627 _abi_target, | |
| 628 ] | |
| 613 } | 629 } | 
| 614 } | 630 } | 
| 615 | 631 | 
| 616 # Pass the same C/C++ flags to the objective C/C++ compiler. | 632 # Pass the same C/C++ flags to the objective C/C++ compiler. | 
| 617 cflags_objc += cflags_c | 633 cflags_objc += cflags_c | 
| 618 cflags_objcc += cflags_cc | 634 cflags_objcc += cflags_cc | 
| 619 } | 635 } | 
| 620 | 636 | 
| 621 config("compiler_arm_fpu") { | 637 config("compiler_arm_fpu") { | 
| 622 if (current_cpu == "arm" && !is_ios) { | 638 if (current_cpu == "arm" && !is_ios) { | 
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 "-Wsign-compare", | 1003 "-Wsign-compare", | 
| 988 ] | 1004 ] | 
| 989 | 1005 | 
| 990 # In Chromium code, we define __STDC_foo_MACROS in order to get the | 1006 # In Chromium code, we define __STDC_foo_MACROS in order to get the | 
| 991 # C99 macros on Mac and Linux. | 1007 # C99 macros on Mac and Linux. | 
| 992 defines = [ | 1008 defines = [ | 
| 993 "__STDC_CONSTANT_MACROS", | 1009 "__STDC_CONSTANT_MACROS", | 
| 994 "__STDC_FORMAT_MACROS", | 1010 "__STDC_FORMAT_MACROS", | 
| 995 ] | 1011 ] | 
| 996 | 1012 | 
| 997 if (!using_sanitizer && (!is_linux || !is_clang || is_official_build)) { | 1013 if (!is_debug && !using_sanitizer && | 
| 1014 (!is_linux || !is_clang || is_official_build)) { | |
| 998 # _FORTIFY_SOURCE isn't really supported by Clang now, see | 1015 # _FORTIFY_SOURCE isn't really supported by Clang now, see | 
| 999 # http://llvm.org/bugs/show_bug.cgi?id=16821. | 1016 # http://llvm.org/bugs/show_bug.cgi?id=16821. | 
| 1000 # It seems to work fine with Ubuntu 12 headers though, so use it in | 1017 # It seems to work fine with Ubuntu 12 headers though, so use it in | 
| 1001 # official builds. | 1018 # official builds. | 
| 1002 # | 1019 # | 
| 1003 # Non-chromium code is not guaranteed to compile cleanly with | 1020 # Non-chromium code is not guaranteed to compile cleanly with | 
| 1004 # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are | 1021 # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are | 
| 1005 # disabled, so only do that for Release build. | 1022 # disabled, so only do that for Release build. | 
| 1006 defines += [ "_FORTIFY_SOURCE=2" ] | 1023 defines += [ "_FORTIFY_SOURCE=2" ] | 
| 1007 } | 1024 } | 
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1319 cflags += [ "-gsplit-dwarf" ] | 1336 cflags += [ "-gsplit-dwarf" ] | 
| 1320 } | 1337 } | 
| 1321 } | 1338 } | 
| 1322 } | 1339 } | 
| 1323 | 1340 | 
| 1324 config("no_symbols") { | 1341 config("no_symbols") { | 
| 1325 if (!is_win) { | 1342 if (!is_win) { | 
| 1326 cflags = [ "-g0" ] | 1343 cflags = [ "-g0" ] | 
| 1327 } | 1344 } | 
| 1328 } | 1345 } | 
| OLD | NEW |