diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index d018af519d6c07..311f45470328f4 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -318,13 +318,25 @@ config("exceptions_default") { configs = [ ":no_exceptions" ] } -config("unwind_tables_default") { +config("unwind_tables") { + cflags = [ "-funwind-tables" ] +} + +config("no_unwind_tables") { cflags = [ "-fno-unwind-tables", "-fno-asynchronous-unwind-tables", ] } +config("unwind_tables_default") { + if (exclude_unwind_tables) { + configs = [ ":no_unwind_tables" ] + } else { + configs = [ ":unwind_tables" ] + } +} + config("size_default") { cflags = [ "-fno-common", diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni index a524bfeb3915a4..61c47f24e8832f 100644 --- a/build/config/compiler/compiler.gni +++ b/build/config/compiler/compiler.gni @@ -31,4 +31,7 @@ declare_args() { # Enable position independent executables (-pie). enable_pie = current_os == "linux" + + # Remove unwind tables from the binary to save space. + exclude_unwind_tables = current_os != "android" } diff --git a/build/config/defaults.gni b/build/config/defaults.gni index f94fed012b8801..45d6d4983d660a 100644 --- a/build/config/defaults.gni +++ b/build/config/defaults.gni @@ -48,6 +48,10 @@ declare_args() { default_configs_exceptions = [ "${build_root}/config/compiler:exceptions_default" ] + # Default configs for unwind tables. + default_configs_unwind_tables = + [ "${build_root}/config/compiler:unwind_tables_default" ] + # Defaults configs for rtti. default_configs_rtti = [ "${build_root}/config/compiler:rtti_default" ] @@ -91,6 +95,7 @@ default_configs += default_configs_symbols default_configs += default_configs_size default_configs += default_configs_specs default_configs += default_configs_exceptions +default_configs += default_configs_unwind_tables default_configs += default_configs_pic default_configs += default_configs_rtti default_configs += default_configs_warnings