Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Ostanevich <sergos@tarantool.org>,
	Igor Munkin <imun@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH luajit v3 02/29] test: build auxiliary C libs from PUC-Rio Lua 5.1
Date: Tue, 13 Apr 2021 16:27:02 +0300	[thread overview]
Message-ID: <dea7772eeb4b798e78fec8fe99409d81528ed7b7.1618320000.git.skaplun@tarantool.org> (raw)
In-Reply-To: <cover.1618320000.git.skaplun@tarantool.org>

This patch adds rules to create additional LuaC libraries for tests
in <attrib.lua>. Also, it renames `luaL_reg` to `luaL_Reg` in <lib1.c>
and <lib2.c> to be consistent with the current LuaJIT's LuaC API.

Part of tarantool/tarantool#5845
Part of tarantool/tarantool#4473
---
 test/PUC-Rio-Lua-5.1-tests/CMakeLists.txt     |  3 +-
 .../PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt | 49 ++++++++++++++++++-
 test/PUC-Rio-Lua-5.1-tests/libs/lib1.c        |  2 +-
 test/PUC-Rio-Lua-5.1-tests/libs/lib2.c        |  2 +-
 4 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/test/PUC-Rio-Lua-5.1-tests/CMakeLists.txt b/test/PUC-Rio-Lua-5.1-tests/CMakeLists.txt
index e3bbc9de..aab2d2fc 100644
--- a/test/PUC-Rio-Lua-5.1-tests/CMakeLists.txt
+++ b/test/PUC-Rio-Lua-5.1-tests/CMakeLists.txt
@@ -16,7 +16,8 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
 # variable as proposed in the first case.
 set(LUA_PATH "?\;${CMAKE_CURRENT_SOURCE_DIR}/?.lua")
 
-# Establish PUC-Lua-5.1-tests-prepare target that creates <libs/P1>
+# Establish PUC-Lua-5.1-tests-prepare target that contains rules
+# for <libs/*> libraries compilation and creates <libs/P1>
 # subdirectory.
 add_subdirectory(libs)
 
diff --git a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
index f24e7f30..b31ba130 100644
--- a/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
+++ b/test/PUC-Rio-Lua-5.1-tests/libs/CMakeLists.txt
@@ -4,11 +4,58 @@
 # See the rationale in the root CMakeLists.txt.
 cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
 
+# Build additional C libraries for tests.
+macro(BuildTestCLib lib sources)
+  add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
+  target_include_directories(${lib} PRIVATE
+    ${LUAJIT_SOURCE_DIR}
+  )
+  set_target_properties(${lib} PROPERTIES
+    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+    PREFIX ""
+  )
+  # XXX: The dynamic libraries are loaded with LuaJIT binary and
+  # use symbols from it. So it is totally OK to have unresolved
+  # symbols at build time.
+  if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+    set_target_properties(${lib} PROPERTIES
+      LINK_FLAGS "-undefined dynamic_lookup"
+    )
+  elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+    # XXX: This is necessary mostly for openSUSE builds, see also
+    # https://bugzilla.suse.com/show_bug.cgi?id=1012388.
+    # Just strip out the linker flag to suppress this linker
+    # option.
+    string(REPLACE "-Wl,--no-undefined" ""
+      CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
+    )
+  endif()
+  list(APPEND TESTLIBS ${lib})
+endmacro()
+
+BuildTestCLib(lib1 lib1.c)
+BuildTestCLib(lib11 lib1.c lib11.c)
+BuildTestCLib(lib2 lib2.c)
+BuildTestCLib(lib21 lib2.c lib21.c)
+
+# Create the exact copy of the lib2 library for tests
+# in <attrib.lua>.
+set(LIB2ORIG "${CMAKE_CURRENT_BINARY_DIR}/lib2${CMAKE_SHARED_LIBRARY_SUFFIX}")
+set(LIB2COPY "${CMAKE_CURRENT_BINARY_DIR}/-lib2${CMAKE_SHARED_LIBRARY_SUFFIX}")
+add_custom_command(
+  OUTPUT ${LIB2COPY}
+  COMMENT "Copying lib2 to -lib2 for PUC-Rio Lua 5.1 tests"
+  COMMAND ${CMAKE_COMMAND} -E copy ${LIB2ORIG} ${LIB2COPY}
+  DEPENDS ${TESTLIBS}
+  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+)
+list(APPEND TESTLIBS ${LIB2COPY})
+
 # The original tarball contains subdirectory "libs" with an empty
 # subdirectory "libs/P1", to be used by tests.
 # Instead of tracking empty directory with some anchor-file for
 # git, create this directory via CMake.
