[libcxx-commits] [libcxx] [libcxxabi] [libcxx][cmake] Allow using FatLTO in libc++ builds (PR #112277)
Paul Kirth via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 14 15:27:49 PDT 2024
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/112277
>From 1dafa521d5a1e10e3f79f63a661b2e14acff5a4a Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Mon, 14 Oct 2024 15:06:38 -0700
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
=?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
---
libcxx/CMakeLists.txt | 4 ++++
libcxx/src/CMakeLists.txt | 10 ++++++++++
libcxxabi/src/CMakeLists.txt | 10 ++++++++++
3 files changed, 24 insertions(+)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index f1942e963ccc31..5a68237f7336c5 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -102,6 +102,10 @@ option(LIBCXX_ENABLE_WIDE_CHARACTERS
support the C functionality for wide characters. When wide characters are
not supported, several parts of the library will be disabled, notably the
wide character specializations of std::basic_string." ON)
+ option(LIBCXX_ENABLE_FATLTO
+ "Whether to compile libc++ with FatLTO enabled." ON)
+ option(LIBCXX_ENABLE_LTO
+ "Whether to compile libc++ with LTO enabled." ON)
# To use time zone support in libc++ the platform needs to have the IANA
# database installed. Libc++ will fail to build if this is enabled on a
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index b187677ff2db52..670db758f53173 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -173,6 +173,16 @@ if (APPLE AND LLVM_USE_SANITIZER)
endif()
endif()
+
+if(LIBCXX_ENABLE_LTO)
+ list(APPEND LIBCXX_COMPILE_FLAGS "-flto")
+ list(APPEND LIBCXX_LINK_FLAGS "-flto")
+endif()
+if(LIBCXX_ENABLE_FATLTO)
+ list(APPEND LIBCXX_COMPILE_FLAGS "-ffat-lto-objects")
+ list(APPEND LIBCXX_LINK_FLAGS "-ffat-lto-objects")
+endif()
+
split_list(LIBCXX_COMPILE_FLAGS)
split_list(LIBCXX_LINK_FLAGS)
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 480e528b819bb9..822ede39c6a525 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -143,6 +143,15 @@ if ( APPLE )
endif()
endif()
+if(LIBCXX_ENABLE_LTO)
+ list(APPEND LIBCXXABI_COMPILE_FLAGS "-flto")
+ list(APPEND LIBCXXABI_LINK_FLAGS "-flto")
+endif()
+if(LIBCXX_ENABLE_FATLTO)
+ list(APPEND LIBCXXABI_COMPILE_FLAGS "-ffat-lto-objects")
+ list(APPEND LIBCXXABI_LINK_FLAGS "-ffat-lto-objects")
+endif()
+
split_list(LIBCXXABI_COMPILE_FLAGS)
split_list(LIBCXXABI_LINK_FLAGS)
@@ -154,6 +163,7 @@ endif()
include(WarningFlags)
+
# Build the shared library.
add_library(cxxabi_shared_objects OBJECT EXCLUDE_FROM_ALL ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS})
cxx_add_warning_flags(cxxabi_shared_objects ${LIBCXXABI_ENABLE_WERROR} ${LIBCXXABI_ENABLE_PEDANTIC})
>From 38851d29d9eaf5e3c597be3f9f57179f308ba335 Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Mon, 14 Oct 2024 15:27:36 -0700
Subject: [PATCH 2/2] Remove newline from diff
Created using spr 1.3.4
---
libcxxabi/src/CMakeLists.txt | 1 -
1 file changed, 1 deletion(-)
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 1a1e57aa0077b4..783f17583c62e0 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -163,7 +163,6 @@ endif()
include(WarningFlags)
-
# Build the shared library.
add_library(cxxabi_shared_objects OBJECT EXCLUDE_FROM_ALL ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS})
cxx_add_warning_flags(cxxabi_shared_objects ${LIBCXXABI_ENABLE_WERROR} ${LIBCXXABI_ENABLE_PEDANTIC})
More information about the libcxx-commits
mailing list