[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
Fri Feb 2 08:00:56 PST 2024
https://github.com/jsji updated https://github.com/llvm/llvm-project/pull/80328
>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 1/2] [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.
>From 7fea2347ca0ee3b08baefcc0fc8f7a33d7d3d934 Mon Sep 17 00:00:00 2001
From: Jinsong Ji <jinsong.ji at intel.com>
Date: Fri, 2 Feb 2024 08:00:44 -0800
Subject: [PATCH 2/2] Update GettingStarted doc
---
llvm/docs/GettingStarted.rst | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/llvm/docs/GettingStarted.rst b/llvm/docs/GettingStarted.rst
index 316fc6ad86b84..345dc41ba636c 100644
--- a/llvm/docs/GettingStarted.rst
+++ b/llvm/docs/GettingStarted.rst
@@ -1186,11 +1186,8 @@ following options with cmake:
should improve your build time slightly.
* -DLLVM_USE_SPLIT_DWARF
- Consider setting this to ON if you require a debug build, as this will ease
- memory pressure on the linker. This will make linking much faster, as the
- binaries will not contain any of the debug information; however, this will
- generate the debug information in the form of a DWARF object file (with the
- extension .dwo). This only applies to host platforms using ELF, such as Linux.
+ Consider setting this to OFF on Linux if you are using old debugger that doesn’t
+ support split dwarf.
.. _links:
More information about the llvm-commits
mailing list