Skip to content

Commit a50b783

Browse files
committed
[cmake] Add LLVM_ENABLE_DIA_SDK option, and expose it in LLVMConfig
Add an explicit LLVM_ENABLE_DIA_SDK option to control building support for DIA SDK-based debugging. Control its value to match whether DIA SDK support was found and expose it in LLVMConfig (alike LLVM_ENABLE_ZLIB). Its value is needed for LLDB to determine whether to run tests requiring DIA support. Currently it is obtained from llvm/Config/config.h; however, this file is not available for standalone builds. Following this change, LLDB will be modified to use the value from LLVMConfig. Differential Revision: https://reviews.llvm.org/D26255 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290818 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 9af2e4e commit a50b783

File tree

7 files changed

+20
-7
lines changed

7 files changed

+20
-7
lines changed

cmake/config-ix.cmake

+8-1
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,15 @@ if( MSVC )
450450
else()
451451
set(HAVE_DIA_SDK 0)
452452
endif()
453+
454+
option(LLVM_ENABLE_DIA_SDK "Use MSVC DIA SDK for debugging if available."
455+
${HAVE_DIA_SDK})
456+
457+
if(LLVM_ENABLE_DIA_SDK AND NOT HAVE_DIA_SDK)
458+
message(FATAL_ERROR "DIA SDK not found. If you have both VS 2012 and 2013 installed, you may need to uninstall the former and re-install the latter afterwards.")
459+
endif()
453460
else()
454-
set(HAVE_DIA_SDK 0)
461+
set(LLVM_ENABLE_DIA_SDK 0)
455462
endif( MSVC )
456463

457464
# FIXME: Signal handler return type, currently hardcoded to 'void'

cmake/modules/LLVMConfig.cmake.in

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ set(LLVM_ENABLE_THREADS @LLVM_ENABLE_THREADS@)
3737

3838
set(LLVM_ENABLE_ZLIB @LLVM_ENABLE_ZLIB@)
3939

40+
set(LLVM_ENABLE_DIA_SDK @LLVM_ENABLE_DIA_SDK@)
41+
4042
set(LLVM_NATIVE_ARCH @LLVM_NATIVE_ARCH@)
4143

4244
set(LLVM_ENABLE_PIC @LLVM_ENABLE_PIC@)

docs/CMake.rst

+4
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ LLVM-specific variables
368368
Enable building with zlib to support compression/uncompression in LLVM tools.
369369
Defaults to ON.
370370

371+
**LLVM_ENABLE_DIA_SDK**:BOOL
372+
Enable building with MSVC DIA SDK for PDB debugging support. Available
373+
only with MSVC. Defaults to ON.
374+
371375
**LLVM_USE_SANITIZER**:STRING
372376
Define the sanitizer used to build LLVM binaries and tests. Possible values
373377
are ``Address``, ``Memory``, ``MemoryWithOrigins``, ``Undefined``, ``Thread``,

include/llvm/Config/config.h.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#cmakedefine01 HAVE_DECL_STRERROR_S
4040

4141
/* Define to 1 if you have the DIA SDK installed, and to 0 if you don't. */
42-
#cmakedefine01 HAVE_DIA_SDK
42+
#cmakedefine01 LLVM_ENABLE_DIA_SDK
4343

4444
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
4545
*/

lib/DebugInfo/PDB/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ macro(add_pdb_impl_folder group)
33
source_group(${group} FILES ${ARGN})
44
endmacro()
55

6-
if(HAVE_DIA_SDK)
6+
if(LLVM_ENABLE_DIA_SDK)
77
include_directories(${MSVC_DIA_SDK_DIR}/include)
88
set(LIBPDB_LINK_FOLDERS "${MSVC_DIA_SDK_DIR}\\lib")
99
if (CMAKE_SIZEOF_VOID_P EQUAL 8)

lib/DebugInfo/PDB/PDB.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "llvm/DebugInfo/PDB/GenericError.h"
1515
#include "llvm/DebugInfo/PDB/IPDBSession.h"
1616
#include "llvm/DebugInfo/PDB/PDB.h"
17-
#if HAVE_DIA_SDK
17+
#if LLVM_ENABLE_DIA_SDK
1818
#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
1919
#endif
2020
#include "llvm/DebugInfo/PDB/Raw/RawSession.h"
@@ -30,7 +30,7 @@ Error llvm::pdb::loadDataForPDB(PDB_ReaderType Type, StringRef Path,
3030
if (Type == PDB_ReaderType::Raw)
3131
return RawSession::createFromPdb(Path, Session);
3232

33-
#if HAVE_DIA_SDK
33+
#if LLVM_ENABLE_DIA_SDK
3434
return DIASession::createFromPdb(Path, Session);
3535
#else
3636
return llvm::make_error<GenericError>("DIA is not installed on the system");
@@ -43,7 +43,7 @@ Error llvm::pdb::loadDataForEXE(PDB_ReaderType Type, StringRef Path,
4343
if (Type == PDB_ReaderType::Raw)
4444
return RawSession::createFromExe(Path, Session);
4545

46-
#if HAVE_DIA_SDK
46+
#if LLVM_ENABLE_DIA_SDK
4747
return DIASession::createFromExe(Path, Session);
4848
#else
4949
return llvm::make_error<GenericError>("DIA is not installed on the system");

test/lit.site.cfg.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ config.llvm_use_intel_jitevents = "@LLVM_USE_INTEL_JITEVENTS@"
3636
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
3737
config.have_zlib = "@HAVE_LIBZ@"
3838
config.have_libxar = "@HAVE_LIBXAR@"
39-
config.have_dia_sdk = @HAVE_DIA_SDK@
39+
config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
4040
config.enable_ffi = "@LLVM_ENABLE_FFI@"
4141
config.test_examples = "@ENABLE_EXAMPLES@"
4242

0 commit comments

Comments
 (0)