Commit Graph

361 Commits

Author SHA1 Message Date
Jonas Devlieghere 6e670e0796 [lldb/Lua] Require Lua 5.3 2020-06-23 09:24:01 -07:00
Jonas Devlieghere 2c0afacada [lldb/CMake] Add LLDB_PYTHON_VERSION to use Python 2 with CMake > 3.12
In addition to having the default fallback from Python 3 to Python 2, it
should also be possible to build against Python 2 explicitly. This patch
makes that possible by setting LLDB_PYTHON_VERSION. The variable only
has effect with CMake 3.12 or later.

Differential revision: https://reviews.llvm.org/D81501
2020-06-09 14:11:11 -07:00
Haibo Huang 04daba9670 [lldb] Cleans up system_libs
Summary:
Long long ago system_libs was appended to LLDB_SYSTEM_LIBS in
cmake/LLDBDependencies.cmake. After that file was removed, system_libs
is orphaned.

Currently the only user is source/Utility. Move the logic there and
remove system_libs.

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D80253
2020-05-20 12:30:08 -07:00
Haibo Huang 780d7d7732 [lldb] Allows customizing libxml2 for darwin
Summary:
This changes allows to disable or use customized libxml2 for lldb.

1. Removes redundant include_directories. The one in LLDBConfig.cmake should be enough.

2. Link to ${LIBXML2_LIBRARIES} if xml2 is enabled.

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D80257
2020-05-20 12:27:08 -07:00
Jonas Devlieghere 397e69dbcb [lldb/CMake] Don't make PYTHON_RPATH a required variable. 2020-04-30 10:54:47 -07:00
Jonas Devlieghere ae6d2ff633 [lldb] fix RPATH when linking against Python3.framework
The install name for the Python 3 framework in Xcode is relative to
the framework's location and not the dylib itself.

  @rpath/Python3.framework/Versions/3.x/Python3

This means that we need to compute the path to the Python3.framework
and use that as the RPATH instead of the usual dylib's directory.
2020-04-30 10:42:03 -07:00
Saleem Abdulrasool 7c8fa95395 lldb: use the newer `find_package` if available
Now that the rest of LLVM prefers python3 over python2, the LLDB path
should follow suite.  Add a fallback path to python2 for non-Windows
targets.
2020-04-29 03:54:33 +00:00
Isuru Fernando 664fda72ea Fix setting Python3_ROOT_DIR on Windows
Summary:
Previously the value of Python3_ROOT_DIR was set to the string
"PYTHON_HOME" instead of the value of the variable named
PYTHON_HOME. This commit fixes that as CMake expects
a path as the value of Python3_ROOT_DIR

Reviewers: #lldb, JDevlieghere, teemperor

Reviewed By: #lldb, JDevlieghere, teemperor

Subscribers: teemperor, JDevlieghere, mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77842
2020-04-14 12:50:54 -05:00
Raphael Isemann ce1bc00f37 [lldb][cmake] Move remove_module_flags macro to AddLLDB.cmake
Summary: This is currently hidden in the Host CMakeLists but we should also use this macro in other parts of LLDB where we have ObjC++ sources (see D74891)

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75164
2020-03-06 17:21:24 -08:00
Jonas Devlieghere 04a91deebb [lldb/CMake] Use PYTHON_HOME as a hint to find Python 3.
http://lists.llvm.org/pipermail/lldb-dev/2020-February/015998.html

Differential revision: https://reviews.llvm.org/D75275
2020-02-27 13:17:49 -08:00
Haibo Huang 3ec3f62f0a Allow customized relative PYTHONHOME (Attemp 1)
Summary:
This is another attempt of 0bb90628b5.

The difference is that g_python_home is not declared as const. Since
some versions of python do not expect that.

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74998
2020-02-21 16:25:30 -08:00
Stella Stamenova 215a31115f Revert "Allow customized relative PYTHONHOME"
This reverts commit 0bb90628b5 since it is causing failures on the Windows LLDB buildbot:

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/14048
2020-02-21 14:57:00 -08:00
Haibo Huang 0bb90628b5 Allow customized relative PYTHONHOME
Summary:
This change allows a hard coded relative PYTHONHOME setting. So that
python can easily be packaged together with lldb.

