Skip to content

[lldb] Support both Lua 5.3 and Lua 5.4 #115500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 11, 2024
Merged

Conversation

JDevlieghere
Copy link
Member

Lua 5.3 and Lua 5.4 are similar enough that we can easily support both in LLDB. This patch adds support for building LLDB with both and updates the documentation accordingly.

Lua 5.3 and Lua 5.4 are similar enough that we can easily support both
in LLDB. This patch adds support for building LLDB with both and updates
the documentation accordingly.
@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2024

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

Lua 5.3 and Lua 5.4 are similar enough that we can easily support both in LLDB. This patch adds support for building LLDB with both and updates the documentation accordingly.


Full diff: https://github.com/llvm/llvm-project/pull/115500.diff

4 Files Affected:

  • (modified) lldb/CMakeLists.txt (+1-2)
  • (modified) lldb/cmake/modules/FindLuaAndSwig.cmake (+14-2)
  • (modified) lldb/docs/resources/build.rst (+1-1)
  • (modified) lldb/test/API/lit.site.cfg.py.in (+1-1)
diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 5827e04b5662f3..20fbb57d62e69a 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -87,8 +87,7 @@ if (LLDB_ENABLE_PYTHON)
 endif ()
 
 if (LLDB_ENABLE_LUA)
-  find_program(Lua_EXECUTABLE lua5.3)
-  set(LLDB_LUA_DEFAULT_RELATIVE_PATH "lib/lua/5.3")
+  set(LLDB_LUA_DEFAULT_RELATIVE_PATH "lib/lua/${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
   set(LLDB_LUA_RELATIVE_PATH ${LLDB_LUA_DEFAULT_RELATIVE_PATH}
     CACHE STRING "Path where Lua modules are installed, relative to install prefix")
 endif ()
diff --git a/lldb/cmake/modules/FindLuaAndSwig.cmake b/lldb/cmake/modules/FindLuaAndSwig.cmake
index 11548b76f843f0..33fadb2a097407 100644
--- a/lldb/cmake/modules/FindLuaAndSwig.cmake
+++ b/lldb/cmake/modules/FindLuaAndSwig.cmake
@@ -8,11 +8,21 @@ if(LUA_LIBRARIES AND LUA_INCLUDE_DIR AND LLDB_ENABLE_SWIG)
   set(LUAANDSWIG_FOUND TRUE)
 else()
   if (LLDB_ENABLE_SWIG)
-    find_package(Lua 5.3 EXACT)
+    find_package(Lua 5.3)
     if(LUA_FOUND)
+      # Find the Lua executable. Only required to run a subset of the Lua
+      # tests.
+      find_program(LUA_EXECUTABLE
+        NAMES
+        "lua"
+        "lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
+      )
       mark_as_advanced(
         LUA_LIBRARIES
-        LUA_INCLUDE_DIR)
+        LUA_INCLUDE_DIR
+        LUA_VERSION_MINOR
+        LUA_VERSION_MAJOR
+        LUA_EXECUTABLE)
     endif()
   else()
     message(STATUS "SWIG 4 or later is required for Lua support in LLDB but could not be found")
@@ -26,5 +36,7 @@ else()
                                     REQUIRED_VARS
                                       LUA_LIBRARIES
                                       LUA_INCLUDE_DIR
+                                      LUA_VERSION_MINOR
+                                      LUA_VERSION_MAJOR
                                       LLDB_ENABLE_SWIG)
 endif()
diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index 33b6a6f79def4b..66db84522bff1f 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -64,7 +64,7 @@ CMake configuration error.
 +-------------------+------------------------------------------------------+--------------------------+
 | Python            | Python scripting                                     | ``LLDB_ENABLE_PYTHON``   |
 +-------------------+------------------------------------------------------+--------------------------+
-| Lua               | Lua scripting                                        | ``LLDB_ENABLE_LUA``      |
+| Lua               | Lua scripting. Lua 5.3 and 5.4 are supported.        | ``LLDB_ENABLE_LUA``      |
 +-------------------+------------------------------------------------------+--------------------------+
 
 Depending on your platform and package manager, one might run any of the
diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in
index 7dd8ffd2f5cb4c..ff6c705caea96c 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -20,7 +20,7 @@ config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
 config.python_executable = "@Python3_EXECUTABLE@"
-config.lua_executable = "@Lua_EXECUTABLE@"
+config.lua_executable = "@LUA_EXECUTABLE@"
 config.lua_test_entry = "TestLuaAPI.py"
 config.dotest_common_args_str = lit_config.substitute("@LLDB_TEST_COMMON_ARGS@")
 config.dotest_user_args_str = lit_config.substitute("@LLDB_TEST_USER_ARGS@")

@JDevlieghere
Copy link
Member Author

I'm not a fan of how TestLuaAPI.py works today. I think it should be its own lit format, without going through detest.py. I think that shouldn't be too hard, but I'll do that as a follow-up.

@labath
Copy link
Collaborator

labath commented Nov 8, 2024

detest.py

I'm not a fan of how TestLuaAPI.py works today.

You could even say you detest it. :P

@jimingham
Copy link
Collaborator

jimingham commented Nov 8, 2024 via email

@JDevlieghere
Copy link
Member Author

I'd say this was a Freudian slip.

@JDevlieghere JDevlieghere merged commit e19d740 into llvm:main Nov 11, 2024
8 checks passed
@JDevlieghere JDevlieghere deleted the lua54 branch November 11, 2024 16:13
JDevlieghere added a commit to swiftlang/llvm-project that referenced this pull request Nov 13, 2024
Lua 5.3 and Lua 5.4 are similar enough that we can easily support both
in LLDB. This patch adds support for building LLDB with both and updates
the documentation accordingly.

(cherry picked from commit e19d740)
JDevlieghere added a commit to swiftlang/llvm-project that referenced this pull request Nov 14, 2024
[lldb] Support both Lua 5.3 and Lua 5.4 (llvm#115500)
Groverkss pushed a commit to iree-org/llvm-project that referenced this pull request Nov 15, 2024
Lua 5.3 and Lua 5.4 are similar enough that we can easily support both
in LLDB. This patch adds support for building LLDB with both and updates
the documentation accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants