[llvm] [CMake] Turn on LLVM_USE_SPLIT_DWARF by default for Linux Debug build (PR #80328)

Jinsong Ji via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 11:40:48 PST 2024


https://github.com/jsji created https://github.com/llvm/llvm-project/pull/80328

split-dwarf feature can help reducing compile time and build footprint.
See examples from:
https://www.productive-cpp.com/improving-cpp-builds-with-split-dwarf/

RelWithDebInfo build of X86 target shows 15%-37% footprint reduction.

The footprint w and w/o this PR are as below:

Default(BUILD_SHARED_LIBS=OFF):

Compile:
 63G vs. 100G  (37%)

Check-all:
 119G vs. 187G  (37%)

Shared lib (BUILD_SHARED_LIBS=ON):
Compile:
 20G vs. 24G (16%)

Check-all:
 28G vs. 33G (15%)

Debugability should not be affected.  Should help with compile time,
especially incremental build as well.


>From 5f6e725a5a263ea3dcaf4692f945721be0216ebd Mon Sep 17 00:00:00 2001
From: Jinsong Ji <jinsong.ji at intel.com>
Date: Thu, 1 Feb 2024 06:50:27 -0800
Subject: [PATCH] [CMake] Turn on LLVM_USE_SPLIT_DWARF by default for Linux
 Debug build

split-dwarf feature can help reducing compile time and build footprint.
See examples from:
https://www.productive-cpp.com/improving-cpp-builds-with-split-dwarf/

RelWithDebInfo build of X86 target shows 15%-37% footprint reduction.

The footprint w and w/o this PR are as below:

Default(BUILD_SHARED_LIBS=OFF):

Compile:
 63G vs. 100G  (37%)

Check-all:
 119G vs. 187G  (37%)

Shared lib (BUILD_SHARED_LIBS=ON):
Compile:
 20G vs. 24G (16%)

Check-all:
 28G vs. 33G (15%)

Debugability should not be affected.  Should help with compile time,
especially incremental build as well.
---
 llvm/CMakeLists.txt | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 485c76b8bb936..73f10748c5bc0 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -686,8 +686,14 @@ set(LLVM_UBSAN_FLAGS
 set(LLVM_LIB_FUZZING_ENGINE "" CACHE PATH
   "Path to fuzzing library for linking with fuzz targets")
 
-option(LLVM_USE_SPLIT_DWARF
-  "Use -gsplit-dwarf when compiling llvm and --gdb-index when linking." OFF)
+# Turn on split-dwarf by default for Linux, take effect on Debug/RelWithDbgInfo builds only.
+if (CMAKE_SYSTEM_NAME MATCHES "Linux")
+    option(LLVM_USE_SPLIT_DWARF
+        "Use -gsplit-dwarf when compiling llvm and --gdb-index when linking." ON)
+else()
+    option(LLVM_USE_SPLIT_DWARF
+        "Use -gsplit-dwarf when compiling llvm and --gdb-index when linking." OFF)
+endif()
 
 # Define an option controlling whether we should build for 32-bit on 64-bit
 # platforms, where supported.



More information about the llvm-commits mailing list