The change includes:
1. Extend LLDB_RELOCATABLE_PYTHON to all platforms. It defaults to ON
for platforms other than Windows, to keep the behavior compatible.
2. Allows to customize LLDB_PYTHON_HOME. But still defaults to
PYTHON_HOME.
3. LLDB_PYTHON_HOME can be a path relative to liblldb. If it is
relative, we will resolve it before send it to Py_DecodeLocale.

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74727
2020-02-21 12:49:10 -08:00
Matt Davis 07d2cdae11 [lldb/cmake] Enable more verbose find_package output.
Summary:
The purpose of this patch is to make identifying missing dependencies clearer to the user.
`find_package` will report if a package is not found, that output, combined with the exiting
status message, is clearer than not having the additional verbosity.

If the SWIG dependency is required {LLDB_ENABLE_PYTHON, LLDB_ENABLE_LUA}
and SWIG is not available, fail the configuration step.  Terminate the
configure early rather than later with a clear error message.

We could possibly modify:
`llvm-project/lldb/cmake/modules/FindPythonInterpAndLibs.cmake`
However, the patch here seems clear in my opinion.

Reviewers: aadsm, hhb, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: labath, jrm, mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74917
2020-02-21 10:37:02 -08:00
Pavel Labath 363f05b83d [lldb] Delete the SharingPtr class
Summary:
The only use of this class was to implement the SharedCluster of ValueObjects.
However, the same functionality can be implemented using a regular
std::shared_ptr, and its little-known "sub-object pointer" feature, where the
pointer can point to one thing, but actually delete something else when it goes
out of scope.

This patch reimplements SharedCluster using this feature --
SharedClusterPointer::GetObject now returns a std::shared_pointer which points
to the ValueObject, but actually owns the whole cluster. The only change I
needed to make here is that now the SharedCluster object needs to be created
before the root ValueObject. This means that all private ValueObject
constructors get a ClusterManager argument, and their static Create functions do
the create-a-manager-and-pass-it-to-value-object dance.

Reviewers: teemperor, JDevlieghere, jingham

Subscribers: mgorny, jfb, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74153
2020-02-11 13:23:18 +01:00
Konrad Kleine b89131cdda [lldb] removed no longer needed CMakeDependentOption
Summary:
In D66791 I've introduced this [[ https://cmake.org/cmake/help/latest/module/CMakeDependentOption.html | `CMakeDependentOption` ]] but in
D71306 @JDevlieghere has changed the way optional dependencies
are handled in LLDB. Today there's no occurence of
`cmake_dependent_option` inside the lldb source tree.

That's why this include can be removed.

Reviewers: JDevlieghere, labath

Reviewed By: labath

Subscribers: labath, mgorny, lldb-commits, JDevlieghere

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74160
2020-02-07 09:23:35 +01:00
Jonas Devlieghere edadb818e5 [lldb/CMake] Only auto-enable Lua when SWIG is found
Just like Python, Lua should only be auto-enabled if SWIG is found as
well. This moves the logic of finding SWIG and Lua as a whole into a new
CMake package.
2020-01-08 14:02:47 -08:00
Jonas Devlieghere bbbbf8a106 [lldb/CMake] Use LLDB's autodetection logic for libxml2
Libxml2 is already an optional dependency. It should use the same
infrastructure as the other dependencies.

Differential revision: https://reviews.llvm.org/D72290
2020-01-08 09:03:40 -08:00
Jonas Devlieghere fc6f15d4d2 [lldb/CMake] Only auto-enable Python when SWIG is found
As correctly pointed out by Martin on the mailing list, Python should
only be auto-enabled if SWIG is found as well. This moves the logic of
finding SWIG into FindPythonInterpAndLibs to make that possible.

