diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 7c66e9638dd710..8e868beb244a2c 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -150,6 +150,15 @@ config("abi_default") { ldflags = cflags } +config("dead_code_elimination_default") { + # Delete unreferenced sections. Helpful with -ffunction-sections. + if (current_os == "mac" || current_os == "ios") { + ldflags = [ "-Wl,-dead_strip" ] + } else { + ldflags = [ "-Wl,--gc-sections" ] + } +} + config("target_default") { if (current_toolchain == default_toolchain) { defines = target_defines diff --git a/build/config/defaults.gni b/build/config/defaults.gni index 45d6d4983d660a..a36b6f8447279d 100644 --- a/build/config/defaults.gni +++ b/build/config/defaults.gni @@ -82,6 +82,10 @@ declare_args() { # Defaults target-specific configs. default_configs_target = [ "${build_root}/config/compiler:target_default" ] + # Default configs for dead code elimination. + default_configs_dead_code = + [ "${build_root}/config/compiler:dead_code_elimination_default" ] + # Extra default configs. default_configs_extra = [] } @@ -105,6 +109,7 @@ default_configs += default_configs_aliasing default_configs += default_configs_sanitize default_configs += default_configs_fuzzing default_configs += default_configs_target +default_configs += default_configs_dead_code default_configs += default_configs_extra executable_default_configs = [] diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 36df1fdd8bade3..ea8e67b985c21f 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -58,6 +58,11 @@ EOF PW_ROOT="$_CHIP_ROOT/third_party/pigweed/repo" export PW_ROOT + # Do not force use Rosetta in Pigweed because Matter is using host toolchain + if [ -z "$PW_BOOTSTRAP_USE_ROSETTA" ]; then + export PW_BOOTSTRAP_USE_ROSETTA=false + fi + . "$_CHIP_ROOT/third_party/pigweed/repo/pw_env_setup/util.sh" _chip_bootstrap_banner() { diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index 67506a1a4487c7..bf7419765c0469 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit 67506a1a4487c7fb1306bedc391883ec58841522 +Subproject commit bf7419765c046936297341b28c89d419971506ec