[Tarantool-patches] [PATCH luajit] build: provide LUAJIT_USE_PERFTOOLS option

Sergey Kaplun skaplun at tarantool.org
Tue Jun 3 20:35:59 MSK 2025


This patch provides the LUAJIT_USE_PERFTOOLS flag via the CMake build
system. It allows you to avoid the definition of the cognominal macro
definition via CMAKE_C_FLAGS to use integration with the Linux perf
tools interface [1] to resolve symbols for traces generated by a JIT.

It may be used like the following:

| perf record script -f luajit test.lua
| perf report -s symbol

[1]: https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt

Resolves tarantool/tarantool#11300
---

Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-11300-use-perftools-flag
Issue: https://github.com/tarantool/tarantool/issues/11300

 CMakeLists.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 854b3613..c0da4362 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -259,6 +259,14 @@ if(LUAJIT_USE_VALGRIND)
   AppendFlags(TARGET_C_FLAGS -DLUAJIT_USE_VALGRIND)
 endif()
 
+# This creates a symbol table of the JIT-compiled code in
+# a </tmp/perf-%d.map> (%d = pid of process) file. It should be
+# used with Linux perf tools. See <src/lj_trace.c> for details.
+option(LUAJIT_USE_PERFTOOLS "Linux perf JIT support" OFF)
+if(LUAJIT_USE_PERFTOOLS)
+  AppendFlags(TARGET_C_FLAGS -DLUAJIT_USE_PERFTOOLS)
+endif()
+
 # This is the client for the GDB JIT API. GDB 7.0 or higher is
 # required to make use of it. See lj_gdbjit.c for details.
 # Enabling this causes a non-negligible overhead, even when not
-- 
2.49.0



More information about the Tarantool-patches mailing list