From a86576d8771c89502d239f0b85a1a6992020aa47 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Wed, 7 Mar 2018 19:32:36 +0000 Subject: [PATCH] Fix cmake's multi-config generators after r326738 LLVM_ENABLE_STATS isn't known at configure-time in these generators so we must defer it to build-time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326936 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/modules/HandleLLVMOptions.cmake | 4 +--- include/llvm/ADT/Statistic.h | 7 +++++++ include/llvm/Config/llvm-config.h.cmake | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index f508db2040c..86ce0bbcfd0 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -882,6 +882,4 @@ function(get_compile_definitions) endfunction() get_compile_definitions() -# The default for LLVM_ENABLE_STATS depends on whether NDEBUG is defined or not. -# LLVM_ENABLE_ASSERTIONS controls that so re-use it as the default. -option(LLVM_ENABLE_STATS "Enable statistics collection" ${LLVM_ENABLE_ASSERTIONS}) +option(LLVM_FORCE_ENABLE_STATS "Enable statistics collection for builds that wouldn't normally enable it" OFF) diff --git a/include/llvm/ADT/Statistic.h b/include/llvm/ADT/Statistic.h index 71d7db846e9..1cb6ac79002 100644 --- a/include/llvm/ADT/Statistic.h +++ b/include/llvm/ADT/Statistic.h @@ -32,6 +32,13 @@ #include #include +// Determine whether statistics should be enabled. We must do it here rather +// than in CMake because multi-config generators cannot determine this at +// configure time. +#if !defined(NDEBUG) || LLVM_FORCE_ENABLE_STATS +#define LLVM_ENABLE_STATS 1 +#endif + namespace llvm { class raw_ostream; diff --git a/include/llvm/Config/llvm-config.h.cmake b/include/llvm/Config/llvm-config.h.cmake index 6b1cb0b0d30..58cc9f99d99 100644 --- a/include/llvm/Config/llvm-config.h.cmake +++ b/include/llvm/Config/llvm-config.h.cmake @@ -80,6 +80,6 @@ /* Whether LLVM records statistics for use with GetStatistics(), * PrintStatistics() or PrintStatisticsJSON() */ -#cmakedefine01 LLVM_ENABLE_STATS +#cmakedefine01 LLVM_FORCE_ENABLE_STATS #endif -- 2.11.0