Skip to content

Commit b97ff92

Browse files
committed
Don't make PDBs by default in Release mode
Introduce the LLVM_ENABLE_PDB option so that users can request them explicitly instead. Add /OPT:REF and /OPT:ICF back, which /DEBUG disables by default. Differential Revision: https://reviews.llvm.org/D43156 llvm-svn: 325296
1 parent de9ad4b commit b97ff92

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,18 @@ if( MSVC )
353353

354354
append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
355355

356-
# Generate PDB even in release for profiling.
357-
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
356+
# Allow users to request PDBs in release mode. CMake offeres the
357+
# RelWithDebInfo configuration, but it uses different optimization settings
358+
# (/Ob1 vs /Ob2 or -O2 vs -O3). LLVM provides this flag so that users can get
359+
# PDBs without changing codegen.
360+
option(LLVM_ENABLE_PDB OFF)
361+
if (LLVM_ENABLE_PDB AND uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
358362
append("/Zi" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
359-
append("/DEBUG" CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
360-
endif (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
363+
# /DEBUG disables linker GC and ICF, but we want those in Release mode.
364+
append("/DEBUG /OPT:REF /OPT:ICF"
365+
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS
366+
CMAKE_SHARED_LINKER_FLAGS)
367+
endif()
361368

362369
# /Zc:strictStrings is incompatible with VS12's (Visual Studio 2013's)
363370
# debug mode headers. Instead of only enabling them in VS2013's debug mode,

0 commit comments

Comments
 (0)