To make diagnosing easier I've included a status message to convey why
Python support is disabled.
2020-01-07 21:57:32 -08:00
Jonas Devlieghere 8c8ffd461d [lldb/CMake] Only set PYTHON_HOME on Windows
My earlier change for Python auto-detection caused PYTHON_HOME to be set
unconditionally, while before the change this only happened for Windows.
This caused the PythonDataObjectsTest to fail with an import error.
2020-01-06 10:07:46 -08:00
Jonas Devlieghere b3757f3091 [lldb/CMake] Autodetect Python dependency
Python was the last remaining "optional" dependency for LLDB. This moves
the code to find Python into FindPythonInterpAndLibs using the same
principles as FindCursesAndPanel.

Differential revision: https://reviews.llvm.org/D72107
2020-01-06 09:05:05 -08:00
Jonas Devlieghere f83801fb2a [lldb/CMake] Print whether an optional dependency was enabled.
Use a status message to convey whether an optional dependency was found
or not. With the auto-detection code it's not longer as simple as
checking the CMake cache.
2020-01-02 13:40:01 -08:00
Jonas Devlieghere f38234ed8b [lldb/CMake] Fix variable naming in FindLibEdit
The current FOUND_VAR for FindLibEdit is libedit_FOUND but wasn't set by
find_package_handle_standard_args. However this isn't valid for the
package name.

  The argument for FOUND_VAR is "libedit_FOUND", but only "LibEdit_FOUND" and
  "LIBEDIT_FOUND" are valid names.

This fixes all the variables set by FindLibEdit to match the desired
naming scheme.
2020-01-02 13:39:57 -08:00
Jonas Devlieghere 3ddfb04f41 [lldb/CMake] Use PYTHON_LIBRARIES instead of PYTHON_LIBRARY
PYTHON_LIBRARIES is the canonical variable set by FindPythonLibs while
PYTHON_LIBRARY is an implementation detail. This replaces the uses of
the latter with the former.
2020-01-02 13:01:17 -08:00
Alex Langford 187f66bcac [lldb/CMake] Always set a value for find_package when finding optional dependencies
Because this is a macro, previous values of `find_package` persist
between calls. This means that if it is set to TRUE on any run, all
subsequent runs will have find_package set to TRUE regardles of whether
or not they should be.
2019-12-23 13:37:58 -08:00
Saleem Abdulrasool b449d19e55 build: use `find_package(Python3)` rather than `PYTHON_HOME`
The behaviour of `PYTHON_HOME` can be emulated by setting
`Python3_EXECUTABLE` to the absolute path instead of the custom variable
now that we can find the python interpreter.
2019-12-22 20:47:25 -08:00
Saleem Abdulrasool 2046d72e91 build: improve python checks for Windows
Require a newer CMake on Windows to use the Python3 support that is
packaged in CMake. This version is able to check both 32-bit and 64-bit
versions and will setup everything properly without the user needing to
specify PYTHON_HOME. This enables building lldb's python bindings on
Windows under Azure's CI again.
2019-12-22 13:57:46 -08:00
Jonas Devlieghere c51ad1f836 [lldb/CMake] Don't use return() from macro()
> A macro is executed as if the macro body were pasted in place of the
> calling statement. This has the consequence that a return() in a macro
> body does not just terminate execution of the macro

After converting from a function() to a macro(), the return() became
invalid. This modifies the control flow to elude the return.
2019-12-20 20:53:33 -08:00
Jonas Devlieghere 94b1bc0fb8 Re-land "[lldb/CMake] Change how we deal with optional dependencies"
Recently there has been some discussion about how we deal with optional
dependencies in LLDB. The approach in LLVM is to make things work out of
the box. If the dependency isn't there, we move on silently.

That's not true for LLDB. Unless you explicitly disable the dependency
with LLDB_ENABLE_*, you'll get a configuration-time error. The
historical reason for this is that LLDB's dependencies have a much
broader impact, think about Python for example which is required to run
the test suite.

The current approach can be frustrating from a user experience
perspective. Sometimes you just want to ensure LLDB builds with a change
in clang.

This patch changes the optional dependencies (with the exception of
Python) to a new scheme. The LLDB_ENABLE_* now takes three values: On,
Off or Auto, with the latter being the default. On and Off behave the
same as today, forcing the dependency to be enabled or disabled. If the
dependency is set to On but is not found, it results in a configuration
time warning. For Auto we detect if the dependency is there and either
enable or disable it depending on whether it's found.

