diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 19e1985225c..462aaa5420e 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -236,6 +236,10 @@ if (is_win) { } if (is_posix) { _native_compiler_configs += [ "//build/config/gcc:no_exceptions" ] + if (is_product) { + _native_compiler_configs += + [ "//build/config/gcc:symbol_visibility_hidden" ] + } } if (is_linux) { diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index d651e4ff719..52256f5dfc0 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -75,10 +75,13 @@ config("compiler") { # so we do so here. Normal function visibility is controlled by # //build/config/gcc:symbol_visibility_hidden. "-fvisibility-inlines-hidden", - - # We need the frame pointer for CPU and heap profiling. - "-fno-omit-frame-pointer", ] + if (!is_product) { + common_flags += [ + # We need the frame pointer for CPU and heap profiling. + "-fno-omit-frame-pointer", + ] + } cflags_cc += common_flags cflags_objcc += common_flags diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index f5c13e9615d..f813be13bc5 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -4,35 +4,6 @@ import("runtime_args.gni") -declare_args() { - # Instead of using is_debug, we introduce a different flag for specifying a - # Debug build of Dart so that clients can still use a Release build of Dart - # while themselves doing a Debug build. - dart_debug = false - - # Set the runtime mode. This affects how the runtime is built and what - # features it has. Valid values are: - # 'develop' (the default) - VM is built to run as a JIT with all development - # features enabled. - # 'profile' - The VM is built to run with AOT compiled code with only the - # CPU profiling features enabled. - # 'release' - The VM is built to run with AOT compiled code with no developer - # features enabled. - # - # These settings are only used for Flutter, at the moment. A standalone build - # of the Dart VM should leave this set to "develop", and should set - # 'is_debug', 'is_release', or 'is_product'. - dart_runtime_mode = "develop" - - # Explicitly set the target architecture in case of precompilation. Leaving - # this unspecified results in automatic target architecture detection. - # Available options are: arm, arm64, x64, and ia32 - dart_target_arch = "" - - # The optimization level to use for debug builds. - dart_debug_optimization_level = "2" -} - config("dart_public_config") { include_dirs = [ "." ] } diff --git a/runtime/bin/BUILD.gn b/runtime/bin/BUILD.gn index 77377779842..8de7a1b0a8c 100644 --- a/runtime/bin/BUILD.gn +++ b/runtime/bin/BUILD.gn @@ -619,7 +619,7 @@ template("dart_executable") { if (is_fuchsia) { configs -= [ "//build/config:symbol_visibility_hidden" ] } - if (defined(is_fuchsia_host) && is_fuchsia_host) { + if (is_fuchsia_host) { # We already have these in the standalone build, but Fuchsia doesn't # have them. They are needed for running Fuchsia binaries built for the # host. @@ -631,7 +631,6 @@ template("dart_executable") { } deps = [ - ":gen_resources_cc", ":standalone_dart_io", ":libdart_builtin", "$dart_zlib_path", @@ -651,7 +650,6 @@ template("dart_executable") { "snapshot_utils.h", "vmservice_impl.cc", "vmservice_impl.h", - "$target_gen_dir/resources_gen.cc", ] + extra_sources include_dirs = [ @@ -662,7 +660,9 @@ template("dart_executable") { if (is_win) { ldflags = [ "/EXPORT:Dart_True" ] } else { - ldflags = [ "-rdynamic" ] + if (dart_runtime_mode != "release") { + ldflags = [ "-rdynamic" ] + } } if (is_win) { @@ -685,29 +685,39 @@ dart_executable("dart") { extra_deps = [ "..:libdart_jit", ":dart_snapshot_cc", - "../observatory:standalone_observatory_archive", + ":gen_resources_cc", ] + if (dart_runtime_mode != "release") { + extra_deps += [ "../observatory:standalone_observatory_archive" ] + } extra_sources = [ "builtin_nolib.cc", "dfe.cc", "dfe.h", "loader.cc", "loader.h", + "$target_gen_dir/resources_gen.cc", ] + if (dart_runtime_mode == "release") { + extra_sources += [ "observatory_assets_empty.cc" ] + } } dart_executable("dart_precompiled_runtime") { extra_configs = [ "..:dart_precompiled_runtime_config" ] - extra_deps = [ - "..:libdart_precompiled_runtime", - "../observatory:standalone_observatory_archive", - ] + extra_deps = [ "..:libdart_precompiled_runtime" ] + if (dart_runtime_mode != "release") { + extra_deps += [ "../observatory:standalone_observatory_archive" ] + } extra_sources = [ "builtin_nolib.cc", "snapshot_empty.cc", "loader.cc", "loader.h", ] + if (dart_runtime_mode == "release") { + extra_sources += [ "observatory_assets_empty.cc" ] + } } dart_executable("dart_bootstrap") { @@ -716,21 +726,22 @@ dart_executable("dart_bootstrap") { "..:dart_no_snapshot_config", ] extra_deps = [ + ":gen_resources_cc", + ":generate_blink_cc_file", ":generate_builtin_cc_file", - ":generate_io_cc_file", - ":generate_io_patch_cc_file", + ":generate_cached_patches_cc_file", ":generate_html_cc_file", ":generate_html_common_cc_file", + ":generate_indexed_db_cc_file", + ":generate_io_cc_file", + ":generate_io_patch_cc_file", ":generate_js_cc_file", ":generate_js_util_cc_file", - ":generate_blink_cc_file", - ":generate_indexed_db_cc_file", - ":generate_cached_patches_cc_file", - ":generate_web_gl_cc_file", ":generate_metadata_cc_file", - ":generate_web_sql_cc_file", ":generate_svg_cc_file", ":generate_web_audio_cc_file", + ":generate_web_gl_cc_file", + ":generate_web_sql_cc_file", "..:libdart_nosnapshot_with_precompiler", ] extra_defines = [ "NO_OBSERVATORY" ] @@ -745,21 +756,22 @@ dart_executable("dart_bootstrap") { "snapshot_empty.cc", # Include generated source files. + "$target_gen_dir/blink_gen.cc", "$target_gen_dir/builtin_gen.cc", + "$target_gen_dir/cached_patches_gen.cc", + "$target_gen_dir/html_common_gen.cc", + "$target_gen_dir/html_gen.cc", + "$target_gen_dir/indexed_db_gen.cc", "$target_gen_dir/io_gen.cc", "$target_gen_dir/io_patch_gen.cc", - "$target_gen_dir/html_gen.cc", - "$target_gen_dir/html_common_gen.cc", "$target_gen_dir/js_gen.cc", "$target_gen_dir/js_util_gen.cc", - "$target_gen_dir/blink_gen.cc", - "$target_gen_dir/indexed_db_gen.cc", - "$target_gen_dir/cached_patches_gen.cc", - "$target_gen_dir/web_gl_gen.cc", "$target_gen_dir/metadata_gen.cc", - "$target_gen_dir/web_sql_gen.cc", + "$target_gen_dir/resources_gen.cc", "$target_gen_dir/svg_gen.cc", "$target_gen_dir/web_audio_gen.cc", + "$target_gen_dir/web_gl_gen.cc", + "$target_gen_dir/web_sql_gen.cc", ] } diff --git a/runtime/bin/vmservice_impl.cc b/runtime/bin/vmservice_impl.cc index 6a5cfccf7d1..82968c3ae45 100644 --- a/runtime/bin/vmservice_impl.cc +++ b/runtime/bin/vmservice_impl.cc @@ -41,7 +41,11 @@ struct ResourcesEntry { int length_; }; +#if defined(DART_PRECOMPILED_RUNTIME) +ResourcesEntry __service_bin_resources_[] = {{NULL, NULL, 0}}; +#else extern ResourcesEntry __service_bin_resources_[]; +#endif class Resources { public: diff --git a/runtime/runtime_args.gni b/runtime/runtime_args.gni index 750c2b4346b..d3f4710abf2 100644 --- a/runtime/runtime_args.gni +++ b/runtime/runtime_args.gni @@ -3,6 +3,38 @@ # BSD-style license that can be found in the LICENSE file. declare_args() { + # Instead of using is_debug, we introduce a different flag for specifying a + # Debug build of Dart so that clients can still use a Release build of Dart + # while themselves doing a Debug build. + dart_debug = false + + # Set the runtime mode. This affects how the runtime is built and what + # features it has. Valid values are: + # 'develop' (the default) - VM is built to run as a JIT with all development + # features enabled. + # 'profile' - The VM is built to run with AOT compiled code with only the + # CPU profiling features enabled. + # 'release' - The VM is built to run with AOT compiled code with no developer + # features enabled. + # + # These settings are only used for Flutter, at the moment. A standalone build + # of the Dart VM should leave this set to "develop", and should set + # 'is_debug', 'is_release', or 'is_product'. + # + # TODO(rmacnak): dart_runtime_mode no longer selects whether libdart is build + # for JIT or AOT, since libdart waw split into libdart_jit and + # libdart_precompiled_runtime. We should remove this flag and just set + # dart_debug/dart_product. + dart_runtime_mode = "develop" + + # Explicitly set the target architecture in case of precompilation. Leaving + # this unspecified results in automatic target architecture detection. + # Available options are: arm, arm64, x64, ia32, and dbc. + dart_target_arch = "" + + # The optimization level to use for debug builds. + dart_debug_optimization_level = "2" + # Whether to fall back to built-in root certificates when they cannot be # verified at the operating system level. dart_use_fallback_root_certificates = false diff --git a/third_party/tcmalloc/BUILD.gn b/third_party/tcmalloc/BUILD.gn index 09d69a982ab..c1b9f102ed4 100644 --- a/third_party/tcmalloc/BUILD.gn +++ b/third_party/tcmalloc/BUILD.gn @@ -92,9 +92,12 @@ source_set("tcmalloc") { "NDEBUG", ] - # Disable stack sampling for heap profiling in Product builds. if (is_product) { + # Disable stack sampling for heap profiling in Product builds. defines += [ "NO_TCMALLOC_SAMPLES" ] + + # To override the C library functions, we can't hide symbols. + configs -= [ "//build/config/gcc:symbol_visibility_hidden" ] } cflags = [ diff --git a/tools/gn.py b/tools/gn.py index 9b7fe2f96d5..5ac0bc97666 100755 --- a/tools/gn.py +++ b/tools/gn.py @@ -189,7 +189,10 @@ def ToGnArgs(args, mode, arch, target_os): # This setting is only meaningful for Flutter. Standalone builds of the VM # should leave this set to 'develop', which causes the build to defer to # 'is_debug', 'is_release' and 'is_product'. - gn_args['dart_runtime_mode'] = 'develop' + if mode == 'product': + gn_args['dart_runtime_mode'] = 'release' + else: + gn_args['dart_runtime_mode'] = 'develop' dont_use_clang = DontUseClang(args, gn_args['target_os'], gn_args['host_cpu'],