[Tarantool-patches] [PATCH luajit 1/3] build: pass sysroot to MacOS SDK

Igor Munkin imun at tarantool.org
Tue May 11 01:09:05 MSK 2021


There were issues with configuring LuaJIT on Apple machines, since
<LuaJITTestArch> CMake auxiliary routine fails to locate system headers
(e.g. assert.h in case when LUA_USE_ASSERT is enabled). As a result
platform detection fails and LuaJIT configuration ends with the fatal
error. This patch adds the necessary flags to help the routine to find
the required system headers.

Relates to tarantool/tarantool#5629
Needed for tarantool/tarantool#5983
Follows up tarantool/tarantool#4862

Signed-off-by: Igor Munkin <imun at tarantool.org>
---

 CMakeLists.txt          | 9 +++++++++
 cmake/LuaJITUtils.cmake | 7 ++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5348e043..110a989f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -114,6 +114,15 @@ if(LUAJIT_ENABLE_WARNINGS)
   )
 endif()
 
+# Set sysroot settings on OSX to find SDK with the system headers.
+# XXX: Obviously, there is no need in this setup if everything is
+# already set via CMAKE_C_FLAGS or in parent project build system.
+if(CMAKE_OSX_SYSROOT AND CMAKE_C_SYSROOT_FLAG AND
+  NOT "${CMAKE_C_FLAGS}" MATCHES "${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}"
+)
+  AppendFlags(CMAKE_C_FLAGS "${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}")
+endif()
+
 # Auxiliary flags for main targets (libraries, binaries).
 AppendFlags(TARGET_C_FLAGS
   -D_FILE_OFFSET_BITS=64
diff --git a/cmake/LuaJITUtils.cmake b/cmake/LuaJITUtils.cmake
index d9f8b12a..8ff26a6a 100644
--- a/cmake/LuaJITUtils.cmake
+++ b/cmake/LuaJITUtils.cmake
@@ -1,8 +1,13 @@
 function(LuaJITTestArch outvar strflags)
+  # XXX: Compiler flags are also required in this routine. It can
+  # use e.g. external headers, which location is specified either
+  # implicitly (within CMake machinery) or explicitly (manually by
+  # configuration options).
+  set(TESTARCH_C_FLAGS "${CMAKE_C_FLAGS} ${strflags}")
   # XXX: <execute_process> simply splits the COMMAND argument by
   # spaces with no further parsing. At the same time GCC is bad in
   # argument handling, so let's help it a bit.
-  separate_arguments(TESTARCH_C_FLAGS UNIX_COMMAND ${strflags})
+  separate_arguments(TESTARCH_C_FLAGS UNIX_COMMAND ${TESTARCH_C_FLAGS})
   # TODO: It would be nice to drop a few words, why do we use this
   # approach instead of CMAKE_HOST_SYSTEM_PROCESSOR variable.
   execute_process(
-- 
2.25.0



More information about the Tarantool-patches mailing list