Differential revision: https://reviews.llvm.org/D71306

PS: The reason Python isn't included yet is because it's so pervasive
that I plan on doing that in a separate patch.
2019-12-20 20:05:04 -08:00
Jonas Devlieghere fe86289bf1 Revert "[lldb/CMake] Change how we deal with optional dependencies"
This is failing on both the Windows and Debian bot.
2019-12-20 15:35:43 -08:00
Jonas Devlieghere 41d7c227b3 [lldb/CMake] Change how we deal with optional dependencies
Recently there has been some discussion about how we deal with optional
dependencies in LLDB. The approach in LLVM is to make things work out of
the box. If the dependency isn't there, we move on silently.

That's not true for LLDB. Unless you explicitly disable the dependency
with LLDB_ENABLE_*, you'll get a configuration-time error. The
historical reason for this is that LLDB's dependencies have a much
broader impact, think about Python for example which is required to run
the test suite.

The current approach can be frustrating from a user experience
perspective. Sometimes you just want to ensure LLDB builds with a change
in clang.

This patch changes the optional dependencies (with the exception of
Python) to a new scheme. The LLDB_ENABLE_* now takes three values: On,
Off or Auto, with the latter being the default. On and Off behave the
same as today, forcing the dependency to be enabled or disabled. If the
dependency is set to On but is not found, it results in a configuration
time warning. For Auto we detect if the dependency is there and either
enable or disable it depending on whether it's found.

Differential revision: https://reviews.llvm.org/D71306

PS: The reason Python isn't included yet is because it's so pervasive
that I plan on doing that in a separate patch.
2019-12-20 14:13:28 -08:00
Jonas Devlieghere 2861324208 [lldb/Lua] Implement a Simple Lua Script Interpreter Prototype
This implements a very elementary Lua script interpreter. It supports
running a single command as well as running interactively. It uses
editline if available. It's still missing a bunch of stuff though. Some
things that I intentionally ingored for now are that I/O isn't properly
hooked up (so every print goes to stdout) and the non-editline support
which is not handling a bunch of corner cases. The latter is a matter of
reusing existing code in the Python interpreter.

Discussion on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2019-December/015812.html

Differential revision: https://reviews.llvm.org/D71234
2019-12-20 11:19:47 -08:00
Pavel Labath 40aa418223 [lldb/cmake] Delete LLDB_LINKER_SUPPORTS_GROUPS
The variable is unused.
2019-12-20 16:58:58 +01:00
Pavel Labath ca567ad6ff [lldb/cmake] Remove support for LLDB_DISABLE_CURSES
The buildbot which necessitated this is fixed.
2019-12-20 16:50:06 +01:00
Jonas Devlieghere 67de896229 [lldb/Lua] Add Boilerplate for a Lua Script Interpreter
This adds the boilerplate necessary to support the Lua script
interpreter. The interpreter is not functional yet and just reports that
it's not implemented.

Discussion on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2019-December/015812.html

Differential revision: https://reviews.llvm.org/D71232
2019-12-19 10:13:51 -08:00
Jonas Devlieghere e8af4fd42d [lldb/CMake] Initialize LLDB_ENABLE_POSIX based on the UNIX variable. 2019-12-13 13:46:43 -08:00
Jonas Devlieghere 4e26cf2cfb [lldb/CMake] Rename LLDB_DISABLE_PYTHON to LLDB_ENABLE_PYTHON
This matches the naming scheme used by LLVM and all the other optional
dependencies in LLDB.

Differential revision: https://reviews.llvm.org/D71482
2019-12-13 13:41:11 -08:00
Jonas Devlieghere 3011d55f72 [lldb/Host] Use cmakedefine01 for LLDB_ENABLE_POSIX
Rename LLDB_DISABLE_POSIX to LLDB_ENABLE_POSIX and use cmakedefine01 for
consistency.
2019-12-13 10:00:59 -08:00
Pavel Labath ec109fb7ed [lldb/cmake] Temporarily revive LLDB_DISABLE_CURSES
At least one lldb bot still uses this cmake variable instead of
LLDB_ENABLE_CURSES. Add code to set the default value of the "enable"
variable based on the old value of the "disable" setting.

This should bring those bots back up, until we can update the master to
use the new setting.
2019-12-13 10:23:35 +01:00
Jonas Devlieghere 61a2bdadb3 [lldb/Host] Use cmakedefine01 for LLDB_ENABLE_TERMIOS
This renames LLDB_CONFIG_TERMIOS_SUPPORTED to LLDB_ENABLE_TERMIOS. It
now also uses cmakedefine01 to keep things consistent with out other
optional dependencies. But more importantly it won't silently fail when
you forget to include Config.h.
2019-12-12 09:34:11 -08:00
Jonas Devlieghere 62456e579e [lldb/CMake] Rename LLDB_DISABLE_LIBEDIT to LLDB_ENABLE_LIBEDIT
This matches the naming scheme used by LLVM.

Differential revision: https://reviews.llvm.org/D71380
2019-12-12 09:23:06 -08:00
Jonas Devlieghere a4304f96d6 [lldb/CMake] Rename LLDB_DISABLE_CURSES to LLDB_ENABLE_CURSES
This matches the naming scheme used by LLVM.

Differential revision: https://reviews.llvm.org/D71377
2019-12-12 09:13:31 -08:00
Jonas Devlieghere ff82315d4e [lldb/CMake] Simplify linking against curses
Centralize the logic to determine what libraries to link against for
curses in the CMake file where it is actually being used. Use
target_include_directories instead of include_directories.
2019-12-11 14:36:32 -08:00
Jonas Devlieghere bf68bcb920 [lldb/Host] Use Host/Config.h for LibXML2 instead of a global define
Rename LIBXML2_DEFINED to LLDB_ENABLE_LIBXML2 and pass it through
Config.h instead of a global define.
2019-12-11 14:13:41 -08:00
Jonas Devlieghere 59998b7b7f [lldb/Host] Use Host/Config.h entries instead of a global define.
As suggested by Pavel in a code review:

> Can we replace this (and maybe python too, while at it) with a
> Host/Config.h entry? A global definition means that one has to
> recompile everything when these change in any way, whereas in
> practice only a handful of files need this..

Differential revision: https://reviews.llvm.org/D71280
2019-12-10 11:16:52 -08:00
Jonas Devlieghere a921f587f7 Revert "[CMake] Re-enable -Wno-gnu-anonymous-struct & -Wno-nested-anon-types."
Whoops, they should be enabled, not disabled.
2019-11-18 17:00:35 -08:00
Jonas Devlieghere 755afc0af8 [CMake] Re-enable -Wno-gnu-anonymous-struct & -Wno-nested-anon-types.
We're checking for support but we're discarding the result. My best
guess is that these warnings were disabled in the past. However, I don't
see a reason to keep it that way.
2019-11-18 16:58:40 -08:00
Jonas Devlieghere 34ca6e1fbe [LLDB] Remove debug message in AddLLDB.cmake 2019-11-12 15:33:03 -08:00
Jonas Devlieghere a247bd1f27 [LLDB] Fix/silence CMake developer warning for LLDB framework.
This fixes the following warning for developers:

  Target 'liblldb' was changed to a FRAMEWORK sometime after install().  This
  may result in the wrong install DESTINATION.  Set the FRAMEWORK property
  earlier.

The solution is to pass the FRAMEWORK flag to add_lldb_library and set
the target property before install(). For now liblldb is the only
customer.
2019-11-12 14:17:19 -08:00
Jonas Devlieghere fbb228c7d2 [LLDB] Always remove debugserver from LLVM_DISTRIBUTION_COMPONENTS
Centralize the logic to remove debugserver from
LLVM_DISTRIBUTION_COMPONENTS when LLDB_USE_SYSTEM_DEBUGSERVER is
enabled. Now this happens regardless of whether the tests are enabled.
2019-11-12 12:58:26 -08:00