-add_custom_target(PUC-Lua-5.1-tests-prepare)
+add_custom_target(PUC-Lua-5.1-tests-prepare DEPENDS ${TESTLIBS})
 add_custom_command(TARGET PUC-Lua-5.1-tests-prepare
   COMMENT "Create directory for PUC-Rio Lua 5.1 tests"
   COMMAND ${CMAKE_COMMAND} -E make_directory P1
diff --git a/test/PUC-Rio-Lua-5.1-tests/libs/lib1.c b/test/PUC-Rio-Lua-5.1-tests/libs/lib1.c
index 812bb9ac..22fe6dee 100644
--- a/test/PUC-Rio-Lua-5.1-tests/libs/lib1.c
+++ b/test/PUC-Rio-Lua-5.1-tests/libs/lib1.c
@@ -14,7 +14,7 @@ static int id (lua_State *L) {
 }
 
 
-static const struct luaL_reg funcs[] = {
+static const struct luaL_Reg funcs[] = {
   {"id", id},
   {NULL, NULL}
 };
diff --git a/test/PUC-Rio-Lua-5.1-tests/libs/lib2.c b/test/PUC-Rio-Lua-5.1-tests/libs/lib2.c
index 9972cbe4..876a212f 100644
--- a/test/PUC-Rio-Lua-5.1-tests/libs/lib2.c
+++ b/test/PUC-Rio-Lua-5.1-tests/libs/lib2.c
@@ -12,7 +12,7 @@ static int id (lua_State *L) {
 }
 
 
-static const struct luaL_reg funcs[] = {
+static const struct luaL_Reg funcs[] = {
   {"id", id},
   {NULL, NULL}
 };
-- 
2.31.0


  parent reply	other threads:[~2021-04-13 13:29 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13 13:27 [Tarantool-patches] [PATCH luajit v3 00/29] Adapt PUC-Rio Lua 5.1 test suite Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 01/29] test: add " Sergey Kaplun via Tarantool-patches
2021-04-13 20:31   ` Igor Munkin via Tarantool-patches
2021-04-14 13:54     ` Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` Sergey Kaplun via Tarantool-patches [this message]
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 03/29] test: adapt PUC-Rio suite for out-of-source build Sergey Kaplun via Tarantool-patches
2021-04-13 21:05   ` Igor Munkin via Tarantool-patches
2021-04-14 13:54     ` Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 04/29] test: remove quotes in progname from PUC-Rio Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 05/29] test: adapt PUC-Rio test for arg presence Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 06/29] test: disable PUC-Rio tests confused by -v output Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 07/29] test: disable PUC-Rio tests for bytecode header Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 08/29] test: adapt PUC-Rio tests counting GC steps Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 09/29] test: disable PUC-Rio suite tests for line hook Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 10/29] test: adapt PUC-Rio tests with vararg functions Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 11/29] test: adapt PUC-Rio test for debug in vararg func Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 12/29] test: adapt PUC-Rio test with count hooks Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 13/29] test: disable PUC-Rio test for tail call info Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 14/29] test: adapt PUC-Rio test with activeline check Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 15/29] test: disable PUC-Rio test for per-coroutine hooks Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 16/29] test: adapt PUC-Rio test for %q in string.format Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 17/29] test: disable locale-dependent PUC-Rio tests Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 18/29] test: use math.fmod in " Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 19/29] test: remove string.gfind assert in PUC-Rio test Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 20/29] test: disable PUC-Rio test for getfenv in tailcall Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 21/29] test: disable PUC-Rio test for variables in error Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 22/29] test: disable PUC-Rio test for fast function name Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 23/29] test: disable PUC-Rio test for non-asci identifier Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 24/29] test: disable PUC-Rio test for syntax level error Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 25/29] test: disable PUC-RIO tests for several -l options Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 26/29] test: disable PUC-Rio test for checking arg layout Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 27/29] test: disable PUC-Rio test checking -h option Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 28/29] test: disable PUC-Rio hanging GC test Sergey Kaplun via Tarantool-patches
2021-04-13 13:27 ` [Tarantool-patches] [PATCH luajit v3 29/29] test: disable too deep recursive PUC-Rio test Sergey Kaplun via Tarantool-patches
2021-04-14 21:08 ` [Tarantool-patches] [PATCH luajit v3 00/29] Adapt PUC-Rio Lua 5.1 test suite Igor Munkin via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dea7772eeb4b798e78fec8fe99409d81528ed7b7.1618320000.git.skaplun@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imun@tarantool.org \
    --cc=sergos@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit v3 02/29] test: build auxiliary C libs from PUC-Rio Lua 5.1' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox