[cmake] Add a big warning about a libstdc++ issue
Summary:
Recent increase in the usage of std::weak_ptr has caused us to rediscover an issue in libstdc++
versions prior to 4.9 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59656>, which make this class
unusable without exceptions in the presence of multiple threads. It's virtualy impossible to work
around this issue without implementing our own shared_ptr/weak_ptr substitutes, which does not
seem like a good idea.
Therefore, I am adding a big CMake warning which warns you about this issue if you're attempting
a to do a build which is suceptible to this problem and suggests possible alternatives. Right
now, nothing spectacular will happen if you ignore this warning (all the crashes I have seen
occur during process shutdown), but there's no guarantee the situation will not change in the
future.
Reviewers: tberghammer, tfiala, nitesh.jain, omjavaid, emaste, krytarowski
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D20671
llvm-svn: 270854
2016-05-26 23:16:11 +08:00
|
|
|
include(CheckCXXSymbolExists)
|
2019-03-01 00:04:54 +08:00
|
|
|
include(CheckTypeSize)
|
[lldb][ELF] Read symbols from .gnu_debugdata sect.
Summary:
If the .symtab section is stripped from the binary it might be that
there's a .gnu_debugdata section which contains a smaller .symtab in
order to provide enough information to create a backtrace with function
names or to set and hit a breakpoint on a function name.
This change looks for a .gnu_debugdata section in the ELF object file.
The .gnu_debugdata section contains a xz-compressed ELF file with a
.symtab section inside. Symbols from that compressed .symtab section
are merged with the main object file's .dynsym symbols (if any).
In addition we always load the .dynsym even if there's a .symtab
section.
For example, the Fedora and RHEL operating systems strip their binaries
but keep a .gnu_debugdata section. While gdb already can read this
section, LLDB until this patch couldn't. To test this patch on a
Fedora or RHEL operating system, try to set a breakpoint on the "help"
symbol in the "zip" binary. Before this patch, only GDB can set this
breakpoint; now LLDB also can do so without installing extra debug
symbols:
lldb /usr/bin/zip -b -o "b help" -o "r" -o "bt" -- -h
The above line runs LLDB in batch mode and on the "/usr/bin/zip -h"
target:
(lldb) target create "/usr/bin/zip"
Current executable set to '/usr/bin/zip' (x86_64).
(lldb) settings set -- target.run-args "-h"
Before the program starts, we set a breakpoint on the "help" symbol:
(lldb) b help
Breakpoint 1: where = zip`help, address = 0x00000000004093b0
Once the program is run and has hit the breakpoint we ask for a
backtrace:
(lldb) r
Process 10073 stopped
* thread #1, name = 'zip', stop reason = breakpoint 1.1
frame #0: 0x00000000004093b0 zip`help
zip`help:
-> 0x4093b0 <+0>: pushq %r12
0x4093b2 <+2>: movq 0x2af5f(%rip), %rsi ; + 4056
0x4093b9 <+9>: movl $0x1, %edi
0x4093be <+14>: xorl %eax, %eax
Process 10073 launched: '/usr/bin/zip' (x86_64)
(lldb) bt
* thread #1, name = 'zip', stop reason = breakpoint 1.1
* frame #0: 0x00000000004093b0 zip`help
frame #1: 0x0000000000403970 zip`main + 3248
frame #2: 0x00007ffff7d8bf33 libc.so.6`__libc_start_main + 243
frame #3: 0x0000000000408cee zip`_start + 46
In order to support the .gnu_debugdata section, one has to have LZMA
development headers installed. The CMake section, that controls this
part looks for the LZMA headers and enables .gnu_debugdata support by
default if they are found; otherwise or if explicitly requested, the
minidebuginfo support is disabled.
GDB supports the "mini debuginfo" section .gnu_debugdata since v7.6
(2013).
Reviewers: espindola, labath, jankratochvil, alexshap
Reviewed By: labath
Subscribers: rnkovacs, wuzish, shafik, emaste, mgorny, arichardson, hiraditya, MaskRay, lldb-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D66791
llvm-svn: 373891
2019-10-07 18:32:16 +08:00
|
|
|
include(CMakeDependentOption)
|
[cmake] Add a big warning about a libstdc++ issue
Summary:
Recent increase in the usage of std::weak_ptr has caused us to rediscover an issue in libstdc++
versions prior to 4.9 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59656>, which make this class
unusable without exceptions in the presence of multiple threads. It's virtualy impossible to work
around this issue without implementing our own shared_ptr/weak_ptr substitutes, which does not
seem like a good idea.
Therefore, I am adding a big CMake warning which warns you about this issue if you're attempting
a to do a build which is suceptible to this problem and suggests possible alternatives. Right
now, nothing spectacular will happen if you ignore this warning (all the crashes I have seen
occur during process shutdown), but there's no guarantee the situation will not change in the
future.
Reviewers: tberghammer, tfiala, nitesh.jain, omjavaid, emaste, krytarowski
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D20671
llvm-svn: 270854
2016-05-26 23:16:11 +08:00
|
|
|
|
2015-05-14 03:45:06 +08:00
|
|
|
set(LLDB_PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(LLDB_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/source")
|
|
|
|
set(LLDB_INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
|
|
|
|
[CMake] Revised LLDB.framework builds
Summary:
Add features to LLDB CMake builds that have so far only been available in Xcode. Clean up a few inconveniences and prepare further improvements.
Options:
* `LLDB_FRAMEWORK_BUILD_DIR` determines target directory (in build-tree)
* `LLDB_FRAMEWORK_INSTALL_DIR` **only** determines target directory in install-tree
* `LLVM_EXTERNALIZE_DEBUGINFO` allows externalized debug info (dSYM on Darwin, emitted to `bin`)
* `LLDB_FRAMEWORK_TOOLS` determines which executables will be copied to the framework's Resources (dropped symlinking, removed INCLUDE_IN_SUITE, removed dummy targets)
Other changes:
* clean up `add_lldb_executable()`
* include `LLDBFramework.cmake` from `source/API/CMakeLists.txt`
* use `*.plist.in` files, which are typical for CMake and independent from Xcode
* add clang headers to the framework bundle
Reviewers: xiaobai, JDevlieghere, aprantl, davide, beanz, stella.stamenova, clayborg, labath
Reviewed By: aprantl
Subscribers: friss, mgorny, lldb-commits, #lldb
Differential Revision: https://reviews.llvm.org/D55328
llvm-svn: 350391
2019-01-04 20:46:50 +08:00
|
|
|
set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
|
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"In-source builds are not allowed. CMake would overwrite the makefiles "
|
|
|
|
"distributed with LLDB. Please create a directory and run cmake from "
|
|
|
|
"there, passing the path to this source directory as the last argument. "
|
|
|
|
"This process created the file `CMakeCache.txt' and the directory "
|
|
|
|
"`CMakeFiles'. Please delete them.")
|
|
|
|
endif()
|
|
|
|
|
2019-12-14 02:37:33 +08:00
|
|
|
set(default_enable_python ON)
|
2019-12-08 07:49:35 +08:00
|
|
|
set(default_enable_lua OFF) # Experimental
|
2019-12-13 01:22:34 +08:00
|
|
|
set(default_enable_libedit ON)
|
2019-12-13 01:13:04 +08:00
|
|
|
set(default_enable_curses ON)
|
2017-07-19 05:15:53 +08:00
|
|
|
|
2019-12-20 23:50:06 +08:00
|
|
|
# Temporarily support the old LLDB_DISABLE_* variables
|
2019-12-14 02:37:33 +08:00
|
|
|
if (DEFINED LLDB_DISABLE_PYTHON)
|
|
|
|
if (LLDB_DISABLE_PYTHON)
|
|
|
|
set(default_enable_python OFF)
|
2019-12-13 17:20:35 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-01-04 20:46:34 +08:00
|
|
|
if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT)
|
|
|
|
set(default_disable_libedit ON)
|
2017-07-19 05:15:53 +08:00
|
|
|
endif()
|
|
|
|
|
2019-01-04 20:46:34 +08:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
2019-12-13 01:22:34 +08:00
|
|
|
set(default_enable_libedit OFF)
|
2019-12-13 01:13:04 +08:00
|
|
|
set(default_enable_curses OFF)
|
2019-01-04 20:46:34 +08:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
|
2019-12-14 02:37:33 +08:00
|
|
|
set(default_enable_python OFF)
|
2019-12-08 07:49:35 +08:00
|
|
|
set(default_enable_lua OFF)
|
2019-12-13 01:22:34 +08:00
|
|
|
set(default_enable_libedit OFF)
|
2019-12-13 01:13:04 +08:00
|
|
|
set(default_enable_curses OFF)
|
2019-01-04 20:46:34 +08:00
|
|
|
elseif(IOS)
|
2019-12-14 02:37:33 +08:00
|
|
|
set(default_enable_python OFF)
|
2019-12-08 07:49:35 +08:00
|
|
|
set(default_enable_lua OFF)
|
2019-01-04 20:46:34 +08:00
|
|
|
endif()
|
2015-05-14 03:45:06 +08:00
|
|
|
|
2019-12-14 02:37:33 +08:00
|
|
|
option(LLDB_ENABLE_PYTHON "Enable Python scripting integration." ${default_enable_python})
|
2019-12-08 07:49:35 +08:00
|
|
|
option(LLDB_ENABLE_PYTHON "Enable Lua scripting integration." ${default_enable_lua})
|
2019-12-13 17:20:35 +08:00
|
|
|
option(LLDB_ENABLE_LIBEDIT "Enable the use of editline." ${default_enable_libedit})
|
|
|
|
option(LLDB_ENABLE_CURSES "Enable Curses integration." ${default_enable_curses})
|
2019-01-04 20:46:34 +08:00
|
|
|
option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to locate Python." OFF)
|
|
|
|
option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF)
|
|
|
|
option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
|
|
|
|
option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
|
[CMake] Revised RPATH handling
Summary:
If we build LLDB.framework, dependant tools need appropriate RPATHs in both locations, the build-tree (for testing) and the install-tree (for deployment). Luckily, CMake can handle it for us: https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling.
* In the build-tree, tools use the absolute path to the framework's actual output location.
* In the install-tree, tools get a list of RPATHs to look for the framework when deployed.
`LLDB_FRAMEWORK_INSTALL_DIR` is added to the `CMAKE_INSTALL_PREFIX` to change the relative location of LLDB.framework in the install-tree.
If it is not empty, it will be added as an additional RPATH to all dependant tools (so they are functional in the install-tree).
If it is empty, LLDB.framework goes to the root and tools will not be functional in the directory structure of the LLVM install-tree.
For historical reasons `LLDB_FRAMEWORK_INSTALL_DIR` defaults to "Library/Frameworks".
Reviewers: xiaobai, JDevlieghere, aprantl, clayborg
Reviewed By: JDevlieghere
Subscribers: ki.stfu, mgorny, lldb-commits, #lldb
Differential Revision: https://reviews.llvm.org/D55330
llvm-svn: 350392
2019-01-04 20:46:57 +08:00
|
|
|
option(LLDB_NO_INSTALL_DEFAULT_RPATH "Disable default RPATH settings in binaries" OFF)
|
2019-07-18 21:30:37 +08:00
|
|
|
option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver for testing (Darwin only)." OFF)
|
2019-11-05 09:00:23 +08:00
|
|
|
option(LLDB_SKIP_STRIP "Whether to skip stripping of binaries when installing lldb." OFF)
|
2015-05-14 03:45:06 +08:00
|
|
|
|
2019-11-13 04:57:00 +08:00
|
|
|
if (LLDB_USE_SYSTEM_DEBUGSERVER)
|
|
|
|
# The custom target for the system debugserver has no install target, so we
|
|
|
|
# need to remove it from the LLVM_DISTRIBUTION_COMPONENTS list.
|
|
|
|
if (LLVM_DISTRIBUTION_COMPONENTS)
|
|
|
|
list(REMOVE_ITEM LLVM_DISTRIBUTION_COMPONENTS debugserver)
|
|
|
|
set(LLVM_DISTRIBUTION_COMPONENTS ${LLVM_DISTRIBUTION_COMPONENTS} CACHE STRING "" FORCE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-01-04 20:46:34 +08:00
|
|
|
if(LLDB_BUILD_FRAMEWORK)
|
|
|
|
if(NOT APPLE)
|
|
|
|
message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms")
|
|
|
|
endif()
|
|
|
|
# CMake 3.6 did not correctly emit POST_BUILD commands for Apple Framework targets
|
2019-02-15 01:34:39 +08:00
|
|
|
# CMake < 3.8 did not have the BUILD_RPATH target property
|
|
|
|
if(CMAKE_VERSION VERSION_LESS 3.8)
|
|
|
|
message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.8")
|
2019-01-04 20:46:34 +08:00
|
|
|
endif()
|
[CMake] Revised LLDB.framework builds
Summary:
Add features to LLDB CMake builds that have so far only been available in Xcode. Clean up a few inconveniences and prepare further improvements.
Options:
* `LLDB_FRAMEWORK_BUILD_DIR` determines target directory (in build-tree)
* `LLDB_FRAMEWORK_INSTALL_DIR` **only** determines target directory in install-tree
* `LLVM_EXTERNALIZE_DEBUGINFO` allows externalized debug info (dSYM on Darwin, emitted to `bin`)
* `LLDB_FRAMEWORK_TOOLS` determines which executables will be copied to the framework's Resources (dropped symlinking, removed INCLUDE_IN_SUITE, removed dummy targets)
Other changes:
* clean up `add_lldb_executable()`
* include `LLDBFramework.cmake` from `source/API/CMakeLists.txt`
* use `*.plist.in` files, which are typical for CMake and independent from Xcode
* add clang headers to the framework bundle
Reviewers: xiaobai, JDevlieghere, aprantl, davide, beanz, stella.stamenova, clayborg, labath
Reviewed By: aprantl
Subscribers: friss, mgorny, lldb-commits, #lldb
Differential Revision: https://reviews.llvm.org/D55328
llvm-svn: 350391
2019-01-04 20:46:50 +08:00
|
|
|
|
|
|
|
set(LLDB_FRAMEWORK_VERSION A CACHE STRING "LLDB.framework version (default is A)")
|
|
|
|
set(LLDB_FRAMEWORK_BUILD_DIR bin CACHE STRING "Output directory for LLDB.framework")
|
|
|
|
set(LLDB_FRAMEWORK_INSTALL_DIR Library/Frameworks CACHE STRING "Install directory for LLDB.framework")
|
|
|
|
|
2019-10-31 01:33:05 +08:00
|
|
|
get_filename_component(LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR ${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE
|
|
|
|
BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR})
|
|
|
|
|
[CMake] `install-distribution` for LLDB on Darwin
Summary:
There's a number of requirements for installing LLDB on macOS that are untypical for LLVM projects: use special install-prefix for LLDB.framework, ship headers and tools as framework resources, patch RPATHs, externalize debug-info to dSYM's and strip binaries with `-ST`. For some of it we could use `llvm_externalize_debuginfo()` in the past and just add special cases. However, this complicates the code for all projects and comes with the major drawback, that it adds all these actions at build-time, i.e. dSYM creation and stripping take a lot of time and don't make sense at build-time.
LLVM's distribution mechanism (https://llvm.org/docs/BuildingADistribution.html) appears to be the natural candidate to install LLDB. Based on D64399 (enable in standalone builds), this patch integrates framework installation with the distribution mechanism and adds custom stripping flags and dSYM creation at install-time. Unlike the abandoned D61952, it leaves build-tree binaries untouched, so there's no side-effects on testing. Potential install-order issues must be handled externally.
Please let me know what you think, while I run a few more tests and add remarks+documentation.
Reviewers: xiaobai, compnerd, JDevlieghere, davide, labath, mgorny
Reviewed By: xiaobai, JDevlieghere
Subscribers: lldb-commits, #lldb
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D64408
llvm-svn: 365617
2019-07-10 19:09:29 +08:00
|
|
|
# Essentially, emit the framework's dSYM outside of the framework directory.
|
|
|
|
set(LLDB_DEBUGINFO_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin CACHE STRING
|
|
|
|
"Directory to emit dSYM files stripped from executables and libraries (Darwin Only)")
|
2019-01-04 20:46:34 +08:00
|
|
|
endif()
|
2017-02-04 08:20:24 +08:00
|
|
|
|
2019-08-07 01:21:34 +08:00
|
|
|
if(APPLE AND CMAKE_GENERATOR STREQUAL Xcode)
|
|
|
|
if(NOT LLDB_EXPLICIT_XCODE_CACHE_USED)
|
|
|
|
message(WARNING
|
|
|
|
"When building with Xcode, we recommend using the corresponding cache script. "
|
2019-08-07 18:03:11 +08:00
|
|
|
"If this was a mistake, clean your build directory and re-run CMake with:\n"
|
2019-08-07 01:21:34 +08:00
|
|
|
" -C ${CMAKE_SOURCE_DIR}/cmake/caches/Apple-lldb-Xcode.cmake\n"
|
|
|
|
"See: https://lldb.llvm.org/resources/build.html#cmakegeneratedxcodeproject\n")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-10-14 22:52:15 +08:00
|
|
|
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
|
|
set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
|
|
|
|
"Causes lldb to export all symbols when building liblldb.")
|
|
|
|
else()
|
|
|
|
# Windows doesn't support toggling this, so don't bother making it a
|
|
|
|
# cache variable.
|
|
|
|
set(LLDB_EXPORT_ALL_SYMBOLS 0)
|
|
|
|
endif()
|
|
|
|
|
2015-05-14 03:45:06 +08:00
|
|
|
if ((NOT MSVC) OR MSVC12)
|
|
|
|
add_definitions( -DHAVE_ROUND )
|
|
|
|
endif()
|
|
|
|
|
2019-12-08 09:35:31 +08:00
|
|
|
if (LLDB_ENABLE_LUA)
|
|
|
|
find_package(Lua REQUIRED)
|
|
|
|
endif()
|
2015-05-14 03:45:06 +08:00
|
|
|
|
2019-12-13 01:22:34 +08:00
|
|
|
if (LLDB_ENABLE_LIBEDIT)
|
2019-03-01 00:04:54 +08:00
|
|
|
find_package(LibEdit REQUIRED)
|
|
|
|
|
|
|
|
# Check if we libedit capable of handling wide characters (built with
|
|
|
|
# '--enable-widec').
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${libedit_LIBRARIES})
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${libedit_INCLUDE_DIRS})
|
|
|
|
check_symbol_exists(el_winsertstr histedit.h LLDB_EDITLINE_USE_WCHAR)
|
|
|
|
set(CMAKE_EXTRA_INCLUDE_FILES histedit.h)
|
|
|
|
check_type_size(el_rfunc_t LLDB_EL_RFUNC_T_SIZE)
|
|
|
|
if (LLDB_EL_RFUNC_T_SIZE STREQUAL "")
|
|
|
|
set(LLDB_HAVE_EL_RFUNC_T 0)
|
|
|
|
else()
|
|
|
|
set(LLDB_HAVE_EL_RFUNC_T 1)
|
|
|
|
endif()
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES)
|
|
|
|
set(CMAKE_EXTRA_INCLUDE_FILES)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2015-10-07 05:11:15 +08:00
|
|
|
# On Windows, we can't use the normal FindPythonLibs module that comes with CMake,
|
|
|
|
# for a number of reasons.
|
|
|
|
# 1) Prior to MSVC 2015, it is only possible to embed Python if python itself was
|
|
|
|
# compiled with an identical version (and build configuration) of MSVC as LLDB.
|
|
|
|
# The standard algorithm does not take into account the differences between
|
|
|
|
# a binary release distribution of python and a custom built distribution.
|
|
|
|
# 2) From MSVC 2015 and onwards, it is only possible to use Python 3.5 or later.
|
|
|
|
# 3) FindPythonLibs queries the registry to locate Python, and when looking for a
|
|
|
|
# 64-bit version of Python, since cmake.exe is a 32-bit executable, it will see
|
|
|
|
# a 32-bit view of the registry. As such, it is impossible for FindPythonLibs to
|
|
|
|
# locate 64-bit Python libraries.
|
|
|
|
# This function is designed to address those limitations. Currently it only partially
|
|
|
|
# addresses them, but it can be improved and extended on an as-needed basis.
|
2019-09-06 01:22:30 +08:00
|
|
|
function(find_python_libs_windows_helper LOOKUP_DEBUG OUT_EXE_PATH_VARNAME OUT_LIB_PATH_VARNAME OUT_DLL_PATH_VARNAME OUT_VERSION_VARNAME)
|
|
|
|
if(LOOKUP_DEBUG)
|
|
|
|
set(POSTFIX "_d")
|
|
|
|
else()
|
|
|
|
set(POSTFIX "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
file(TO_CMAKE_PATH "${PYTHON_HOME}/python${POSTFIX}.exe" PYTHON_EXE)
|
|
|
|
file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/${PYTHONLIBS_BASE_NAME}${POSTFIX}.lib" PYTHON_LIB)
|
|
|
|
file(TO_CMAKE_PATH "${PYTHON_HOME}/${PYTHONLIBS_BASE_NAME}${POSTFIX}.dll" PYTHON_DLL)
|
|
|
|
|
|
|
|
foreach(component PYTHON_EXE;PYTHON_LIB;PYTHON_DLL)
|
|
|
|
if(NOT EXISTS ${${component}})
|
|
|
|
message(WARNING "Unable to find ${component}")
|
|
|
|
unset(${component})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if (NOT PYTHON_EXE OR NOT PYTHON_LIB OR NOT PYTHON_DLL)
|
|
|
|
message(WARNING "Unable to find all Python components. Python support will be disabled for this build.")
|
2019-12-14 02:37:33 +08:00
|
|
|
set(LLDB_ENABLE_PYTHON 0 PARENT_SCOPE)
|
2019-09-06 01:22:30 +08:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Find the version of the Python interpreter.
|
|
|
|
execute_process(COMMAND "${PYTHON_EXE}" -c
|
|
|
|
"import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))"
|
|
|
|
OUTPUT_VARIABLE PYTHON_VERSION_OUTPUT
|
|
|
|
RESULT_VARIABLE PYTHON_VERSION_RESULT
|
|
|
|
ERROR_QUIET)
|
|
|
|
|
|
|
|
if(PYTHON_VERSION_RESULT)
|
|
|
|
message(WARNING "Unable to retrieve Python executable version")
|
|
|
|
set(PYTHON_VERSION_OUTPUT "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(${OUT_EXE_PATH_VARNAME} ${PYTHON_EXE} PARENT_SCOPE)
|
|
|
|
set(${OUT_LIB_PATH_VARNAME} ${PYTHON_LIB} PARENT_SCOPE)
|
|
|
|
set(${OUT_DLL_PATH_VARNAME} ${PYTHON_DLL} PARENT_SCOPE)
|
|
|
|
set(${OUT_VERSION_VARNAME} ${PYTHON_VERSION_OUTPUT} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2015-10-07 05:11:15 +08:00
|
|
|
function(find_python_libs_windows)
|
|
|
|
if ("${PYTHON_HOME}" STREQUAL "")
|
Specify log level for CMake messages (less stderr)
Summary:
Specify message levels in CMake. Prefer STATUS (stdout).
As the default message mode (i.e. level) is NOTICE in CMake, more then necessary messages get printed to stderr. Some tools, noticably ccmake treat this as an error and require additional confirmation and re-running CMake's configuration step.
This commit specifies a mode (either STATUS or WARNING or FATAL_ERROR) instead of the default.
* I used `csearch -f 'llvm-project/.+(CMakeLists\.txt|cmake)' -l 'message\("'` to find all locations.
* Reviewers were chosen by the most common authors of specific files. If there are more suitable reviewers for these CMake changes, please let me know.
Patch by: Christoph Siedentop
Reviewers: zturner, beanz, xiaobai, kbobyrev, lebedev.ri, sgraenitz
Reviewed By: sgraenitz
Subscribers: mgorny, lebedev.ri, #sanitizers, lldb-commits, llvm-commits
Tags: #sanitizers, #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D63370
llvm-svn: 363821
2019-06-19 23:25:32 +08:00
|
|
|
message(WARNING "LLDB embedded Python on Windows requires specifying a value for PYTHON_HOME. Python support disabled.")
|
2019-12-14 02:37:33 +08:00
|
|
|
set(LLDB_ENABLE_PYTHON 0 PARENT_SCOPE)
|
2015-10-07 05:11:15 +08:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2019-03-30 01:35:42 +08:00
|
|
|
file(TO_CMAKE_PATH "${PYTHON_HOME}/Include" PYTHON_INCLUDE_DIR)
|
2015-10-07 05:11:15 +08:00
|
|
|
|
2019-03-30 01:35:42 +08:00
|
|
|
if(EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h")
|
|
|
|
file(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" python_version_str
|
2015-10-07 05:11:15 +08:00
|
|
|
REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"")
|
2015-12-17 22:13:39 +08:00
|
|
|
string(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"+]+)[+]?\".*" "\\1"
|
|
|
|
PYTHONLIBS_VERSION_STRING "${python_version_str}")
|
2019-07-18 06:36:26 +08:00
|
|
|
message(STATUS "Found Python library version ${PYTHONLIBS_VERSION_STRING}")
|
2015-10-07 05:11:15 +08:00
|
|
|
string(REGEX REPLACE "([0-9]+)[.]([0-9]+)[.][0-9]+" "python\\1\\2" PYTHONLIBS_BASE_NAME "${PYTHONLIBS_VERSION_STRING}")
|
|
|
|
unset(python_version_str)
|
|
|
|
else()
|
Specify log level for CMake messages (less stderr)
Summary:
Specify message levels in CMake. Prefer STATUS (stdout).
As the default message mode (i.e. level) is NOTICE in CMake, more then necessary messages get printed to stderr. Some tools, noticably ccmake treat this as an error and require additional confirmation and re-running CMake's configuration step.
This commit specifies a mode (either STATUS or WARNING or FATAL_ERROR) instead of the default.
* I used `csearch -f 'llvm-project/.+(CMakeLists\.txt|cmake)' -l 'message\("'` to find all locations.
* Reviewers were chosen by the most common authors of specific files. If there are more suitable reviewers for these CMake changes, please let me know.
Patch by: Christoph Siedentop
Reviewers: zturner, beanz, xiaobai, kbobyrev, lebedev.ri, sgraenitz
Reviewed By: sgraenitz
Subscribers: mgorny, lebedev.ri, #sanitizers, lldb-commits, llvm-commits
Tags: #sanitizers, #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D63370
llvm-svn: 363821
2019-06-19 23:25:32 +08:00
|
|
|
message(WARNING "Unable to find ${PYTHON_INCLUDE_DIR}/patchlevel.h, Python installation is corrupt.")
|
|
|
|
message(WARNING "Python support will be disabled for this build.")
|
2019-12-14 02:37:33 +08:00
|
|
|
set(LLDB_ENABLE_PYTHON 0 PARENT_SCOPE)
|
2015-10-07 05:11:15 +08:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
file(TO_CMAKE_PATH "${PYTHON_HOME}" PYTHON_HOME)
|
2019-05-29 10:26:29 +08:00
|
|
|
# TODO(compnerd) when CMake Policy `CMP0091` is set to NEW, we should use
|
|
|
|
# if(CMAKE_MSVC_RUNTIME_LIBRARY MATCHES MultiThreadedDebug)
|
2019-09-06 01:22:30 +08:00
|
|
|
if(NOT DEFINED CMAKE_BUILD_TYPE)
|
|
|
|
# Multi-target generator was selected (like Visual Studio or Xcode) where no concrete build type was passed
|
|
|
|
# Lookup for both debug and release python installations
|
|
|
|
find_python_libs_windows_helper(TRUE PYTHON_DEBUG_EXE PYTHON_DEBUG_LIB PYTHON_DEBUG_DLL PYTHON_DEBUG_VERSION_STRING)
|
|
|
|
find_python_libs_windows_helper(FALSE PYTHON_RELEASE_EXE PYTHON_RELEASE_LIB PYTHON_RELEASE_DLL PYTHON_RELEASE_VERSION_STRING)
|
2019-12-14 02:37:33 +08:00
|
|
|
if(NOT LLDB_ENABLE_PYTHON)
|
|
|
|
set(LLDB_ENABLE_PYTHON 0 PARENT_SCOPE)
|
2019-09-06 01:22:30 +08:00
|
|
|
return()
|
2019-05-29 10:26:29 +08:00
|
|
|
endif()
|
2015-10-08 16:50:20 +08:00
|
|
|
|
2019-09-06 01:22:30 +08:00
|
|
|
# We should have been found both debug and release python here
|
|
|
|
# Now check that their versions are equal
|
|
|
|
if(NOT PYTHON_DEBUG_VERSION_STRING STREQUAL PYTHON_RELEASE_VERSION_STRING)
|
|
|
|
message(FATAL_ERROR "Python versions for debug (${PYTHON_DEBUG_VERSION_STRING}) and release (${PYTHON_RELEASE_VERSION_STRING}) are different."
|
|
|
|
"Python installation is corrupted")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
set(PYTHON_EXECUTABLE $<$<CONFIG:Debug>:${PYTHON_DEBUG_EXE}>$<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_EXE}>)
|
|
|
|
set(PYTHON_LIBRARY $<$<CONFIG:Debug>:${PYTHON_DEBUG_LIB}>$<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_LIB}>)
|
|
|
|
set(PYTHON_DLL $<$<CONFIG:Debug>:${PYTHON_DEBUG_DLL}>$<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_DLL}>)
|
|
|
|
set(PYTHON_VERSION_STRING ${PYTHON_RELEASE_VERSION_STRING})
|
|
|
|
else()
|
|
|
|
# Lookup for concrete python installation depending on build type
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL Debug)
|
|
|
|
set(LOOKUP_DEBUG_PYTHON TRUE)
|
|
|
|
else()
|
|
|
|
set(LOOKUP_DEBUG_PYTHON FALSE)
|
|
|
|
endif()
|
|
|
|
find_python_libs_windows_helper(${LOOKUP_DEBUG_PYTHON} PYTHON_EXECUTABLE PYTHON_LIBRARY PYTHON_DLL PYTHON_VERSION_STRING)
|
2019-12-14 02:37:33 +08:00
|
|
|
if(NOT LLDB_ENABLE_PYTHON)
|
|
|
|
set(LLDB_ENABLE_PYTHON 0 PARENT_SCOPE)
|
2019-09-06 01:22:30 +08:00
|
|
|
return()
|
|
|
|
endif()
|
2015-10-08 16:50:20 +08:00
|
|
|
endif()
|
|
|
|
|
2019-09-06 01:22:30 +08:00
|
|
|
if(PYTHON_VERSION_STRING)
|
|
|
|
string(REPLACE "." ";" PYTHON_VERSION_PARTS "${PYTHON_VERSION_STRING}")
|
|
|
|
list(GET PYTHON_VERSION_PARTS 0 PYTHON_VERSION_MAJOR)
|
|
|
|
list(GET PYTHON_VERSION_PARTS 1 PYTHON_VERSION_MINOR)
|
|
|
|
list(GET PYTHON_VERSION_PARTS 2 PYTHON_VERSION_PATCH)
|
|
|
|
else()
|
|
|
|
unset(PYTHON_VERSION_MAJOR)
|
|
|
|
unset(PYTHON_VERSION_MINOR)
|
|
|
|
unset(PYTHON_VERSION_PATCH)
|
2019-07-26 22:26:33 +08:00
|
|
|
endif()
|
2015-10-07 05:11:15 +08:00
|
|
|
|
2019-07-26 22:26:33 +08:00
|
|
|
# Set the same variables as FindPythonInterp and FindPythonLibs.
|
2019-09-18 09:00:12 +08:00
|
|
|
set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}" CACHE PATH "")
|
|
|
|
set(PYTHON_LIBRARY "${PYTHON_LIBRARY}" CACHE PATH "")
|
|
|
|
set(PYTHON_DLL "${PYTHON_DLL}" CACHE PATH "")
|
|
|
|
set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}" CACHE PATH "")
|
2019-09-06 01:22:30 +08:00
|
|
|
set(PYTHONLIBS_VERSION_STRING "${PYTHONLIBS_VERSION_STRING}" PARENT_SCOPE)
|
|
|
|
set(PYTHON_VERSION_STRING "${PYTHON_VERSION_STRING}" PARENT_SCOPE)
|
|
|
|
set(PYTHON_VERSION_MAJOR "${PYTHON_VERSION_MAJOR}" PARENT_SCOPE)
|
|
|
|
set(PYTHON_VERSION_MINOR "${PYTHON_VERSION_MINOR}" PARENT_SCOPE)
|
|
|
|
set(PYTHON_VERSION_PATCH "${PYTHON_VERSION_PATCH}" PARENT_SCOPE)
|
2019-07-26 22:26:33 +08:00
|
|
|
|
2019-07-27 00:15:19 +08:00
|
|
|
message(STATUS "LLDB Found PythonExecutable: ${PYTHON_EXECUTABLE} (${PYTHON_VERSION_STRING})")
|
2019-09-06 01:22:30 +08:00
|
|
|
message(STATUS "LLDB Found PythonLibs: ${PYTHON_LIBRARY} (${PYTHONLIBS_VERSION_STRING})")
|
Specify log level for CMake messages (less stderr)
Summary:
Specify message levels in CMake. Prefer STATUS (stdout).
As the default message mode (i.e. level) is NOTICE in CMake, more then necessary messages get printed to stderr. Some tools, noticably ccmake treat this as an error and require additional confirmation and re-running CMake's configuration step.
This commit specifies a mode (either STATUS or WARNING or FATAL_ERROR) instead of the default.
* I used `csearch -f 'llvm-project/.+(CMakeLists\.txt|cmake)' -l 'message\("'` to find all locations.
* Reviewers were chosen by the most common authors of specific files. If there are more suitable reviewers for these CMake changes, please let me know.
Patch by: Christoph Siedentop
Reviewers: zturner, beanz, xiaobai, kbobyrev, lebedev.ri, sgraenitz
Reviewed By: sgraenitz
Subscribers: mgorny, lebedev.ri, #sanitizers, lldb-commits, llvm-commits
Tags: #sanitizers, #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D63370
llvm-svn: 363821
2019-06-19 23:25:32 +08:00
|
|
|
message(STATUS "LLDB Found PythonDLL: ${PYTHON_DLL}")
|
|
|
|
message(STATUS "LLDB Found PythonIncludeDirs: ${PYTHON_INCLUDE_DIR}")
|
2015-10-07 05:11:15 +08:00
|
|
|
endfunction(find_python_libs_windows)
|
|
|
|
|
2019-10-09 02:38:46 +08:00
|
|
|
# Call find_python_libs_windows ahead of the rest of the python configuration.
|
|
|
|
# It's possible that it won't find a python installation and will then set
|
2019-12-14 02:37:33 +08:00
|
|
|
# LLDB_ENABLE_PYTHON to OFF.
|
|
|
|
if (LLDB_ENABLE_PYTHON AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
2019-10-09 02:38:46 +08:00
|
|
|
find_python_libs_windows()
|
|
|
|
endif()
|
|
|
|
|
2019-12-14 02:37:33 +08:00
|
|
|
if (LLDB_ENABLE_PYTHON)
|
2015-05-14 03:45:06 +08:00
|
|
|
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
2015-10-07 05:11:15 +08:00
|
|
|
if (NOT LLDB_RELOCATABLE_PYTHON)
|
2015-10-10 03:45:26 +08:00
|
|
|
file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
|
2015-05-14 03:45:06 +08:00
|
|
|
endif()
|
|
|
|
else()
|
2019-07-17 02:27:12 +08:00
|
|
|
find_package(PythonInterp REQUIRED)
|
|
|
|
find_package(PythonLibs REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2019-07-26 22:26:33 +08:00
|
|
|
if (NOT CMAKE_CROSSCOMPILING)
|
|
|
|
string(REPLACE "." ";" pythonlibs_version_list ${PYTHONLIBS_VERSION_STRING})
|
|
|
|
list(GET pythonlibs_version_list 0 pythonlibs_major)
|
|
|
|
list(GET pythonlibs_version_list 1 pythonlibs_minor)
|
|
|
|
|
|
|
|
# Ignore the patch version. Some versions of macOS report a different patch
|
|
|
|
# version for the system provided interpreter and libraries.
|
|
|
|
if (NOT PYTHON_VERSION_MAJOR VERSION_EQUAL pythonlibs_major OR
|
|
|
|
NOT PYTHON_VERSION_MINOR VERSION_EQUAL pythonlibs_minor)
|
2019-07-27 04:58:10 +08:00
|
|
|
message(FATAL_ERROR "Found incompatible Python interpreter (${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})"
|
2019-07-26 22:26:33 +08:00
|
|
|
" and Python libraries (${pythonlibs_major}.${pythonlibs_minor})")
|
|
|
|
endif()
|
2015-10-07 05:11:15 +08:00
|
|
|
endif()
|
2019-03-30 01:35:42 +08:00
|
|
|
|
|
|
|
if (PYTHON_INCLUDE_DIR)
|
|
|
|
include_directories(${PYTHON_INCLUDE_DIR})
|
2015-05-14 03:45:06 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-12-14 02:37:33 +08:00
|
|
|
if (NOT LLDB_ENABLE_PYTHON)
|
2019-03-30 01:35:42 +08:00
|
|
|
unset(PYTHON_INCLUDE_DIR)
|
2015-05-14 03:45:06 +08:00
|
|
|
unset(PYTHON_LIBRARY)
|
2019-03-30 01:35:42 +08:00
|
|
|
unset(PYTHON_EXECUTABLE)
|
2015-05-14 03:45:06 +08:00
|
|
|
endif()
|
|
|
|
|
2015-10-29 08:48:38 +08:00
|
|
|
if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)
|
|
|
|
include_directories(${LLVM_EXTERNAL_CLANG_SOURCE_DIR}/include)
|
|
|
|
else ()
|
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/tools/clang/include)
|
|
|
|
endif ()
|
2015-05-14 03:45:06 +08:00
|
|
|
include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include")
|
|
|
|
|
|
|
|
# Disable GCC warnings
|
|
|
|
check_cxx_compiler_flag("-Wno-deprecated-declarations"
|
|
|
|
CXX_SUPPORTS_NO_DEPRECATED_DECLARATIONS)
|
|
|
|
if (CXX_SUPPORTS_NO_DEPRECATED_DECLARATIONS)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
check_cxx_compiler_flag("-Wno-unknown-pragmas"
|
|
|
|
CXX_SUPPORTS_NO_UNKNOWN_PRAGMAS)
|
|
|
|
if (CXX_SUPPORTS_NO_UNKNOWN_PRAGMAS)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
|
|
|
|
endif ()
|
|
|
|
|
2015-10-23 18:34:53 +08:00
|
|
|
check_cxx_compiler_flag("-Wno-strict-aliasing"
|
|
|
|
CXX_SUPPORTS_NO_STRICT_ALIASING)
|
|
|
|
if (CXX_SUPPORTS_NO_STRICT_ALIASING)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing")
|
|
|
|
endif ()
|
|
|
|
|
2015-05-14 03:45:06 +08:00
|
|
|
# Disable Clang warnings
|
|
|
|
check_cxx_compiler_flag("-Wno-deprecated-register"
|
|
|
|
CXX_SUPPORTS_NO_DEPRECATED_REGISTER)
|
|
|
|
if (CXX_SUPPORTS_NO_DEPRECATED_REGISTER)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
|
|
|
|
endif ()
|
|
|
|
|
2015-09-02 07:43:51 +08:00
|
|
|
check_cxx_compiler_flag("-Wno-vla-extension"
|
|
|
|
CXX_SUPPORTS_NO_VLA_EXTENSION)
|
|
|
|
if (CXX_SUPPORTS_NO_VLA_EXTENSION)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-vla-extension")
|
|
|
|
endif ()
|
|
|
|
|
2015-05-14 03:45:06 +08:00
|
|
|
# Disable MSVC warnings
|
|
|
|
if( MSVC )
|
|
|
|
add_definitions(
|
|
|
|
-wd4018 # Suppress 'warning C4018: '>=' : signed/unsigned mismatch'
|
|
|
|
-wd4068 # Suppress 'warning C4068: unknown pragma'
|
|
|
|
-wd4150 # Suppress 'warning C4150: deletion of pointer to incomplete type'
|
2018-12-22 07:59:24 +08:00
|
|
|
-wd4201 # Suppress 'warning C4201: nonstandard extension used: nameless struct/union'
|
2015-05-14 03:45:06 +08:00
|
|
|
-wd4251 # Suppress 'warning C4251: T must have dll-interface to be used by clients of class U.'
|
|
|
|
-wd4521 # Suppress 'warning C4521: 'type' : multiple copy constructors specified'
|
|
|
|
-wd4530 # Suppress 'warning C4530: C++ exception handler used, but unwind semantics are not enabled.'
|
|
|
|
)
|
2015-07-17 23:26:27 +08:00
|
|
|
endif()
|
2015-05-14 03:45:06 +08:00
|
|
|
|
2016-03-23 01:58:09 +08:00
|
|
|
# Use the Unicode (UTF-16) APIs by default on Win32
|
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
2016-12-15 23:00:41 +08:00
|
|
|
add_definitions( -D_UNICODE -DUNICODE )
|
2016-03-23 01:58:09 +08:00
|
|
|
endif()
|
|
|
|
|
2018-11-13 00:22:28 +08:00
|
|
|
# If LLDB_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
|
|
|
|
if(NOT DEFINED LLDB_VERSION_MAJOR)
|
|
|
|
set(LLDB_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED LLDB_VERSION_MINOR)
|
|
|
|
set(LLDB_VERSION_MINOR ${LLVM_VERSION_MINOR})
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED LLDB_VERSION_PATCH)
|
|
|
|
set(LLDB_VERSION_PATCH ${LLVM_VERSION_PATCH})
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED LLDB_VERSION_SUFFIX)
|
|
|
|
set(LLDB_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
|
|
|
|
endif()
|
|
|
|
set(LLDB_VERSION "${LLDB_VERSION_MAJOR}.${LLDB_VERSION_MINOR}.${LLDB_VERSION_PATCH}${LLDB_VERSION_SUFFIX}")
|
2015-05-14 03:45:06 +08:00
|
|
|
message(STATUS "LLDB version: ${LLDB_VERSION}")
|
|
|
|
|
[lldb][ELF] Read symbols from .gnu_debugdata sect.
Summary:
If the .symtab section is stripped from the binary it might be that
there's a .gnu_debugdata section which contains a smaller .symtab in
order to provide enough information to create a backtrace with function
names or to set and hit a breakpoint on a function name.
This change looks for a .gnu_debugdata section in the ELF object file.
The .gnu_debugdata section contains a xz-compressed ELF file with a
.symtab section inside. Symbols from that compressed .symtab section
are merged with the main object file's .dynsym symbols (if any).
In addition we always load the .dynsym even if there's a .symtab
section.
For example, the Fedora and RHEL operating systems strip their binaries
but keep a .gnu_debugdata section. While gdb already can read this
section, LLDB until this patch couldn't. To test this patch on a
Fedora or RHEL operating system, try to set a breakpoint on the "help"
symbol in the "zip" binary. Before this patch, only GDB can set this
breakpoint; now LLDB also can do so without installing extra debug
symbols:
lldb /usr/bin/zip -b -o "b help" -o "r" -o "bt" -- -h
The above line runs LLDB in batch mode and on the "/usr/bin/zip -h"
target:
(lldb) target create "/usr/bin/zip"
Current executable set to '/usr/bin/zip' (x86_64).
(lldb) settings set -- target.run-args "-h"
Before the program starts, we set a breakpoint on the "help" symbol:
(lldb) b help
Breakpoint 1: where = zip`help, address = 0x00000000004093b0
Once the program is run and has hit the breakpoint we ask for a
backtrace:
(lldb) r
Process 10073 stopped
* thread #1, name = 'zip', stop reason = breakpoint 1.1
frame #0: 0x00000000004093b0 zip`help
zip`help:
-> 0x4093b0 <+0>: pushq %r12
0x4093b2 <+2>: movq 0x2af5f(%rip), %rsi ; + 4056
0x4093b9 <+9>: movl $0x1, %edi
0x4093be <+14>: xorl %eax, %eax
Process 10073 launched: '/usr/bin/zip' (x86_64)
(lldb) bt
* thread #1, name = 'zip', stop reason = breakpoint 1.1
* frame #0: 0x00000000004093b0 zip`help
frame #1: 0x0000000000403970 zip`main + 3248
frame #2: 0x00007ffff7d8bf33 libc.so.6`__libc_start_main + 243
frame #3: 0x0000000000408cee zip`_start + 46
In order to support the .gnu_debugdata section, one has to have LZMA
development headers installed. The CMake section, that controls this
part looks for the LZMA headers and enables .gnu_debugdata support by
default if they are found; otherwise or if explicitly requested, the
minidebuginfo support is disabled.
GDB supports the "mini debuginfo" section .gnu_debugdata since v7.6
(2013).
Reviewers: espindola, labath, jankratochvil, alexshap
Reviewed By: labath
Subscribers: rnkovacs, wuzish, shafik, emaste, mgorny, arichardson, hiraditya, MaskRay, lldb-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D66791
llvm-svn: 373891
2019-10-07 18:32:16 +08:00
|
|
|
find_package(LibLZMA)
|
|
|
|
cmake_dependent_option(LLDB_ENABLE_LZMA "Support LZMA compression" ON "LIBLZMA_FOUND" OFF)
|
|
|
|
if (LLDB_ENABLE_LZMA)
|
|
|
|
include_directories(${LIBLZMA_INCLUDE_DIRS})
|
|
|
|
endif()
|
|
|
|
llvm_canonicalize_cmake_booleans(LLDB_ENABLE_LZMA)
|
|
|
|
|
2015-05-14 03:45:06 +08:00
|
|
|
include_directories(BEFORE
|
2017-04-15 06:03:45 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/include
|
2019-08-08 16:27:25 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
2015-05-14 03:45:06 +08:00
|
|
|
)
|
|
|
|
|
2015-06-29 19:03:21 +08:00
|
|
|
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
|
|
install(DIRECTORY include/
|
2018-03-08 23:52:46 +08:00
|
|
|
COMPONENT lldb-headers
|
2015-06-29 19:03:21 +08:00
|
|
|
DESTINATION include
|
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN ".svn" EXCLUDE
|
2017-04-15 06:03:45 +08:00
|
|
|
PATTERN ".cmake" EXCLUDE
|
|
|
|
)
|
|
|
|
|
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
|
2018-03-08 23:52:46 +08:00
|
|
|
COMPONENT lldb-headers
|
2017-04-15 06:03:45 +08:00
|
|
|
DESTINATION include
|
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN ".svn" EXCLUDE
|
|
|
|
PATTERN ".cmake" EXCLUDE
|
2015-06-29 19:03:21 +08:00
|
|
|
)
|
2018-03-08 23:52:46 +08:00
|
|
|
|
|
|
|
add_custom_target(lldb-headers)
|
2019-05-28 17:29:05 +08:00
|
|
|
set_target_properties(lldb-headers PROPERTIES FOLDER "lldb misc")
|
2018-03-08 23:52:46 +08:00
|
|
|
|
|
|
|
if (NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
add_llvm_install_targets(install-lldb-headers
|
|
|
|
COMPONENT lldb-headers)
|
|
|
|
endif()
|
2015-06-29 19:03:21 +08:00
|
|
|
endif()
|
2015-04-16 23:51:33 +08:00
|
|
|
|
2018-12-19 04:51:00 +08:00
|
|
|
if (NOT LIBXML2_FOUND)
|
2015-04-16 23:51:33 +08:00
|
|
|
find_package(LibXml2)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Find libraries or frameworks that may be needed
|
2017-07-19 05:15:53 +08:00
|
|
|
if (APPLE)
|
|
|
|
if(NOT IOS)
|
|
|
|
find_library(CARBON_LIBRARY Carbon)
|
|
|
|
find_library(CORE_SERVICES_LIBRARY CoreServices)
|
|
|
|
endif()
|
2015-05-14 03:45:06 +08:00
|
|
|
find_library(FOUNDATION_LIBRARY Foundation)
|
|
|
|
find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
|
2015-04-16 23:51:33 +08:00
|
|
|
find_library(SECURITY_LIBRARY Security)
|
2019-12-12 06:10:38 +08:00
|
|
|
set(LLDB_ENABLE_LIBXML2 ON)
|
2017-07-19 05:15:53 +08:00
|
|
|
list(APPEND system_libs xml2
|
|
|
|
${FOUNDATION_LIBRARY}
|
|
|
|
${CORE_FOUNDATION_LIBRARY}
|
|
|
|
${CORE_SERVICES_LIBRARY}
|
|
|
|
${SECURITY_LIBRARY}
|
|
|
|
${DEBUG_SYMBOLS_LIBRARY})
|
2018-08-23 06:25:45 +08:00
|
|
|
include_directories(${LIBXML2_INCLUDE_DIR})
|
2018-12-19 04:51:00 +08:00
|
|
|
elseif(LIBXML2_FOUND AND LIBXML2_VERSION_STRING VERSION_GREATER 2.8)
|
2019-12-12 06:10:38 +08:00
|
|
|
set(LLDB_ENABLE_LIBXML2 ON)
|
2018-12-19 04:51:00 +08:00
|
|
|
list(APPEND system_libs ${LIBXML2_LIBRARIES})
|
|
|
|
include_directories(${LIBXML2_INCLUDE_DIR})
|
2015-04-16 23:51:33 +08:00
|
|
|
endif()
|
|
|
|
|
2018-03-14 18:08:21 +08:00
|
|
|
if( WIN32 AND NOT CYGWIN )
|
|
|
|
set(PURE_WINDOWS 1)
|
|
|
|
endif()
|
2015-06-04 11:12:37 +08:00
|
|
|
|
2018-03-14 18:08:21 +08:00
|
|
|
if(NOT PURE_WINDOWS)
|
|
|
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
list(APPEND system_libs ${CMAKE_THREAD_LIBS_INIT})
|
2015-06-04 11:12:37 +08:00
|
|
|
endif()
|
|
|
|
|
2018-03-14 18:08:21 +08:00
|
|
|
list(APPEND system_libs ${CMAKE_DL_LIBS})
|
|
|
|
|
2015-09-16 23:34:06 +08:00
|
|
|
# Figure out if lldb could use lldb-server. If so, then we'll
|
|
|
|
# ensure we build lldb-server when an lldb target is being built.
|
2019-08-14 07:50:54 +08:00
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD|Windows")
|
2019-07-20 19:18:31 +08:00
|
|
|
set(LLDB_CAN_USE_LLDB_SERVER ON)
|
2019-05-14 06:55:11 +08:00
|
|
|
else()
|
2019-07-20 19:18:31 +08:00
|
|
|
set(LLDB_CAN_USE_LLDB_SERVER OFF)
|
2015-09-16 23:34:06 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Figure out if lldb could use debugserver. If so, then we'll
|
|
|
|
# ensure we build debugserver when we build lldb.
|
2019-07-20 19:18:31 +08:00
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
|
|
set(LLDB_CAN_USE_DEBUGSERVER ON)
|
2015-09-16 23:34:06 +08:00
|
|
|
else()
|
2019-07-20 19:18:31 +08:00
|
|
|
set(LLDB_CAN_USE_DEBUGSERVER OFF)
|
2015-09-16 23:34:06 +08:00
|
|
|
endif()
|
2015-11-15 09:53:23 +08:00
|
|
|
|
2019-12-13 01:13:04 +08:00
|
|
|
if (LLDB_ENABLE_CURSES)
|
2015-11-15 09:53:23 +08:00
|
|
|
find_package(Curses REQUIRED)
|
|
|
|
find_library(CURSES_PANEL_LIBRARY NAMES panel DOC "The curses panel library")
|
|
|
|
if (NOT CURSES_PANEL_LIBRARY)
|
|
|
|
message(FATAL_ERROR "A required curses' panel library not found.")
|
|
|
|
endif ()
|
|
|
|
endif ()
|
[cmake] Add a big warning about a libstdc++ issue
Summary:
Recent increase in the usage of std::weak_ptr has caused us to rediscover an issue in libstdc++
versions prior to 4.9 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59656>, which make this class
unusable without exceptions in the presence of multiple threads. It's virtualy impossible to work
around this issue without implementing our own shared_ptr/weak_ptr substitutes, which does not
seem like a good idea.
Therefore, I am adding a big CMake warning which warns you about this issue if you're attempting
a to do a build which is suceptible to this problem and suggests possible alternatives. Right
now, nothing spectacular will happen if you ignore this warning (all the crashes I have seen
occur during process shutdown), but there's no guarantee the situation will not change in the
future.
Reviewers: tberghammer, tfiala, nitesh.jain, omjavaid, emaste, krytarowski
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D20671
llvm-svn: 270854
2016-05-26 23:16:11 +08:00
|
|
|
|
2017-01-27 20:58:23 +08:00
|
|
|
if ((CMAKE_SYSTEM_NAME MATCHES "Android") AND LLVM_BUILD_STATIC AND
|
|
|
|
((ANDROID_ABI MATCHES "armeabi") OR (ANDROID_ABI MATCHES "mips")))
|
2017-01-27 23:19:03 +08:00
|
|
|
add_definitions(-DANDROID_USE_ACCEPT_WORKAROUND)
|
2017-01-27 20:23:51 +08:00
|
|
|
endif()
|
|
|
|
|
2016-12-17 20:48:06 +08:00
|
|
|
find_package(Backtrace)
|
2017-04-28 00:04:26 +08:00
|
|
|
include(LLDBGenerateConfig)
|