From d0e912ea56723e4e00d189bb9e270fea0c03e40d Mon Sep 17 00:00:00 2001 From: Prabhdeep Singh Soni Date: Thu, 28 Aug 2025 18:02:26 -0400 Subject: [PATCH] Use -flto=thin when using CFI Signed-off-by: Prabhdeep Singh Soni --- config/sanitizers/BUILD.gn | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/config/sanitizers/BUILD.gn b/config/sanitizers/BUILD.gn index 358fb78171..3274338531 100755 --- a/config/sanitizers/BUILD.gn +++ b/config/sanitizers/BUILD.gn @@ -3,6 +3,7 @@ # found in the LICENSE file. import("//build/config/clang/clang.gni") +import("//build/config/compiler/compiler.gni") import("//build/config/ohos/config.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build/misc/overrides/build.gni") @@ -630,8 +631,13 @@ config("cfi_config_release") { _cfi_blocklist_path = "//build/config/sanitizers/cfi_blocklist.txt" configs = [ "//build/config/gcc:symbol_visibility_default" ] - cflags = [ - "-flto", + cflags = [] + if (use_thin_lto) { + cflags += [ "-flto=thin" ] + } else { + cflags += [ "-flto" ] + } + cflags += [ "-fsanitize=cfi", "-fsanitize-blacklist=" + rebase_path(_cfi_blocklist_path, root_build_dir), @@ -671,8 +677,13 @@ config("cfi_config_debug") { config("cfi_cross_dso_release") { configs = [ ":cfi_config_release" ] cflags = [ "-fsanitize-cfi-cross-dso" ] - ldflags = [ - "-flto", + ldflags = [] + if (use_thin_lto) { + ldflags += [ "-flto=thin" ] + } else { + ldflags += [ "-flto" ] + } + ldflags += [ "-fsanitize=cfi", "-fsanitize-cfi-cross-dso", ] -- Gitee