diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-03 13:42:47 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-15 10:27:51 +0000 |
commit | 8c5c43c7b138c9b4b0bf56d946e61d3bbc111bec (patch) | |
tree | d29d987c4d7b173cf853279b79a51598f104b403 /chromium/build/config | |
parent | 830c9e163d31a9180fadca926b3e1d7dfffb5021 (diff) | |
download | qtwebengine-chromium-8c5c43c7b138c9b4b0bf56d946e61d3bbc111bec.tar.gz |
BASELINE: Update Chromium to 66.0.3359.156
Change-Id: I0c9831ad39911a086b6377b16f995ad75a51e441
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/build/config')
32 files changed, 970 insertions, 479 deletions
diff --git a/chromium/build/config/BUILDCONFIG.gn b/chromium/build/config/BUILDCONFIG.gn index 853c8492ce9..7d60dd92090 100644 --- a/chromium/build/config/BUILDCONFIG.gn +++ b/chromium/build/config/BUILDCONFIG.gn @@ -166,8 +166,7 @@ declare_args() { # # For more information see # https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md - is_component_build = - is_debug && current_os != "ios" && current_os != "fuchsia" + is_component_build = is_debug && current_os != "ios" } assert(!(is_debug && is_official_build), "Can't do official debug builds") @@ -373,6 +372,7 @@ if (current_os == "win" || current_os == "winrt_81" || } else if (current_os == "aix") { is_android = false is_chromeos = false + is_fuchsia = false is_ios = false is_linux = false is_mac = false @@ -516,6 +516,7 @@ set_sources_assignment_filter(sources_assignment_filter) default_compiler_configs = [ "//build/config:feature_flags", "//build/config/compiler:afdo", + "//build/config/compiler:afdo_optimize_size", "//build/config/compiler:compiler", "//build/config/compiler:clang_stackrealign", "//build/config/compiler:compiler_arm_fpu", diff --git a/chromium/build/config/OWNERS b/chromium/build/config/OWNERS index bd53091f46a..f1592d3b1ae 100644 --- a/chromium/build/config/OWNERS +++ b/chromium/build/config/OWNERS @@ -1,6 +1,5 @@ -brettw@chromium.org dpranke@chromium.org scottmg@chromium.org -per-file BUILDCONFIG.gn=brettw@chromium.org +per-file BUILDCONFIG.gn=dpranke@chromium.org per-file BUILDCONFIG.gn=set noparent diff --git a/chromium/build/config/allocator.gni b/chromium/build/config/allocator.gni index fc5000a3c23..92a2f341d24 100644 --- a/chromium/build/config/allocator.gni +++ b/chromium/build/config/allocator.gni @@ -5,9 +5,9 @@ import("//build/config/sanitizers/sanitizers.gni") # Temporarily disable tcmalloc on arm64 linux to get rid of compilation errors. -if (is_android || current_cpu == "mipsel" || is_mac || is_ios || is_asan || - is_lsan || is_tsan || is_msan || is_win || is_syzyasan || is_fuchsia || - (is_linux && target_cpu == "arm64")) { +if (is_android || current_cpu == "mipsel" || is_mac || is_ios || + is_asan || is_lsan || is_tsan || is_msan || is_win || is_syzyasan || + is_fuchsia || (is_linux && target_cpu == "arm64")) { _default_allocator = "none" } else { _default_allocator = "tcmalloc" diff --git a/chromium/build/config/android/config.gni b/chromium/build/config/android/config.gni index a533ce96135..cf339a2423c 100644 --- a/chromium/build/config/android/config.gni +++ b/chromium/build/config/android/config.gni @@ -39,16 +39,14 @@ if (is_android) { # Android SDK release. Currently, only "o_mr1" is publicly supported. android_sdk_release = default_android_sdk_release } + } - # This is the result of profiling Chromium. Blindly applying it to arbitrary - # downstream projects and hoping it'll grant a speedup seems fragile. (Not - # to mention that it resides in a Chromium-specific directory.) - if (build_with_chromium) { - # The default AFDO profile used by public builds. Value may differ in - # internal builds. - clang_default_afdo_profile = - rebase_path("//chrome/android/profiles/chrome-profile-3309-text.prof") - } + # This is the result of profiling Chromium. Blindly applying it to arbitrary + # downstream projects and hoping it'll grant a speedup seems fragile. (Not + # to mention that it resides in a Chromium-specific directory.) + if (build_with_chromium) { + clang_default_afdo_profile = + rebase_path("//chrome/android/profiles/afdo.prof") } if (!defined(extra_chrome_shared_library_configs)) { @@ -70,7 +68,7 @@ if (is_android) { if (android_sdk_release == "o_mr1") { default_android_sdk_root = "//third_party/android_tools/sdk" default_android_sdk_version = "27" - default_android_sdk_build_tools_version = "27.0.1" + default_android_sdk_build_tools_version = "27.0.3" default_android_sdk_tools_version_suffix = "-26.0.0-dev" public_android_sdk = true } @@ -115,6 +113,11 @@ if (is_android) { webview_framework_jar = webview_public_framework_jar } + # TODO(crbug.com/807768): Remove this extra dependency. + if (!defined(android_extra_test_deps)) { + android_extra_test_deps = [] + } + assert(defined(default_android_sdk_root), "SDK release " + android_sdk_release + " not recognized.") @@ -190,6 +193,11 @@ if (is_android) { # When true, updates all android_aar_prebuilt() .info files during gn gen. # Refer to android_aar_prebuilt() for more details. update_android_aar_prebuilts = false + + # When true, uses the third party libraries from //third_party/android_deps + # over the ones in other places. (instead of the support library from + # android_tools for example) + enable_android_deps_repository = false } # We need a second declare_args block to make sure we are using the overridden @@ -255,8 +263,6 @@ if (is_android) { # Path to the SDK's android.jar android_sdk_jar = "$android_sdk/android.jar" - zipalign_path = "$android_sdk_build_tools/zipalign" - # Subdirectories inside android_ndk_root that contain the sysroot for the # associated platform. x86_android_sysroot_subdir = diff --git a/chromium/build/config/android/internal_rules.gni b/chromium/build/config/android/internal_rules.gni index bcf42f48f70..365ec89502e 100644 --- a/chromium/build/config/android/internal_rules.gni +++ b/chromium/build/config/android/internal_rules.gni @@ -336,11 +336,7 @@ template("write_build_config") { args += [ "--extra-classpath-jars=$_rebased_input_jars_paths" ] } if (defined(invoker.proguard_enabled) && invoker.proguard_enabled) { - args += [ - "--proguard-enabled", - "--proguard-info", - rebase_path(invoker.proguard_info, root_build_dir), - ] + args += [ "--proguard-enabled" ] } if (defined(invoker.proguard_configs)) { _rebased_proguard_configs = @@ -1186,9 +1182,14 @@ if (enable_java_templates) { if (defined(invoker.jar_excluded_patterns)) { _jar_excluded_patterns = invoker.jar_excluded_patterns } + _jar_included_patterns = [] + if (defined(invoker.jar_included_patterns)) { + _jar_included_patterns = invoker.jar_included_patterns + } _strip_resource_classes = defined(invoker.strip_resource_classes) && invoker.strip_resource_classes - _filter_jar = _jar_excluded_patterns != [] || _strip_resource_classes + _filter_jar = _jar_excluded_patterns != [] || + _jar_included_patterns != [] || _strip_resource_classes _deps = [] _previous_output_jar = _input_jar_path @@ -1269,6 +1270,7 @@ if (enable_java_templates) { action(_desugar_target) { script = "//build/android/gyp/desugar.py" + depfile = "$target_gen_dir/$target_name.d" deps = _deps if (defined(invoker.deps)) { deps += invoker.deps @@ -1292,6 +1294,8 @@ if (enable_java_templates) { } inputs += [ _android_sdk_ijar ] args = [ + "--depfile", + rebase_path(depfile, root_build_dir), "--input-jar", rebase_path(_desugar_input_jar, root_build_dir), "--output-jar", @@ -1334,6 +1338,7 @@ if (enable_java_templates) { "--jar-path", rebase_path(_filter_output_jar, root_build_dir), "--excluded-classes=$_jar_excluded_patterns", + "--included-classes=$_jar_included_patterns", ] if (_strip_resource_classes) { args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ] @@ -1409,23 +1414,55 @@ if (enable_java_templates) { } } - # Runs process_resources.py + template("merge_manifests") { + action(target_name) { + forward_variables_from(invoker, + [ + "deps", + "testonly", + ]) + script = "//build/android/gyp/merge_manifest.py" + depfile = "$target_gen_dir/$target_name.d" + + inputs = [ + invoker.build_config, + invoker.input_manifest, + ] + + outputs = [ + invoker.output_manifest, + ] + _rebased_build_config = rebase_path(invoker.build_config, root_build_dir) + + args = [ + "--depfile", + rebase_path(depfile, root_build_dir), + "--build-vars", + rebase_path(android_build_vars, root_build_dir), + "--root-manifest", + rebase_path(invoker.input_manifest, root_build_dir), + "--output", + rebase_path(invoker.output_manifest, root_build_dir), + "--extras", + "@FileArg($_rebased_build_config:extra_android_manifests)", + ] + } + } + template("process_resources") { _process_resources_target_name = target_name if (defined(invoker.srcjar_path)) { _srcjar_path = invoker.srcjar_path } if (defined(invoker.output)) { - _post_process = defined(invoker.post_process_script) _packaged_resources_path = invoker.output - if (_post_process) { - _process_resources_target_name = "${target_name}__intermediate" - _packaged_resources_path = - get_path_info(_packaged_resources_path, "dir") + "/" + - get_path_info(_packaged_resources_path, "name") + - ".intermediate.ap_" - _srcjar_path = "${_srcjar_path}.intermediate.srcjar" - } + } + if (defined(invoker.post_process_script)) { + _process_resources_target_name = "${target_name}__intermediate" + _packaged_resources_path = + get_path_info(_packaged_resources_path, "dir") + "/" + + get_path_info(_packaged_resources_path, "name") + ".intermediate.ap_" + _srcjar_path = "${_srcjar_path}.intermediate.srcjar" } action(_process_resources_target_name) { set_sources_assignment_filter([]) @@ -1632,12 +1669,13 @@ if (enable_java_templates) { } if (defined(invoker.png_to_webp) && invoker.png_to_webp) { _webp_target = "//third_party/libwebp:cwebp($host_toolchain)" + _webp_binary = get_label_info(_webp_target, "root_out_dir") + "/cwebp" deps += [ _webp_target ] + inputs += [ _webp_binary ] args += [ "--png-to-webp", "--webp-binary", - rebase_path(get_label_info(_webp_target, "root_out_dir") + "/cwebp", - root_build_dir), + rebase_path(_webp_binary, root_build_dir), ] } if (defined(invoker.exclude_xxxhdpi) && invoker.exclude_xxxhdpi) { @@ -1656,22 +1694,30 @@ if (enable_java_templates) { } } - if (defined(_packaged_resources_path) && _post_process) { + if (defined(invoker.post_process_script)) { action(target_name) { depfile = "${target_gen_dir}/${invoker.target_name}_2.d" script = invoker.post_process_script args = [ - "--depfile", - rebase_path(depfile, root_build_dir), - "--apk-path", - rebase_path(_packaged_resources_path, root_build_dir), - "--output", - rebase_path(invoker.output, root_build_dir), - "--srcjar-in", - rebase_path(_srcjar_path, root_build_dir), - "--srcjar-out", - rebase_path(invoker.srcjar_path, root_build_dir), - ] + invoker.post_process_args + "--depfile", + rebase_path(depfile, root_build_dir), + "--apk-path", + rebase_path(_packaged_resources_path, root_build_dir), + "--output", + rebase_path(invoker.output, root_build_dir), + "--srcjar-in", + rebase_path(_srcjar_path, root_build_dir), + "--srcjar-out", + rebase_path(invoker.srcjar_path, root_build_dir), + ] + if (defined(invoker.shared_resources_whitelist)) { + args += [ + "--r-text-whitelist", + rebase_path(invoker.shared_resources_whitelist, root_build_dir), + "--r-text", + rebase_path(invoker.r_text_out_path, root_build_dir), + ] + } inputs = [ _srcjar_path, _packaged_resources_path, @@ -1680,8 +1726,9 @@ if (enable_java_templates) { invoker.output, invoker.srcjar_path, ] - public_deps = - [ ":${_process_resources_target_name}" ] + invoker.post_process_deps + public_deps = [ + ":${_process_resources_target_name}", + ] } } } @@ -1819,9 +1866,6 @@ if (enable_java_templates) { # keystore_password: Keystore password. template("finalize_apk") { action(target_name) { - deps = [] - script = "//build/android/gyp/finalize_apk.py" - depfile = "$target_gen_dir/$target_name.d" forward_variables_from(invoker, [ "deps", @@ -1830,10 +1874,13 @@ if (enable_java_templates) { "testonly", ]) - sources = [ - invoker.input_apk_path, - ] + script = "//build/android/gyp/finalize_apk.py" + _apksigner = "$android_sdk_build_tools/apksigner" + _zipalign = "$android_sdk_build_tools/zipalign" inputs = [ + _apksigner, + _zipalign, + invoker.input_apk_path, invoker.keystore_path, ] outputs = [ @@ -1844,14 +1891,14 @@ if (enable_java_templates) { ] args = [ - "--depfile", - rebase_path(depfile, root_build_dir), - "--zipalign-path", - rebase_path(zipalign_path, root_build_dir), "--unsigned-apk-path", rebase_path(invoker.input_apk_path, root_build_dir), "--final-apk-path", rebase_path(invoker.output_apk_path, root_build_dir), + "--apksigner-path", + rebase_path(_apksigner, root_build_dir), + "--zipalign-path", + rebase_path(_zipalign, root_build_dir), "--key-path", rebase_path(invoker.keystore_path, root_build_dir), "--key-name", @@ -1964,6 +2011,7 @@ if (enable_java_templates) { package_apk(_package_target) { forward_variables_from(invoker, [ + "apk_name", "assets_build_config", "native_lib_placeholders", "native_libs_filearg", @@ -1983,10 +2031,6 @@ if (enable_java_templates) { dex_path = _dex_path } - if (defined(invoker.apk_name)) { - apk_name = invoker.apk_name - } - output_apk_path = _packaged_apk_path } @@ -2164,6 +2208,7 @@ if (enable_java_templates) { outputs = [ invoker.javac_jar_path, invoker.javac_jar_path + ".md5.stamp", + invoker.javac_jar_path + ".info", ] inputs = invoker.java_files + _java_srcjars + [ _build_config ] if (invoker.java_files != []) { @@ -2181,7 +2226,7 @@ if (enable_java_templates) { "--java-srcjars=$_rebased_java_srcjars", "--java-srcjars=@FileArg($_rebased_build_config:javac:srcjars)", "--java-version=1.8", - "--classpath=@FileArg($_rebased_build_config:deps_info:javac_full_classpath)", + "--full-classpath=@FileArg($_rebased_build_config:deps_info:javac_full_classpath)", "--interface-classpath=@FileArg($_rebased_build_config:deps_info:javac_full_interface_classpath)", "--processorpath=@FileArg($_rebased_build_config:javac:processor_classpath)", "--processors=@FileArg($_rebased_build_config:javac:processor_classes)", @@ -2223,6 +2268,15 @@ if (enable_java_templates) { "--processorpath=$_rebased_errorprone_processorpath", ] } + if (defined(invoker.apk_name)) { + # The supersize tool will search in this directory for each apk. + _apk_jar_info_path = "size-info/${invoker.apk_name}.apk.jar.info" + args += [ + "--apk-jar-info-path", + _apk_jar_info_path, + ] + outputs += [ "$root_build_dir/$_apk_jar_info_path" ] + } foreach(e, _provider_configurations) { args += [ "--provider-configuration=" + rebase_path(e, root_build_dir) ] } @@ -2411,7 +2465,6 @@ if (enable_java_templates) { "incremental_apk_path", "incremental_install_json_path", "proguard_enabled", - "proguard_info", "non_native_packed_relocations", "shared_libraries_runtime_deps_file", "secondary_abi_shared_libraries_runtime_deps_file", @@ -2430,6 +2483,9 @@ if (enable_java_templates) { build_config = _build_config is_prebuilt = _is_prebuilt possible_config_deps = _accumulated_deps + if (defined(apk_under_test)) { + possible_config_deps += [ apk_under_test ] + } supports_android = _supports_android requires_android = _requires_android bypass_platform_checks = defined(invoker.bypass_platform_checks) && @@ -2461,6 +2517,11 @@ if (enable_java_templates) { } } _accumulated_deps += [ ":$_build_config_target_name" ] + + # Don't need to depend on the apk-under-test to be packaged. + if (defined(invoker.apk_under_test)) { + _accumulated_deps += [ "${invoker.apk_under_test}__java" ] + } if (defined(invoker.android_manifest_dep)) { _accumulated_deps += [ invoker.android_manifest_dep ] } @@ -2499,6 +2560,9 @@ if (enable_java_templates) { requires_android = _requires_android deps = _accumulated_deps javac_jar_path = _javac_jar_path + if (defined(invoker.apk_name)) { + apk_name = invoker.apk_name + } } _accumulated_deps += [ ":$_compile_java_target" ] @@ -2541,6 +2605,7 @@ if (enable_java_templates) { "alternative_android_sdk_ijar_dep", "alternative_android_sdk_jar", "jar_excluded_patterns", + "jar_included_patterns", ]) supports_android = _supports_android enable_build_hooks = _enable_build_hooks diff --git a/chromium/build/config/android/rules.gni b/chromium/build/config/android/rules.gni index 0704250c7bc..7678f686f6e 100644 --- a/chromium/build/config/android/rules.gni +++ b/chromium/build/config/android/rules.gni @@ -1181,7 +1181,12 @@ if (enable_java_templates) { if (!defined(srcjar_deps)) { srcjar_deps = [] } - srcjar_deps += [ ":$_process_resources_target" ] + srcjar_deps += [ + ":$_process_resources_target", + + # This dep is required for any targets that depend on //base:base_java. + "//base:base_build_config_gen", + ] } test_runner_script(_test_runner_target_name) { @@ -1230,8 +1235,10 @@ if (enable_java_templates) { # enable_incremental_javac_override: Overrides the global # enable_incremental_javac. # - # jar_excluded_patterns: List of patterns of .class files to exclude from the - # final jar. + # jar_excluded_patterns: List of patterns of .class files to exclude. + # jar_included_patterns: List of patterns of .class files to include. + # When omitted, all classes not matched by jar_excluded_patterns are + # included. When specified, all non-matching .class files are stripped. # # output_name: File name for the output .jar (not including extension). # Defaults to the input .jar file name. @@ -1268,7 +1275,7 @@ if (enable_java_templates) { # ":foo_generated_enum" # ] # jar_excluded_patterns = [ - # "*/FooService.class", "*/FooService\$*.class" + # "*/FooService.class", "org/chromium/FooService\$*.class" # ] # } template("java_library") { @@ -1382,9 +1389,6 @@ if (enable_java_templates) { requires_android = _requires_android possible_config_deps = _deps build_config = _build_config - if (_proguard_enabled) { - proguard_info = "${invoker.output}.info" - } } _deps += [ ":$_build_config_target_name" ] @@ -1406,9 +1410,9 @@ if (enable_java_templates) { output_jar_path = invoker.output args = [ - "--proguard-configs=@FileArg($_rebased_build_config:proguard:all_configs)", + "--proguard-configs=@FileArg($_rebased_build_config:deps_info:proguard_all_configs)", "--input-paths=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)", - "--classpath=@FileArg($_rebased_build_config:proguard:extra_jars)", + "--classpath=@FileArg($_rebased_build_config:deps_info:proguard_all_extra_jars)", ] if (defined(invoker.proguard_config_exclusions)) { _rebased_proguard_config_exclusions = @@ -1480,6 +1484,7 @@ if (enable_java_templates) { # Currently supports: # * AndroidManifest.xml # * classes.jar + # * jni/ # * res/ # * R.txt # * proguard.txt @@ -1487,13 +1492,13 @@ if (enable_java_templates) { # * public.txt # * annotations.zip # * assets/ - # * jni/ # See: https://developer.android.com/studio/projects/android-library.html#aar-contents # # Variables: # output: Path to the output .aar. # proguard_configs: List of proguard configs (optional). # android_manifest: Path to AndroidManifest.xml (optional). + # native_libraries: list of native libraries (optional). # # Example # dist_aar("my_aar") { @@ -1546,7 +1551,7 @@ if (enable_java_templates) { "--jars=@FileArg($_rebased_build_config:deps_info:javac_full_classpath)", "--dependencies-res-zips=@FileArg($_rebased_build_config:resources:dependency_zips)", "--r-text-files=@FileArg($_rebased_build_config:resources:extra_r_text_files)", - "--proguard-configs=@FileArg($_rebased_build_config:proguard:all_configs)", + "--proguard-configs=@FileArg($_rebased_build_config:deps_info:proguard_all_configs)", ] if (defined(invoker.android_manifest)) { args += [ @@ -1554,6 +1559,16 @@ if (enable_java_templates) { rebase_path(invoker.android_manifest, root_build_dir), ] } + if (defined(invoker.native_libraries) && invoker.native_libraries != []) { + inputs += invoker.native_libraries + _rebased_native_libraries = + rebase_path(invoker.native_libraries, root_build_dir) + + args += [ + "--native-libraries=$_rebased_native_libraries", + "--abi=$android_app_abi", + ] + } } } @@ -1593,7 +1608,7 @@ if (enable_java_templates) { # ":foo_generated_enum" # ] # jar_excluded_patterns = [ - # "*/FooService.class", "*/FooService\$*.class" + # "*/FooService.class", "org/chromium/FooService\$*.class" # ] # } template("android_library") { @@ -1641,6 +1656,64 @@ if (enable_java_templates) { } } + # Creates org/chromium/base/BuildConfig.java + # This doesn't really belong in //build since it genates a file for //base. + # However, we don't currently have a better way to include this file in all + # apks that depend on //base:base_java. + # + # Variables: + # use_final_fields: True to use final fields. All other variables are + # ignored when this is false. + # build_config: Path to build_config used for locale list + # enable_multidex: Value for ENABLE_MULTIDEX. + # firebase_app_id: Value for FIREBASE_APP_ID. + # + template("generate_build_config_srcjar") { + java_cpp_template(target_name) { + package_path = "org/chromium/base" + sources = [ + "//base/android/java/templates/BuildConfig.template", + ] + defines = [] + + # TODO(agrieve): These two are not target-specific and should be moved + # to BuildHooks.java. + # Set these even when !use_final_fields so that they have correct default + # values withnin junit_binary(). + if (is_java_debug || dcheck_always_on) { + defines += [ "_DCHECK_IS_ON" ] + } + if (use_cfi_diag || is_ubsan || is_ubsan_security || is_ubsan_vptr) { + defines += [ "_IS_UBSAN" ] + } + + if (invoker.use_final_fields) { + forward_variables_from(invoker, + [ + "deps", + "testonly", + ]) + defines += [ "USE_FINAL" ] + if (invoker.enable_multidex) { + defines += [ "ENABLE_MULTIDEX" ] + } + inputs = [ + invoker.build_config, + ] + _rebased_build_config = rebase_path(invoker.build_config) + defines += [ + "COMPRESSED_LOCALE_LIST=" + + "@FileArg($_rebased_build_config:compressed_locales_java_list)", + "UNCOMPRESSED_LOCALE_LIST=" + + "@FileArg($_rebased_build_config:uncompressed_locales_java_list)", + ] + if (defined(invoker.firebase_app_id)) { + defines += [ "_FIREBASE_APP_ID=${invoker.firebase_app_id}" ] + } + } + } + } + # Declare an Android apk target # # This target creates an Android APK containing java code, resources, assets, @@ -1680,6 +1753,8 @@ if (enable_java_templates) { # generate_buildconfig_java: If defined and false, skip generating the # BuildConfig java class describing the build configuration. The default # is true for non-test APKs. + # firebase_app_id: The value for BuildConfig.FIREBASE_APP_ID (optional). + # Identifier is sent with crash reports to enable Java stack deobfuscation. # requires_sdk_api_level_23: If defined and true, the apk is intended for # installation only on Android M or later. In these releases the system # linker does relocation unpacking, so we can enable it unconditionally. @@ -1950,31 +2025,10 @@ if (enable_java_templates) { _android_manifest = "$target_gen_dir/${_template_name}_manifest/AndroidManifest.xml" _merge_manifest_target = "${_template_name}__merge_manifests" - action(_merge_manifest_target) { - script = "//build/android/gyp/merge_manifest.py" - depfile = "$target_gen_dir/$target_name.d" - - sources = [ - _android_root_manifest, - ] - - outputs = [ - _android_manifest, - ] - - args = [ - "--depfile", - rebase_path(depfile, root_build_dir), - "--build-vars", - rebase_path(android_build_vars, root_build_dir), - "--root-manifest", - rebase_path(_android_root_manifest, root_build_dir), - "--output", - rebase_path(_android_manifest, root_build_dir), - "--extras", - "@FileArg($_rebased_build_config:extra_android_manifests)", - ] - + merge_manifests(_merge_manifest_target) { + input_manifest = _android_root_manifest + output_manifest = _android_manifest + build_config = _build_config deps = _android_root_manifest_deps + [ ":$_build_config_target" ] } @@ -2004,8 +2058,6 @@ if (enable_java_templates) { version_name = _version_name if (defined(invoker.post_process_package_resources_script)) { post_process_script = invoker.post_process_package_resources_script - post_process_deps = invoker.post_process_package_resources_deps - post_process_args = invoker.post_process_package_resources_args } srcjar_path = "${target_gen_dir}/${target_name}.srcjar" r_text_out_path = "${target_gen_dir}/${target_name}_R.txt" @@ -2070,6 +2122,10 @@ if (enable_java_templates) { "--output=$_rebased_ordered_libraries_json", "--runtime-deps=" + rebase_path(_runtime_deps_file, root_build_dir), ] + if (defined(invoker.dont_load_shared_libraries)) { + args += [ "--exclude-shared-libraries=" + + invoker.dont_load_shared_libraries ] + } } java_cpp_template("${_template_name}__native_libraries_java") { @@ -2115,31 +2171,14 @@ if (enable_java_templates) { } if (_generate_buildconfig_java) { - java_cpp_template("${_template_name}__build_config_java") { - package_path = "org/chromium/base" - sources = [ - "//base/android/java/templates/BuildConfig.template", - ] + generate_build_config_srcjar("${_template_name}__build_config_java") { + forward_variables_from(invoker, [ "firebase_app_id" ]) + use_final_fields = true + build_config = _build_config + enable_multidex = _enable_multidex deps = [ ":$_build_config_target", ] - - defines = [] - if (_enable_multidex) { - defines += [ "ENABLE_MULTIDEX" ] - } - if (is_java_debug || dcheck_always_on) { - defines += [ "_DCHECK_IS_ON" ] - } - if (use_cfi_diag || is_ubsan || is_ubsan_security || is_ubsan_vptr) { - defines += [ "_IS_UBSAN" ] - } - defines += [ - "COMPRESSED_LOCALE_LIST=" + - "@FileArg($_rebased_build_config:compressed_locales_java_list)", - "UNCOMPRESSED_LOCALE_LIST=" + - "@FileArg($_rebased_build_config:uncompressed_locales_java_list)", - ] } _srcjar_deps += [ ":${_template_name}__build_config_java" ] } @@ -2148,6 +2187,7 @@ if (enable_java_templates) { java_library_impl(_java_target) { forward_variables_from(invoker, [ + "apk_name", "android_manifest", "android_manifest_dep", "apk_under_test", @@ -2169,16 +2209,12 @@ if (enable_java_templates) { dex_path = _lib_dex_path apk_path = _final_apk_path - if (defined(invoker.apk_under_test)) { - deps += [ "${invoker.apk_under_test}" ] - } incremental_allowed = _incremental_allowed incremental_apk_path = "${_final_apk_path_no_ext}_incremental.apk" incremental_install_json_path = _incremental_install_json_path proguard_enabled = _proguard_enabled if (_proguard_enabled) { - proguard_info = "$_proguard_output_jar_path.info" proguard_configs = [ _generated_proguard_config ] if (defined(invoker.proguard_configs)) { proguard_configs += invoker.proguard_configs @@ -2241,9 +2277,9 @@ if (enable_java_templates) { output_jar_path = _proguard_output_jar_path args = [ - "--proguard-configs=@FileArg($_rebased_build_config:proguard:all_configs)", + "--proguard-configs=@FileArg($_rebased_build_config:deps_info:proguard_all_configs)", "--input-paths=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)", - "--classpath=@FileArg($_rebased_build_config:proguard:extra_jars)", + "--classpath=@FileArg($_rebased_build_config:deps_info:proguard_all_extra_jars)", ] if (defined(invoker.proguard_config_exclusions)) { _rebased_proguard_config_exclusions = @@ -2252,19 +2288,6 @@ if (enable_java_templates) { "--proguard-config-exclusions=$_rebased_proguard_config_exclusions", ] } - - if (defined(invoker.apk_under_test)) { - deps += [ - "${invoker.apk_under_test}__build_config", - "${invoker.apk_under_test}__proguard", - ] - _apk_under_test_build_config = - get_label_info(invoker.apk_under_test, "target_gen_dir") + "/" + - get_label_info(invoker.apk_under_test, "name") + ".build_config" - _rebased_apk_under_test_build_config = - rebase_path(_apk_under_test_build_config, root_build_dir) - args += [ "--tested-apk-info=@FileArg($_rebased_apk_under_test_build_config:deps_info:proguard_info)" ] - } } _dex_sources = [ _proguard_output_jar_path ] _dex_deps = [ ":$_proguard_target" ] @@ -2569,7 +2592,7 @@ if (enable_java_templates) { _apk_operations = [] _incremental_apk_operations = [] - # Generate apk opeartion related script. + # Generate apk operation related script. if (!defined(invoker.create_apk_script) || invoker.create_apk_script) { _apk_operations_target_name = "${target_name}__apk_operations" action(_apk_operations_target_name) { @@ -2771,6 +2794,9 @@ if (enable_java_templates) { "//tools/android/forwarder2", "//tools/android/md5sum", ] + if (defined(invoker.apk_under_test)) { + data_deps += [ invoker.apk_under_test ] + } if (defined(invoker.additional_apks)) { data_deps += invoker.additional_apks } @@ -2922,7 +2948,6 @@ if (enable_java_templates) { ":${target_name}__runtime_deps", ":${target_name}__secondary_abi_runtime_deps", "//base:base_java", - "//testing/android/appurify_support:appurify_support_java", "//testing/android/reporter:reporter_java", ] data_deps += [ @@ -3246,6 +3271,7 @@ if (enable_java_templates) { forward_variables_from(invoker, [ "jar_excluded_patterns", + "jar_included_patterns", "requires_android", ]) deps = [ @@ -3270,6 +3296,7 @@ if (enable_java_templates) { "deps", "input_jars_paths", "jar_excluded_patterns", + "jar_included_patterns", "proguard_configs", "requires_android", "testonly", @@ -3318,3 +3345,44 @@ if (enable_java_templates) { } } } + +# Compatibility wrapper to toggle android_deps usage for a dependency. +# +# This target creates a wrapper for a dependency allowing it to be loaded +# either from //third_party/android_deps or from an existing //third_party +# (or other) target. +# +# Variables +# fallback_target: Target to use when the android_deps repo is not enabled. +# android_deps_target_name: Name of the target from the android_deps repo to +# use when the repo is enabled. Is not set, the wrapper's target name will +# be used instead. +# +# Example +# prebuilt_wrapper("android_support_multidex_java") { +# android_deps_target_name = "com_android_support_multidex_java" +# fallback_target = "$android_support_library_package:$target_name" +# } +template("prebuilt_wrapper") { + if (defined(invoker.android_deps_target_name)) { + _resolved_android_deps_target_name = invoker.android_deps_target_name + } else { + _resolved_android_deps_target_name = target_name + } + + if (enable_android_deps_repository) { + _resolved_target = + "//third_party/android_deps:${_resolved_android_deps_target_name}" + assert(invoker.fallback_target != "") # Mark as used. + } else { + _resolved_target = "${invoker.fallback_target}" + assert(_resolved_android_deps_target_name != "") # Mark as used. + } + + java_group(target_name) { + forward_variables_from(invoker, [ "testonly" ]) + deps = [ + _resolved_target, + ] + } +} diff --git a/chromium/build/config/arm.gni b/chromium/build/config/arm.gni index 29434eba92f..abd4dd02fdc 100644 --- a/chromium/build/config/arm.gni +++ b/chromium/build/config/arm.gni @@ -3,6 +3,7 @@ # found in the LICENSE file. import("//build/config/v8_target_cpu.gni") +import("//build/secondary/third_party/catapult/devil/devil_arm.gni") # These are primarily relevant in current_cpu == "arm" contexts, where # ARM code is being compiled. But they can also be relevant in the @@ -79,8 +80,15 @@ if (current_cpu == "arm" || v8_current_cpu == "arm") { } if (arm_float_abi == "") { - if (current_os == "android" || target_os == "android") { + if (current_os == "android") { arm_float_abi = "softfp" + } else if (target_os == "android") { + if (build_devil_arm_deps) { + # Raspberry Pis require "hard" + arm_float_abi = "hard" + } else { + arm_float_abi = "softfp" + } } else if (current_os == "linux" && target_cpu != v8_target_cpu) { # Default to the same as Android for V8 simulator builds. arm_float_abi = "softfp" diff --git a/chromium/build/config/c++/c++.gni b/chromium/build/config/c++/c++.gni index a9f627f997a..85ffde0ea00 100644 --- a/chromium/build/config/c++/c++.gni +++ b/chromium/build/config/c++/c++.gni @@ -36,7 +36,7 @@ declare_args() { use_custom_libcxx = use_custom_libcxx || (use_custom_libcxx_for_host && current_cpu == host_cpu) +use_custom_libcxx = use_custom_libcxx && !is_nacl libcxx_prefix = "//buildtools/third_party/libc++/trunk" libcxxabi_prefix = "//buildtools/third_party/libc++abi/trunk" -libunwind_prefix = "//buildtools/third_party/libunwind/trunk" diff --git a/chromium/build/config/clang/clang.gni b/chromium/build/config/clang/clang.gni index 7026f65207f..2c2d76fd4b2 100644 --- a/chromium/build/config/clang/clang.gni +++ b/chromium/build/config/clang/clang.gni @@ -4,10 +4,12 @@ import("//build/toolchain/toolchain.gni") +default_clang_base_path = "//third_party/llvm-build/Release+Asserts" + declare_args() { # Indicates if the build should use the Chrome-specific plugins for enforcing # coding guidelines, etc. Only used when compiling with Clang. clang_use_chrome_plugins = is_clang && !is_nacl && !use_xcode_clang - clang_base_path = "//third_party/llvm-build/Release+Asserts" + clang_base_path = default_clang_base_path } diff --git a/chromium/build/config/compiler/BUILD.gn b/chromium/build/config/compiler/BUILD.gn index 2673c6a7988..9a10137aa40 100644 --- a/chromium/build/config/compiler/BUILD.gn +++ b/chromium/build/config/compiler/BUILD.gn @@ -3,11 +3,14 @@ # found in the LICENSE file. import("//build/config/android/config.gni") +import("//build/config/c++/c++.gni") import("//build/config/chrome_build.gni") import("//build/config/chromecast_build.gni") +import("//build/config/clang/clang.gni") import("//build/config/compiler/compiler.gni") import("//build/config/coverage/coverage.gni") import("//build/config/host_byteorder.gni") +import("//build/config/ui.gni") import("//build/toolchain/cc_wrapper.gni") import("//build/toolchain/toolchain.gni") import("//build_overrides/build.gni") @@ -104,21 +107,12 @@ declare_args() { # Path to an AFDO profile to use while building with clang, if any. Empty # implies none. - # - # Please note that you need to be very careful about changing your profile at - # the moment. See the `BUG(gbiv)` comment later in this file. clang_sample_profile_path = "" # Some configurations have default sample profiles. If this is true and # clang_sample_profile_path is empty, we'll fall back to the default. clang_use_default_sample_profile = is_official_build && defined(clang_default_afdo_profile) - - # Whether to assert to the compiler that the AFDO profiles are accurate. - # True will cause the compiler to optimize uncovered functions for size - # (despite passing -O2 or -O3), which reduces binary size by quite a bit, - # potentially at the cost of some performance. - clang_sample_profile_is_accurate = true } declare_args() { @@ -126,13 +120,25 @@ declare_args() { use_cxx11_on_android = use_cxx11 } -if (is_clang) { - update_args = [ "--print-revision" ] - if (llvm_force_head_revision) { - update_args += [ "--llvm-force-head-revision" ] - } - clang_revision = - exec_script("//tools/clang/scripts/update.py", update_args, "trim string") +declare_args() { + # Set to true to use icf, Identical Code Folding. + # + # icf=all is broken in older golds, see + # https://sourceware.org/bugzilla/show_bug.cgi?id=17704 + # See also https://crbug.com/663886 + # `linux_use_bundled_binutils` is to avoid breaking Linux distros which may + # still have a buggy gold. + # chromeos binutils has been patched with the fix, so always use icf there. + # The bug only affects x86 and x64, so we can still use ICF when targeting + # other architectures. + # + # lld doesn't have the bug. + use_icf = + is_posix && !using_sanitizer && !(is_android && use_order_profiling) && + ((use_lld && !is_nacl) || + (use_gold && + ((!is_android && linux_use_bundled_binutils) || is_chromeos || + !(current_cpu == "x86" || current_cpu == "x64")))) } # Apply the default logic for these values if they were not set explicitly. @@ -179,6 +185,7 @@ config("compiler") { ldflags = [] defines = [] configs = [] + inputs = [] # System-specific flags. If your compiler flags apply to one of the # categories here, add it to the associated file to keep this shared config @@ -215,34 +222,6 @@ config("compiler") { # -------------------------------- cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 - # AFDO on clang. Clang doesn't seem to suffer from the bug that caused GCC's - # AFDO to be split into its own config, so this isn't part of that config. - # - # Since we only profile the browser, skip it if we're building host tools. - # - # XXX(gbiv): There is currently *no* dependency between the profile we use - # and the compilations/links that we do. So, if the profile gets updated, - # the user has to manually clean build artifacts. CL:827560 should fix this - # by allowing us to specify `inputs` here, but until then, the only "good" - # workaround is changing your profile name each time you update the profile. - if (is_clang && current_toolchain == default_toolchain) { - _sample_path = "" - if (clang_sample_profile_path != "") { - _sample_path = clang_sample_profile_path - } else if (clang_use_default_sample_profile) { - assert(defined(clang_default_afdo_profile), - "This platform has no default sample profiles") - _sample_path = clang_default_afdo_profile - } - - if (_sample_path != "") { - cflags += [ "-fprofile-sample-use=${_sample_path}" ] - if (clang_sample_profile_is_accurate) { - cflags += [ "-fprofile-sample-accurate" ] - } - } - } - # Stack protection. if (is_mac) { # The strong variant of the stack protector significantly increases @@ -433,20 +412,8 @@ config("compiler") { ldflags += [ "-fuse-ld=bfd" ] } - if (is_posix && (use_gold || (use_lld && !is_nacl)) && !using_sanitizer && - !(is_android && use_order_profiling)) { - # TODO(thakis): Remove `!is_android` below once NDK gold has been rolled - # with the fix for https://sourceware.org/bugzilla/show_bug.cgi?id=17704 - # merged. See also https://crbug.com/663886 - # `linux_use_bundled_binutils` is to avoid breaking Linux distros which may - # still have a buggy gold. - # chromeos binutils has been patched with the fix, so always use icf there. - # The bug only affects x86 and x64, so we can still use ICF when targeting - # other architectures. - if ((!is_android && linux_use_bundled_binutils) || is_chromeos || - !(current_cpu == "x86" || current_cpu == "x64")) { - ldflags += [ "-Wl,--icf=all" ] - } + if (use_icf) { + ldflags += [ "-Wl,--icf=all" ] } if (linux_use_bundled_binutils) { @@ -489,8 +456,17 @@ config("compiler") { # clang-cl (used if is_win) doesn't expose this flag. # Currently disabled for nacl since its toolchain lacks this flag (too old). # TODO(zforman): Once nacl's toolchain is updated, remove check. - if (is_clang && is_linux && strip_absolute_paths_from_debug_symbols) { - absolute_path = rebase_path("//.") + if (is_clang && !is_nacl && !is_win && !is_mac && !is_ios && + strip_absolute_paths_from_debug_symbols) { + # This is resolved to path like "$HOME/chromium/src/out/Release". + # If debug option is given, clang includes $cwd in debug info. + # In such build, this flag generates reproducible obj files + # even we use build directory like "out/feature_a" and "out/feature_b" if + # we build same files with same compile flag other than this. + # Other paths are already givne in relative, no need to normalize it by + # using -fdebug-prefix-map. + absolute_path = rebase_path(root_out_dir) + cflags += [ "-fdebug-prefix-map=$absolute_path=." ] } @@ -562,6 +538,13 @@ config("compiler") { "gold plugin only supported with ChromeOS") cflags += [ "-flto=thin" ] + + # Limit the size of the ThinLTO cache to the lesser of 10% of available disk + # space, 10GB and 100000 files. + if (use_lld) { + cache_policy = + "cache_size=10%:cache_size_bytes=10g:cache_size_files=100000" + } if (is_win) { # This is a straight translation of the non-Windows flags below. ldflags += [ @@ -569,7 +552,7 @@ config("compiler") { "/opt:lldltojobs=8", "/lldltocache:" + rebase_path("$root_out_dir/thinlto-cache", root_build_dir), - "/lldltocachepolicy:cache_size=10%", + "/lldltocachepolicy:$cache_policy", ] } else { ldflags += [ "-flto=thin" ] @@ -582,20 +565,17 @@ config("compiler") { "-Wl,--thinlto-jobs=8", "-Wl,--thinlto-cache-dir=" + rebase_path("$root_out_dir/thinlto-cache", root_build_dir), - - # Limit the size of the ThinLTO cache to 10% of available disk space - # TODO(pcc): Change the limit from a percentage to an absolute size - # (10-20GB) once that feature lands in LLVM. - "-Wl,--thinlto-cache-policy,cache_size=10%", + "-Wl,--thinlto-cache-policy,$cache_policy", ] } else { ldflags += [ "-Wl,-plugin-opt,jobs=8" ] + not_needed([ "cache_policy" ]) } } # Disable optimization for now because they increase binary size by too # much. - if (use_lld && (is_android || is_linux)) { + if (use_lld && (is_android || (is_linux && !is_chromeos))) { ldflags += [ "-Wl,--lto-O0" ] } @@ -608,6 +588,15 @@ config("compiler") { if (is_mac) { ldflags += [ "-Wl,-all_load" ] } + + # This flag causes LTO to create an .ARM.attributes section with the correct + # architecture. This is necessary because LLD will refuse to link a program + # unless the architecture revision in .ARM.attributes is sufficiently new. + # TODO(pcc): The contents of .ARM.attributes should be based on the + # -march flag passed at compile time (see llvm.org/pr36291). + if (current_cpu == "arm") { + ldflags += [ "-march=$arm_arch" ] + } } # Pass the same C/C++ flags to the objective C/C++ compiler. @@ -841,11 +830,18 @@ config("compiler_cpu_abi") { ] } } else if (mips_arch_variant == "r2") { - cflags += [ - "-mips64r2", - "-Wa,-mips64r2", - ] ldflags += [ "-mips64r2" ] + if (is_clang) { + cflags += [ + "-march=mips64el", + "-mcpu=mips64r2", + ] + } else { + cflags += [ + "-mips64r2", + "-Wa,-mips64r2", + ] + } } else if (mips_arch_variant == "loongson3") { defines += [ "_MIPS_ARCH_LOONGSON" ] cflags += [ @@ -923,8 +919,13 @@ config("compiler_cpu_abi") { cflags += [ "-m32" ] ldflags += [ "-m32" ] } else if (v8_current_cpu == "ppc64") { - cflags += [ "-m64" ] - ldflags += [ "-m64" ] + if (current_os == "aix") { + cflags += [ "-maix64" ] + ldflags += [ "-maix64" ] + } else { + cflags += [ "-m64" ] + ldflags += [ "-m64" ] + } } } else if (current_cpu == "s390x") { if (v8_current_cpu == "s390" && host_byteorder == "little") { @@ -998,7 +999,18 @@ config("clang_stackrealign") { } config("clang_revision") { - if (is_clang) { + if (is_clang && clang_base_path == default_clang_base_path) { + update_args = [ + "--print-revision", + "--verify-version=$clang_version", + ] + if (llvm_force_head_revision) { + update_args += [ "--llvm-force-head-revision" ] + } + clang_revision = exec_script("//tools/clang/scripts/update.py", + update_args, + "trim string") + # This is here so that all files get recompiled after a clang roll and # when turning clang on or off. (defines are passed via the command line, # and build system rebuild things when their commandline changes). Nothing @@ -1326,18 +1338,8 @@ config("default_warnings") { # TODO(thakis): https://crbug.com/753973 "-Wno-enum-compare-switch", - # TODO(hans): https://crbug.com/763392 - "-Wno-tautological-unsigned-zero-compare", - # TODO(hans): https://crbug.com/766891 "-Wno-null-pointer-arithmetic", - - # TODO(hans): https://crbug.com/767059 - # Disable -Wtautological-constant-compare (and implicitly also - # -Wtautological-unsigned-enum-zero-compare), but re-enable - # useful sub-diagnostics in that group. - "-Wno-tautological-constant-compare", - "-Wtautological-constant-out-of-range-compare", ] } else if (use_xcode_clang) { cflags += [ @@ -1370,7 +1372,7 @@ config("chromium_code") { ldflags = [ "-Werror" ] } if (is_clang) { - # Enable -Wextra for chromium_code when we control the compiler. + # Enable extra warnings for chromium_code when we control the compiler. cflags += [ "-Wextra" ] } @@ -1403,6 +1405,19 @@ config("chromium_code") { } } + if (is_clang) { + cflags += [ + # Warn on missing break statements at the end of switch cases. + # For intentional fallthrough, use FALLTHROUGH; from + # base/compiler_specific.h + "-Wimplicit-fallthrough", + + # Thread safety analysis. See base/thread_annotations.h and + # https://clang.llvm.org/docs/ThreadSafetyAnalysis.html + "-Wthread-safety", + ] + } + configs = [ ":default_warnings" ] } @@ -1491,7 +1506,9 @@ config("no_rtti") { config("exceptions") { if (is_win) { # Enables exceptions in the STL. - defines = [ "_HAS_EXCEPTIONS=1" ] + if (!use_custom_libcxx) { + defines = [ "_HAS_EXCEPTIONS=1" ] + } cflags_cc = [ "/EHsc" ] } else { cflags_cc = [ "-fexceptions" ] @@ -1502,7 +1519,14 @@ config("exceptions") { config("no_exceptions") { if (is_win) { # Disables exceptions in the STL. - defines = [ "_HAS_EXCEPTIONS=0" ] + # libc++ uses the __has_feature macro to control whether to use exceptions, + # so defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also + # breaks libc++ because it depends on MSVC headers that only provide certain + # declarations if _HAS_EXCEPTIONS is 1. Those MSVC headers do not use + # exceptions, despite being conditional on _HAS_EXCEPTIONS. + if (!use_custom_libcxx) { + defines = [ "_HAS_EXCEPTIONS=0" ] + } } else { cflags_cc = [ "-fno-exceptions" ] cflags_objcc = cflags_cc @@ -1571,7 +1595,6 @@ if (is_win) { common_optimize_on_cflags = [ "/Ob2", # Both explicit and auto inlining. "/Oy-", # Disable omitting frame pointers, must be after /O2. - "/d2Zi+", # Improve debugging of optimized code. "/Zc:inline", # Remove unreferenced COMDAT (faster links). ] if (!is_asan) { @@ -1656,7 +1679,8 @@ if (is_win) { common_optimize_on_ldflags += [ # Specifically tell the linker to perform optimizations. # See http://lwn.net/Articles/192624/ . - "-Wl,-O1", + # -O2 enables string tail merge optimization in gold and lld. + "-Wl,-O2", "-Wl,--gc-sections", ] } @@ -1877,15 +1901,44 @@ config("default_optimization") { } } -# GCC supports a form of profile-guided optimization called AFDO, which -# is used by ChromeOS in their official builds. However, -# //base/allocator:tcmalloc currently doesn't work correctly with AFDO -# so we provide separate config so that the flag can be disabled per-target. -# TODO(crbug.com/633719): Remove this config once tcmalloc works with AFDO -# or we remove tcmalloc or we stop using AFDO. +_clang_sample_profile = "" +if (is_clang && current_toolchain == default_toolchain) { + if (clang_sample_profile_path != "") { + _clang_sample_profile = clang_sample_profile_path + } else if (clang_use_default_sample_profile) { + assert(defined(clang_default_afdo_profile), + "This platform has no default sample profiles") + _clang_sample_profile = clang_default_afdo_profile + } +} + +# Clang offers a way to assert that AFDO profiles are accurate, which causes it +# to optimize functions not represented in a profile more aggressively for size. +# This config can be toggled in cases where shaving off binary size hurts +# performance too much. +config("afdo_optimize_size") { + if (_clang_sample_profile != "" && sample_profile_is_accurate) { + cflags = [ "-fprofile-sample-accurate" ] + } +} + +# GCC and clang support a form of profile-guided optimization called AFDO. +# There are some targeted places that AFDO regresses (and an icky interaction +# between //base/allocator:tcmalloc and AFDO on GCC), so we provide a separate +# config to allow AFDO to be disabled per-target. config("afdo") { - if (auto_profile_path != "" && current_toolchain == default_toolchain) { + if (is_clang) { + if (_clang_sample_profile != "") { + cflags = [ "-fprofile-sample-use=${_clang_sample_profile}" ] + inputs = [ + _clang_sample_profile, + ] + } + } else if (auto_profile_path != "" && current_toolchain == default_toolchain) { cflags = [ "-fauto-profile=${auto_profile_path}" ] + inputs = [ + auto_profile_path, + ] } } @@ -1911,6 +1964,8 @@ config("symbols") { } if (is_win_fastlink) { + assert(!use_lld, "is_win_fastlink=true cannot be used with use_lld=true.") + # Tell VS 2015+ to create a PDB that references debug # information in .obj and .lib files instead of copying # it all. This flag is incompatible with /PROFILE @@ -1980,6 +2035,8 @@ config("symbols") { } # Minimal symbols. +# This config guarantees to hold symbol for stack trace which are shown to user +# when crash happens in unittests running on buildbot. config("minimal_symbols") { if (is_win) { # Linker symbols for backtraces only. diff --git a/chromium/build/config/compiler/compiler.gni b/chromium/build/config/compiler/compiler.gni index 6fddf3d0526..5fb5a3c91d2 100644 --- a/chromium/build/config/compiler/compiler.gni +++ b/chromium/build/config/compiler/compiler.gni @@ -54,22 +54,15 @@ declare_args() { # Windows build. use_incremental_wpo = false - # Root directory that will store the MSVC link repro. This should only be - # used for debugging purposes on the builders where a MSVC linker flakyness - # has been observed. The targets for which a link repro should be generated - # should add somethink like this to their configuration: - # if (linkrepro_root_dir != "") { - # ldflags = ["/LINKREPRO:" + linkrepro_root_dir + "/" + target_name] - # } - # - # Note that doing a link repro uses a lot of disk space and slows down the - # build, so this shouldn't be enabled on too many targets. - # - # See crbug.com/669854. - linkrepro_root_dir = "" - # Whether or not we should use position independent code. use_pic = true + + # Whether we're using a sample profile collected on an architecture different + # than the one we're compiling for. + # + # It's currently not possible to collect AFDO profiles on anything but + # x86{,_64}. + using_mismatched_sample_profile = current_cpu != "x64" && current_cpu != "x86" } assert(!is_cfi || use_thin_lto, "CFI requires ThinLTO") @@ -89,6 +82,14 @@ exclude_unwind_tables = # explore favoring size over speed in this case as well. optimize_for_size = is_android || is_ios +declare_args() { + # Whether we should consider the profile we're using to be accurate. Accurate + # profiles have the benefit of (potentially substantial) binary size + # reductions, by instructing the compiler to optimize cold and uncovered + # functions heavily for size. This often comes at the cost of performance. + sample_profile_is_accurate = optimize_for_size +} + # Determine whether to enable or disable frame pointers, based on the platform # and build arguments. if (is_mac || is_ios || is_linux) { @@ -155,11 +156,12 @@ declare_args() { # Linux or Fuchsia. # TODO(pcc): Enable lld on more architectures on Linux. E.g. we probably need # to fix some of crbug.com/742655 to enable it on ARM. - # TODO(pcc): Remove !is_msan once crbug.com/772559 is fixed. - use_lld = is_clang && !is_msan && + use_lld = is_clang && ((is_win && host_os != "win") || is_fuchsia || (use_thin_lto && target_os != "chromeos") || - (is_linux && current_cpu == "x64" && target_os != "chromeos")) + (is_linux && current_cpu == "x64" && target_os != "chromeos") || + (is_android && (current_cpu != "arm" || arm_version >= 7) && + current_cpu != "mipsel" && current_cpu != "mips64el")) } declare_args() { @@ -167,8 +169,9 @@ declare_args() { use_gold = (!use_lld && !(is_chromecast && is_linux && (current_cpu == "arm" || current_cpu == "mipsel")) && - (is_linux && (current_cpu == "x64" || current_cpu == "x86" || - current_cpu == "arm" || current_cpu == "mipsel"))) || + (is_linux && + (current_cpu == "x64" || current_cpu == "x86" || current_cpu == "arm" || + current_cpu == "mipsel" || current_cpu == "mips64el"))) || (is_android && (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm" || current_cpu == "arm64")) } diff --git a/chromium/build/config/coverage/BUILD.gn b/chromium/build/config/coverage/BUILD.gn index 36f2e66cf1a..6a6ec8877e2 100644 --- a/chromium/build/config/coverage/BUILD.gn +++ b/chromium/build/config/coverage/BUILD.gn @@ -10,6 +10,13 @@ config("default_coverage") { "-fprofile-instr-generate", "-fcoverage-mapping", "-fno-use-cxa-atexit", + + # Following experimental flags removes unused header functions from the + # coverage mapping data embedded in the test binaries, and the reduction + # of binary size enables building Chrome's large unit test targets on + # MacOS. Please refer to crbug.com/796290 for more details. + "-mllvm", + "-limited-coverage-experimental=true", ] ldflags = [ "-fprofile-instr-generate" ] } diff --git a/chromium/build/config/coverage/coverage.gni b/chromium/build/config/coverage/coverage.gni index 4ee7bedb81a..ee4734cfea9 100644 --- a/chromium/build/config/coverage/coverage.gni +++ b/chromium/build/config/coverage/coverage.gni @@ -16,11 +16,10 @@ declare_args() { assert(!use_clang_coverage || is_clang, "Clang Source-based Code Coverage requires clang.") -assert(!(use_clang_coverage && is_debug && is_component_build), - "If use_clang_coverage is true and is_debug is true (is_debug " + - "defaults to true), then is_component_build must be false.$0x0A" + - "Try adding is_component_build=false to your GN args.") - assert( !(use_clang_coverage && is_component_build), - "Clang Source-based Code Coverage is incompatible with is_component_build.") + "Clang Source-based Code Coverage requires \"is_component_build=false\" " + + "flag because: There will be no coverage info for libraries in " + + "component builds and \"is_component_build\" is set to true by " + + "\"is_debug\" unless it is explicitly set to false.$0x0ATry adding " + + "\"is_component_build=false\" to your GN args.") diff --git a/chromium/build/config/fuchsia/BUILD.gn b/chromium/build/config/fuchsia/BUILD.gn index b346cc05150..14c5b218813 100644 --- a/chromium/build/config/fuchsia/BUILD.gn +++ b/chromium/build/config/fuchsia/BUILD.gn @@ -33,11 +33,11 @@ config("compiler") { # patches, we might want to make tools/clang/scripts/update.py build it # and bundle it with the clang package instead of using the library from # the SDK, https://crbug.com/724204 - # Note: Intentionally 6.0.0 instead of $clang_version because the clang + # Note: Intentionally 7.0.0 instead of $clang_version because the clang # version of the toolchain_libs directory in the Fuchsia SDK can be # different from the version of Chromium's clang. "-resource-dir", - rebase_path(fuchsia_sdk, root_build_dir) + "/toolchain_libs/clang/6.0.0", + rebase_path(fuchsia_sdk, root_build_dir) + "/toolchain_libs/clang/7.0.0", # The stack defaults to 256k on Fuchsia (see # https://fuchsia.googlesource.com/zircon/+/master/system/private/zircon/stack.h#9), diff --git a/chromium/build/config/fuchsia/build_manifest.py b/chromium/build/config/fuchsia/build_manifest.py new file mode 100644 index 00000000000..15f9cc1c47d --- /dev/null +++ b/chromium/build/config/fuchsia/build_manifest.py @@ -0,0 +1,141 @@ +# Copyright 2018 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Creates a archive manifest used for Fuchsia package generation. + +Arguments: + root_dir: The absolute path to the Chromium source tree root. + + out_dir: The absolute path to the Chromium build directory. + + app_name: The filename of the package's executable target. + + runtime_deps: The path to the GN runtime deps file. + + output_path: The path of the manifest file which will be written. +""" + +import json +import os +import sys +import tempfile + + +# Path to file describing the services to be made available to the process. +SANDBOX_POLICY_PATH = 'build/config/fuchsia/sandbox_policy' + + +def MakePackagePath(file_path, roots): + """Computes a path for |file_path| that is relative to one of the directory + paths in |roots|. + + file_path: The absolute file path to relativize. + roots: A list of absolute directory paths which may serve as a relative root + for |file_path|. At least one path must contain |file_path|. + Overlapping roots are permitted; the deepest matching root will be + chosen. + + Examples: + + >>> MakePackagePath('/foo/bar.txt', ['/foo/']) + 'bar.txt' + + >>> MakePackagePath('/foo/dir/bar.txt', ['/foo/']) + 'dir/bar.txt' + + >>> MakePackagePath('/foo/out/Debug/bar.exe', ['/foo/', '/foo/out/Debug/']) + 'bar.exe' + """ + + # Prevents greedily matching against a shallow path when a deeper, better + # matching path exists. + roots.sort(key=len, reverse=True) + + for next_root in roots: + if not next_root.endswith(os.sep): + next_root += os.sep + + if file_path.startswith(next_root): + relative_path = file_path[len(next_root):] + + # TODO(fuchsia): The requirements for finding/loading .so are in flux, so + # this ought to be reconsidered at some point. + # See https://crbug.com/732897. + if file_path.endswith('.so'): + relative_path = 'lib/' + os.path.basename(relative_path) + + return relative_path + + raise Exception('Error: no matching root paths found for \'%s\'.' % file_path) + + +def _GetStrippedPath(bin_path): + """Finds the stripped version of the binary |bin_path| in the build + output directory.""" + + if not '.unstripped' in bin_path: + raise Exception('File "%s" is not in an .unstripped directory.' % bin_path) + + return os.path.normpath(os.path.join(bin_path, + os.path.pardir, + os.path.pardir, + os.path.basename(bin_path))) + + +def _IsBinary(path): + """Checks if the file at |path| is an ELF executable by inspecting its FourCC + header.""" + + with open(path, 'rb') as f: + file_tag = f.read(4) + return file_tag == '\x7fELF' + + +def BuildManifest(root_dir, out_dir, app_name, runtime_deps_file, output_path): + with open(output_path, 'w') as output: + # Process the runtime deps file for file paths, recursively walking + # directories as needed. + # runtime_deps may contain duplicate paths, so use a set for + # de-duplication. + expanded_files = set() + for next_path in open(runtime_deps_file, 'r'): + next_path = next_path.strip() + if os.path.isdir(next_path): + for root, _, files in os.walk(next_path): + for next_file in files: + if next_file.startswith('.'): + continue + expanded_files.add(os.path.abspath(os.path.join(root, next_file))) + else: + expanded_files.add(os.path.abspath(next_path)) + + # Format and write out the manifest contents. + app_found = False + for next_file in expanded_files: + if _IsBinary(next_file): + next_file = _GetStrippedPath(next_file) + + in_package_path = MakePackagePath(os.path.join(out_dir, next_file), + [root_dir, out_dir]) + if in_package_path == app_name: + in_package_path = 'bin/app' + app_found = True + + # The source path is relativized so that it can be used on multiple + # environments with differing parent directory structures, + # e.g. builder bots and swarming clients. + output.write('%s=%s\n' % (in_package_path, + os.path.relpath(next_file, out_dir))) + if not app_found: + raise Exception('Could not locate executable inside runtime_deps.') + output.write('meta/sandbox=' + + os.path.relpath(os.path.join(root_dir, SANDBOX_POLICY_PATH), + out_dir)) + + return 0 + + +if __name__ == '__main__': + sys.exit(BuildManifest(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], + sys.argv[5])) diff --git a/chromium/build/config/fuchsia/package.gni b/chromium/build/config/fuchsia/package.gni new file mode 100644 index 00000000000..36effa60ee6 --- /dev/null +++ b/chromium/build/config/fuchsia/package.gni @@ -0,0 +1,85 @@ +# Copyright 2018 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Creates a Fuchsia .far package file. +# +# Parameters are: +# package_name: The name of the package to build. +# binary: The name of the executable which should be launched by the package. +# Will be renamed as "bin/app" in the package contents. +# deps: A list of targets whose output will be included in the package. +template("package") { + pkg = { + package_name = target_name + forward_variables_from(invoker, "*") + } + assert(defined(pkg.binary)) + + _pkg_out_dir = "$root_out_dir/gen/" + get_label_info(pkg.package_name, "dir") + _runtime_deps_file = "$_pkg_out_dir/${pkg.package_name}.runtime_deps" + _manifest_file = "$_pkg_out_dir/${pkg.package_name}.archive_manifest" + _archive_file = "$_pkg_out_dir/${pkg.package_name}.far" + _write_manifest_target = "${pkg.package_name}__write_manifest" + + # Generates a manifest file based on the GN runtime deps + # suitable for "far" tool consumption. + action(_write_manifest_target) { + forward_variables_from(invoker, + [ + "deps", + "public_deps", + "testonly", + ]) + + script = "//build/config/fuchsia/build_manifest.py" + + inputs = [ + _runtime_deps_file, + ] + + outputs = [ + _manifest_file, + ] + + data_deps = pkg.deps + + args = [ + rebase_path("//"), + rebase_path(root_out_dir), + pkg.binary, + rebase_path(_runtime_deps_file), + rebase_path(_manifest_file), + ] + + write_runtime_deps = _runtime_deps_file + } + + # Packages an executable target and its dependencies into a Fuchsia archive + # file (.far). + action(target_name) { + forward_variables_from(invoker, [ "testonly" ]) + + far_tool_path = "//third_party/fuchsia-sdk/tools/far" + script = "//build/gn_run_binary.py" + + deps = [ + ":$_write_manifest_target", + ] + + outputs = [ + _archive_file, + ] + + data = [ + _archive_file, + ] + + args = [ + rebase_path(far_tool_path, root_build_dir), + "create", + "--archive=" + rebase_path(_archive_file), + "--manifest=" + rebase_path(_manifest_file), + ] + } +} diff --git a/chromium/build/config/fuchsia/rules.gni b/chromium/build/config/fuchsia/rules.gni index 4ecf71a89eb..8db998fd992 100644 --- a/chromium/build/config/fuchsia/rules.gni +++ b/chromium/build/config/fuchsia/rules.gni @@ -1,98 +1,150 @@ -# Copyright 2017 The Chromium Authors. All rights reserved. +# Copyright 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. assert(is_fuchsia) +import("//build/config/chromecast_build.gni") +import("//build/config/fuchsia/package.gni") + template("generate_runner_script") { # This runtime_deps file is used at runtime and thus cannot go in # target_gen_dir. - _target_dir_name = get_label_info(invoker.exe_target, "dir") - _target_shortname = get_label_info(invoker.exe_target, "name") - _runtime_deps_file = "$root_out_dir/gen.runtime/$_target_dir_name/$_target_shortname.runtime_deps" - _runtime_deps_target = "${target_name}__write_deps" + _runtime_deps_target = "${target_name}__deps" + _runtime_deps_file = + "$root_out_dir/gen.runtime/" + + get_label_info(invoker.root_target_name, "dir") + "/" + + get_label_info(invoker.root_target_name, "name") + ".runtime_deps" + _pkg_dir = "$root_out_dir/gen/" + get_label_info(invoker.package_name, "dir") + _manifest_path = "$_pkg_dir/${invoker.package_name}.archive_manifest" + _package_path = "$_pkg_dir/${invoker.package_name}.far" + _runner_target = "${target_name}_runner" + _legacy_runner_target = "${target_name}_legacy_runner" + group(_runtime_deps_target) { forward_variables_from(invoker, [ - "data", - "data_deps", "deps", - "public_deps", "testonly", ]) + data_deps = deps write_runtime_deps = _runtime_deps_file } - action(target_name) { + # Build both types of runner scripts until the legacy scripts can be removed. + # TODO(crbug.com/805057): delete legacy runner scripts. + group(target_name) { + forward_variables_from(invoker, [ "testonly" ]) + data_deps = [ + ":${_legacy_runner_target}", + ] + data_deps += [ ":${_runner_target}" ] + } + + action(_legacy_runner_target) { forward_variables_from(invoker, [ - "data_deps", "deps", "runner_script", "target", "testonly", ]) - if (!defined(deps)) { - deps = [] - } - if (!defined(data_deps)) { - data_deps = [] - } script = "//build/fuchsia/create_runner_script.py" depfile = "$target_gen_dir/$target_name.d" - data = [] - runner_args = [] - outputs = [ invoker.generated_script, ] - data += [ + + data = [ invoker.generated_script, - "//build/fuchsia/exe_runner.py", - "//build/fuchsia/test_runner.py", - "//build/fuchsia/runner_common.py", + "//build/fuchsia/", "//build/util/lib/", "//third_party/fuchsia-sdk/", + _runtime_deps_file, + ] + data_deps = [ + "//testing/buildbot/filters:fuchsia_filters", + ] + + # Arguments used at build time by the runner script generator. + args = [ + "--depfile", + rebase_path(depfile, root_build_dir), + "--script-output-path", + rebase_path(invoker.generated_script, root_build_dir), + "--exe-name", + rebase_path(invoker.exe_path, root_build_dir), ] - runner_args += [ + # Arguments used at runtime by the test runner. + if (defined(invoker.use_test_server) && invoker.use_test_server) { + args += [ "--enable-test-server" ] + } + args += [ "--runner-script", runner_script, "--output-directory", rebase_path(root_build_dir, root_build_dir), "--target-cpu", target_cpu, + "--runtime-deps-path", + rebase_path(_runtime_deps_file, root_build_dir), ] + } - deps += [ - ":$_runtime_deps_target", + action(_runner_target) { + forward_variables_from(invoker, + [ + "runner_script", + "target", + "testonly", + ]) + + deps = [ "//testing/buildbot/filters:fuchsia_filters", ] - data += [ _runtime_deps_file ] - runner_args += [ - "--runtime-deps-path", - rebase_path(_runtime_deps_file, root_build_dir), + + _generated_script = "${invoker.generated_script}_v2" + + script = "//build/fuchsia/runner_v2/create_runner_script.py" + + outputs = [ + _generated_script, ] - if (defined(args)) { - args = [] - } + data = [ + _generated_script, + _manifest_path, + "//build/fuchsia/runner_v2/", + "//build/util/lib/", + "//third_party/fuchsia-sdk/", + ] + + # Arguments used at build time by the runner script generator. args = [ - "--depfile", - rebase_path(depfile, root_build_dir), "--script-output-path", - rebase_path(invoker.generated_script, root_build_dir), - "--exe-name", - _target_shortname, + rebase_path(_generated_script, root_build_dir, root_out_dir), + "--package", + rebase_path(_package_path, root_out_dir, root_build_dir), + "--package-manifest", + rebase_path(_manifest_path, root_out_dir, root_build_dir), ] if (defined(invoker.use_test_server) && invoker.use_test_server) { args += [ "--enable-test-server" ] } - args += runner_args + # Arguments used at runtime by the test runner. + args += [ + "--runner-script", + runner_script, + "--output-directory", + rebase_path(root_build_dir, root_build_dir), + "--target-cpu", + target_cpu, + ] } } @@ -102,55 +154,84 @@ template("test_runner_script") { generate_runner_script(target_name) { testonly = true runner_script = "test_runner.py" - exe_target = invoker.test_name + exe_path = invoker.exe_path + root_target_name = invoker.test_name generated_script = - "$root_build_dir/bin/run_" + get_label_info(exe_target, "name") + "$root_build_dir/bin/run_" + get_label_info(invoker.test_name, "name") forward_variables_from(invoker, "*") } } # This template is used to generate a runner script for arbitrary executables # into the build dir for Fuchsia. The template should reference an "executable" -# target using the "exe_target" attribute. +# path using the "exe_path" attribute. # # Example usage: # +# _exe_path = "$root_out_dir/foo_fuchsia" # executable("foo") { # sources = [ "foo_main.cc" ] +# output_name = _exe_path # } # fuchsia_executable_runner("foo_fuchsia") { -# exe_target = ":foo" +# exe_path = _exe_path # } template("fuchsia_executable_runner") { - generate_runner_script(target_name) { - forward_variables_from(invoker, - [ - "testonly", - "exe_target", - "data_deps", - ]) + forward_variables_from(invoker, [ "exe_target" ]) + + _pkg_target = "${target_name}_pkg" + _gen_runner_target = "${target_name}_runner" + _archive_target = "${target_name}_archive" + _exe_name = get_label_info(exe_target, "name") + _exe_path = "${root_out_dir}/${_exe_name}" + + # Define the target dependencies as the union of the executable target + # and the invoker's deps. + if (defined(invoker.deps)) { + _combined_deps = invoker.deps + [ exe_target ] + } else { + _combined_deps = [ exe_target ] + } + + package(_pkg_target) { + forward_variables_from(invoker, [ "testonly" ]) + package_name = _exe_name + binary = _exe_name + deps = _combined_deps + } + + generate_runner_script(_gen_runner_target) { + forward_variables_from(invoker, [ "testonly" ]) runner_script = "exe_runner.py" - generated_script = - "$root_build_dir/bin/run_" + get_label_info(exe_target, "name") - if (!defined(data_deps)) { - data_deps = [] + generated_script = "$root_build_dir/bin/run_${_exe_name}" + deps = _combined_deps + exe_path = _exe_path + root_target_name = invoker.target_name + package_name = _exe_name + } + + group(target_name) { + forward_variables_from(invoker, [ "testonly" ]) + deps = [ + ":${_archive_target}", + ":${_gen_runner_target}", + ":${_pkg_target}", + ] + + # Disable packaging for Chromecast builds. (https://crbug.com/810069) + if (is_chromecast) { + deps -= [ ":${_pkg_target}" ] } - data_deps += [ exe_target ] } - generate_runner_script(target_name + "_archive") { - forward_variables_from(invoker, - [ - "testonly", - "exe_target", - "data_deps", - ]) + generate_runner_script(_archive_target) { + forward_variables_from(invoker, [ "testonly" ]) runner_script = "archive_builder.py" generated_script = "$root_build_dir/bin/archive_" + get_label_info(exe_target, "name") - if (!defined(data_deps)) { - data_deps = [] - } - data_deps += [ exe_target ] + deps = _combined_deps + exe_path = _exe_path + root_target_name = invoker.target_name + package_name = _exe_name } } diff --git a/chromium/build/config/fuchsia/sandbox_policy b/chromium/build/config/fuchsia/sandbox_policy new file mode 100644 index 00000000000..e3352a0e5b1 --- /dev/null +++ b/chromium/build/config/fuchsia/sandbox_policy @@ -0,0 +1,6 @@ +{ + "features": [ "persistent-storage", + "shell", + "system-temp" ] +} + diff --git a/chromium/build/config/gcc/BUILD.gn b/chromium/build/config/gcc/BUILD.gn index f1950bfec32..4b4d6fe795c 100644 --- a/chromium/build/config/gcc/BUILD.gn +++ b/chromium/build/config/gcc/BUILD.gn @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/c++/c++.gni") import("//build/config/compiler/compiler.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build/config/sysroot.gni") @@ -110,7 +111,7 @@ config("executable_ldconfig") { } else { # See the rpath_for... config above for why this is necessary for component # builds. Sanitizers use a custom libc++ where this is also necessary. - if (is_component_build || using_sanitizer) { + if (is_component_build || using_sanitizer || !libcpp_is_static) { configs = [ ":rpath_for_built_shared_libraries" ] } if (current_cpu == "mipsel" || current_cpu == "mips64el") { @@ -127,7 +128,7 @@ config("executable_ldconfig") { _rpath_link += "/$shlib_subdir" } if (is_android) { - _rebased_sysroot = rebase_path(sysroot, root_build_dir) + _rebased_sysroot = rebase_path(link_sysroot, root_build_dir) _rpath_link += ":$_rebased_sysroot/usr/lib" } diff --git a/chromium/build/config/ios/BUILD.gn b/chromium/build/config/ios/BUILD.gn index e768343cc20..47d36fc2fb9 100644 --- a/chromium/build/config/ios/BUILD.gn +++ b/chromium/build/config/ios/BUILD.gn @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/coverage/coverage.gni") import("//build/config/ios/ios_sdk.gni") import("//build/config/sysroot.gni") import("//build/toolchain/toolchain.gni") @@ -97,8 +98,8 @@ config("runtime_library") { cflags = common_flags ldflags = common_flags - if (ios_enable_coverage) { - configs = [ ":enable_coverage" ] + if (use_clang_coverage) { + configs = [ "//build/config/coverage:default_coverage" ] } } @@ -124,16 +125,6 @@ config("xctest_config") { ] } -# This enables support for LLVM code coverage. See -# http://llvm.org/docs/CoverageMappingFormat.html. -config("enable_coverage") { - cflags = [ - "-fprofile-instr-generate", - "-fcoverage-mapping", - ] - ldflags = [ "-fprofile-instr-generate" ] -} - group("xctest") { public_configs = [ ":xctest_config" ] } diff --git a/chromium/build/config/ios/ios_sdk.gni b/chromium/build/config/ios/ios_sdk.gni index 82ffac8be8a..35de13b28ef 100644 --- a/chromium/build/config/ios/ios_sdk.gni +++ b/chromium/build/config/ios/ios_sdk.gni @@ -36,10 +36,6 @@ declare_args() { # to avoid running out of certificates if using a free account. ios_automatically_manage_certs = true - # Enabling this option makes clang compile for profiling to gather code - # coverage metrics. - ios_enable_coverage = false - # If non-empty, this list must contain valid cpu architecture, and the final # build will be a multi-architecture build (aka fat build) supporting the # main $target_cpu architecture and all of $additional_target_cpus. diff --git a/chromium/build/config/ios/rules.gni b/chromium/build/config/ios/rules.gni index 95f72f72f53..f820ef36e26 100644 --- a/chromium/build/config/ios/rules.gni +++ b/chromium/build/config/ios/rules.gni @@ -1274,7 +1274,9 @@ template("ios_framework_bundle") { deps = [] } deps += [ ":$_arch_shared_library_source" ] - + if (_has_public_headers) { + deps += [ ":$_framework_headers_target($default_toolchain)" ] + } if (!defined(ldflags)) { ldflags = [] } @@ -1399,9 +1401,11 @@ template("ios_framework_bundle") { forward_variables_from(invoker, [ "testonly" ]) deps = [ ":$_compile_headers_map_target", - ":$_copy_public_headers_target", ":$_create_module_map_target", ] + public_deps = [ + ":$_copy_public_headers_target", + ] } } @@ -1633,7 +1637,9 @@ template("ios_xctest_bundle") { if (ios_automatically_manage_certs) { # Use a fixed bundle identifier for EarlGrey tests when using Xcode to # manage the certificates as the number of free certs is limited. - extra_substitutions = [ "MODULE_BUNDLE_ID=gtest.${ios_generic_test_bundle_id_suffix}-module" ] + extra_substitutions = [ + "MODULE_BUNDLE_ID=gtest.${ios_generic_test_bundle_id_suffix}-module", + ] } else { extra_substitutions = [ "MODULE_BUNDLE_ID=gtest.$_output_name" ] } diff --git a/chromium/build/config/jumbo.gni b/chromium/build/config/jumbo.gni index 427bb1fb541..6b146d9a764 100644 --- a/chromium/build/config/jumbo.gni +++ b/chromium/build/config/jumbo.gni @@ -84,31 +84,7 @@ template("internal_jumbo_target") { invoker_sources = [] } - if (invoker_sources != []) { - gen_target_dir = get_path_info(invoker_sources[0], "gen_dir") - assert(excluded_sources != [] || true) # Prevent "unused variable". - - # Find the gen_target_dir directory with shortest path. Short paths - # are nice in themselves since they mean shorter error messages and - # fewer bytes to parse, but the currently deployed version of ninja - # also has a limitation where it only allows 32 path components in - # Windows. - # See https://crbug.com/738186 and - # https://github.com/ninja-build/ninja/issues/1161 - foreach(source_file, invoker_sources) { - possibly_better_gen_target_dir = get_path_info(gen_target_dir, "dir") - possibly_better_gen_target_dir_2 = - get_path_info(possibly_better_gen_target_dir, "dir") - alt_gen_target_dir = get_path_info(source_file, "gen_dir") - if (alt_gen_target_dir == possibly_better_gen_target_dir || - alt_gen_target_dir == possibly_better_gen_target_dir_2) { - gen_target_dir = alt_gen_target_dir - } - } - } else { - gen_target_dir = "<will not be used>" # Will not result in - # anything used anyway. - } + gen_target_dir = invoker.target_gen_dir assert(gen_target_dir != "") # Prevent "unused variable". diff --git a/chromium/build/config/linux/OWNERS b/chromium/build/config/linux/OWNERS new file mode 100644 index 00000000000..280ba478dca --- /dev/null +++ b/chromium/build/config/linux/OWNERS @@ -0,0 +1 @@ +thomasanderson@chromium.org diff --git a/chromium/build/config/linux/pkg-config.py b/chromium/build/config/linux/pkg-config.py index 5ef73227df0..a3339f8e2ad 100755 --- a/chromium/build/config/linux/pkg-config.py +++ b/chromium/build/config/linux/pkg-config.py @@ -224,7 +224,8 @@ def main(): # Output a GN array, the first one is the cflags, the second are the libs. The # JSON formatter prints GN compatible lists when everything is a list of # strings. - print json.dumps([includes, cflags, libs, lib_dirs, ldflags]) + cflags += map(lambda dir: "-isystem" + dir, includes) + print json.dumps([cflags, libs, lib_dirs, ldflags]) return 0 diff --git a/chromium/build/config/linux/pkg_config.gni b/chromium/build/config/linux/pkg_config.gni index 7358f8e763c..8f95457e928 100644 --- a/chromium/build/config/linux/pkg_config.gni +++ b/chromium/build/config/linux/pkg_config.gni @@ -101,13 +101,12 @@ template("pkg_config") { } pkgresult = exec_script(pkg_config_script, args, "value") - include_dirs = pkgresult[0] - cflags = pkgresult[1] + cflags = pkgresult[0] if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) { - libs = pkgresult[2] - lib_dirs = pkgresult[3] - ldflags = pkgresult[4] + libs = pkgresult[1] + lib_dirs = pkgresult[2] + ldflags = pkgresult[3] } forward_variables_from(invoker, diff --git a/chromium/build/config/merge_for_jumbo.py b/chromium/build/config/merge_for_jumbo.py index 4892c07e231..573b7472522 100755 --- a/chromium/build/config/merge_for_jumbo.py +++ b/chromium/build/config/merge_for_jumbo.py @@ -15,20 +15,6 @@ import argparse import cStringIO import os -# Files that appear in sources lists but have no effect and are -# ignored by the build system. We warn for unexpected files in the -# sources list, but these are ok. -NOOP_FILE_SUFFIXES = ( - ".css", - ".g", - ".idl", - ".inc", - ".js", - ".json", - ".py", -) - - def write_jumbo_files(inputs, outputs, written_input_set, written_output_set): output_count = len(outputs) input_count = len(inputs) @@ -93,15 +79,7 @@ def main(): write_jumbo_files(inputs, outputs, written_input_set, written_output_set) - header_files = set([x for x in all_inputs if x.endswith(".h")]) assert set(args.outputs) == written_output_set, "Did not fill all outputs" - random_files_to_ignore = set([x for x in all_inputs - if x.endswith(NOOP_FILE_SUFFIXES)]) - files_not_included = set(all_inputs) - (written_input_set | - header_files | - random_files_to_ignore) - assert not files_not_included, ("Jumbo build left out files: %s" % - files_not_included) if args.verbose: print("Generated %s (%d files) based on %s" % ( str(args.outputs), len(written_input_set), args.file_list)) diff --git a/chromium/build/config/posix/BUILD.gn b/chromium/build/config/posix/BUILD.gn index ae4a1bff8f0..55860cff103 100644 --- a/chromium/build/config/posix/BUILD.gn +++ b/chromium/build/config/posix/BUILD.gn @@ -49,14 +49,6 @@ config("runtime_library") { "-isystem" + rebase_path("$libcxxabi_prefix/include", root_build_dir), ] - # This condition should match the one in buildtools/third_party/libc++abi. - if ((is_linux && current_cpu == "arm") || is_fuchsia) { - cflags_c += [ "-isystem" + - rebase_path("$libunwind_prefix/include", root_build_dir) ] - cflags_cc += [ "-isystem" + - rebase_path("$libunwind_prefix/include", root_build_dir) ] - } - # Make sure we don't link against libc++ or libstdc++. if (is_clang) { ldflags += [ "-nostdlib++" ] @@ -79,28 +71,6 @@ config("runtime_library") { if (!is_mac && !is_ios && sysroot != "") { # Pass the sysroot to all C compiler variants, the assembler, and linker. sysroot_flags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ] - - # Android uses unified headers in NDK r16 and later, meaning that the - # compile time sysroot and link time sysroot are different - link_sysroot = sysroot - if (is_android) { - if (current_cpu == "arm") { - link_sysroot = "$android_ndk_root/$arm_android_sysroot_subdir" - } else if (current_cpu == "arm64") { - link_sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir" - } else if (current_cpu == "x86") { - link_sysroot = "$android_ndk_root/$x86_android_sysroot_subdir" - } else if (current_cpu == "x64") { - link_sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir" - } else if (current_cpu == "mipsel") { - link_sysroot = "$android_ndk_root/$mips_android_sysroot_subdir" - } else if (current_cpu == "mips64el") { - link_sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir" - } else { - assert(false, "No android link sysroot for cpu: $target_cpu") - } - } - asmflags += sysroot_flags link_sysroot_flags = diff --git a/chromium/build/config/sanitizers/BUILD.gn b/chromium/build/config/sanitizers/BUILD.gn index 6e651a6f5e8..0b136843b76 100644 --- a/chromium/build/config/sanitizers/BUILD.gn +++ b/chromium/build/config/sanitizers/BUILD.gn @@ -255,16 +255,18 @@ config("common_sanitizer_flags") { assert(is_clang, "sanitizers only supported with clang") assert(!is_official_build, "sanitizers not supported in official builds") - if (!sanitizer_keep_symbols) { - cflags += [ "-gline-tables-only" ] - } + if (!sanitizer_no_symbols) { + if (!sanitizer_keep_symbols) { + cflags += [ "-gline-tables-only" ] + } - cflags += [ - # Column info in debug data confuses Visual Studio's debugger, so don't - # use this by default. However, clusterfuzz needs it for good attribution - # of reports to CLs, so turn it on there. - "-gcolumn-info", - ] + cflags += [ + # Column info in debug data confuses Visual Studio's debugger, so don't + # use this by default. However, clusterfuzz needs it for good + # attribution of reports to CLs, so turn it on there. + "-gcolumn-info", + ] + } # Frame pointers are controlled in //build/config/compiler:default_stack_frames } diff --git a/chromium/build/config/sanitizers/sanitizers.gni b/chromium/build/config/sanitizers/sanitizers.gni index efea1d48b62..73441af5d8f 100644 --- a/chromium/build/config/sanitizers/sanitizers.gni +++ b/chromium/build/config/sanitizers/sanitizers.gni @@ -107,6 +107,10 @@ declare_args() { # necessary, overriding any other symbol level arguments that may be set. # Setting this to true prevents this. sanitizer_keep_symbols = false + + # Builds fuzzer/sanitizers without symbols. Use with symbol_level=0. + # Useful for reducing binary size when building with use_clang_coverage=true. + sanitizer_no_symbols = false } # Disable sanitizers for non-default toolchains. diff --git a/chromium/build/config/sysroot.gni b/chromium/build/config/sysroot.gni index daab5f87b12..d5daf2df2e4 100644 --- a/chromium/build/config/sysroot.gni +++ b/chromium/build/config/sysroot.gni @@ -15,9 +15,9 @@ declare_args() { # The absolute path to directory containing linux sysroot images target_sysroot_dir = "//build/linux" - use_sysroot = - current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm" || - current_cpu == "arm64" || current_cpu == "mipsel" + use_sysroot = current_cpu == "x86" || current_cpu == "x64" || + current_cpu == "arm" || current_cpu == "arm64" || + current_cpu == "mipsel" || current_cpu == "mips64el" } if (current_os == target_os && current_cpu == target_cpu && @@ -32,15 +32,17 @@ if (current_os == target_os && current_cpu == target_cpu && # By default build against a sysroot image downloaded from Cloud Storage # during gclient runhooks. if (current_cpu == "x64") { - sysroot = "$target_sysroot_dir/debian_stretch_amd64-sysroot" + sysroot = "$target_sysroot_dir/debian_sid_amd64-sysroot" } else if (current_cpu == "x86") { - sysroot = "$target_sysroot_dir/debian_stretch_i386-sysroot" + sysroot = "$target_sysroot_dir/debian_sid_i386-sysroot" } else if (current_cpu == "mipsel") { - sysroot = "$target_sysroot_dir/debian_stretch_mips-sysroot" + sysroot = "$target_sysroot_dir/debian_sid_mips-sysroot" + } else if (current_cpu == "mips64el") { + sysroot = "$target_sysroot_dir/debian_sid_mips64el-sysroot" } else if (current_cpu == "arm") { - sysroot = "$target_sysroot_dir/debian_stretch_arm-sysroot" + sysroot = "$target_sysroot_dir/debian_sid_arm-sysroot" } else if (current_cpu == "arm64") { - sysroot = "$target_sysroot_dir/debian_stretch_arm64-sysroot" + sysroot = "$target_sysroot_dir/debian_sid_arm64-sysroot" } else { assert(false, "No linux sysroot for cpu: $target_cpu") } @@ -76,3 +78,26 @@ if (current_os == target_os && current_cpu == target_cpu && } else { sysroot = "" } + +if (is_android) { + # Android uses unified headers in NDK r16 and later, meaning that the + # compile time sysroot and link time sysroot are different + link_sysroot = sysroot + if (current_cpu == "arm") { + link_sysroot = "$android_ndk_root/$arm_android_sysroot_subdir" + } else if (current_cpu == "arm64") { + link_sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir" + } else if (current_cpu == "x86") { + link_sysroot = "$android_ndk_root/$x86_android_sysroot_subdir" + } else if (current_cpu == "x64") { + link_sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir" + } else if (current_cpu == "mipsel") { + link_sysroot = "$android_ndk_root/$mips_android_sysroot_subdir" + } else if (current_cpu == "mips64el") { + link_sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir" + } else { + assert(false, "No android link sysroot for cpu: $target_cpu") + } +} else { + link_sysroot = sysroot +} diff --git a/chromium/build/config/win/BUILD.gn b/chromium/build/config/win/BUILD.gn index 80bfa75f2e1..1f6bc13e087 100644 --- a/chromium/build/config/win/BUILD.gn +++ b/chromium/build/config/win/BUILD.gn @@ -3,6 +3,7 @@ # found in the LICENSE file. import("//build/config/chrome_build.gni") +import("//build/config/c++/c++.gni") import("//build/config/clang/clang.gni") import("//build/config/compiler/compiler.gni") import("//build/config/sanitizers/sanitizers.gni") @@ -61,8 +62,6 @@ config("compiler") { "/Zc:sizedDealloc-", ] - # Building with Clang on Windows is a work in progress and very - # experimental. See crbug.com/82385. if (is_clang) { cflags += [ "-fmsc-version=1911" ] @@ -85,6 +84,14 @@ config("compiler") { lib_dirs = [ "$clang_base_path/lib/clang/$clang_version/lib/windows" ] } + if (use_lld) { + # /Brepro lets the compiler not write the mtime field in the .obj output. + # link.exe /incremental relies on this field to work correctly, but lld + # never looks at this timestamp, so it's safe to pass this flag with + # lld and get more deterministic compiler output in return. + cflags += [ "/Brepro" ] + } + # /PROFILE ensures that the PDB file contains FIXUP information (growing the # PDB file by about 5%) but does not otherwise alter the output binary. This # information is used by the Syzygy optimization tool when decomposing the @@ -217,13 +224,26 @@ config("runtime_library") { # However it is prohibited when using /analyze defines += [ "_USING_V110_SDK71_" ] } + + if (use_custom_libcxx) { + cflags_cc = [ "-I" + rebase_path("$libcxx_prefix/include", root_build_dir) ] + if (libcpp_is_static) { + defines += [ "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS" ] + } + + # Prevent libc++ from embedding linker flags to try to automatically link + # against its runtime library. This is unnecessary with our build system, + # and can also result in build failures if libc++'s name for a library does + # not match ours. + defines += [ "_LIBCPP_NO_AUTO_LINK" ] + } } # Sets the default Windows build version. This is separated because some # targets need to manually override it for their compiles. config("winver") { defines = [ - "NTDDI_VERSION=0x0A000000", + "NTDDI_VERSION=0x0A000002", "_WIN32_WINNT=0x0A00", "WINVER=0x0A00", ] @@ -262,20 +282,9 @@ config("common_linker_setup") { "/ignore:4199", "/ignore:4221", "/NXCOMPAT", + "/DYNAMICBASE", ] - # ASLR makes debugging with windbg difficult because Chrome.exe and - # Chrome.dll share the same base name. As result, windbg will name the - # Chrome.dll module like chrome_<base address>, where <base address> - # typically changes with each launch. This in turn means that breakpoints in - # Chrome.dll don't stick from one launch to the next. For this reason, we - # turn ASLR off in debug builds. - if (is_debug) { - ldflags += [ "/DYNAMICBASE:NO" ] - } else { - ldflags += [ "/DYNAMICBASE" ] - } - if (win_linker_timing) { ldflags += [ "/time", @@ -289,8 +298,9 @@ config("cfi_linker") { # https://msdn.microsoft.com/en-us/library/windows/desktop/mt637065.aspx # /DYNAMICBASE (ASLR) is turned off in debug builds, therefore CFG can’t be # turned on either. - # TODO(thakis): Turn this on with lld once supported, https://crbug.com/693709 - if (!is_debug && !use_lld) { + # CFG seems to lead to random corruption with incremental linking so turn off + # CFG in component builds. https://crbug.com/812421 + if (!is_debug && !is_component_build) { # Turn on CFG in msvc linker, regardless of compiler used. Turn off CFG for # longjmp (new in VS 2017) because it relies on compiler support which we do # not have enabled. @@ -373,6 +383,9 @@ config("windowed") { incremental_linking_on_switch = [ "/INCREMENTAL" ] incremental_linking_off_switch = [ "/INCREMENTAL:NO" ] +if (use_lld) { + incremental_linking_on_switch += [ "/OPT:NOREF" ] +} # Disable incremental linking for syzyasan, enable for debug builds and all # component builds - any builds where performance is not job one. |