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

Sergey Kaplun skaplun at tarantool.org
Fri May 14 19:07:05 MSK 2021


Igor,

Thanks for the fixes!

Please fix the nit below. Otherwise, LGTM.

On 13.05.21, Igor Munkin wrote:
> Sergey,
> 
> Thanks for such precise review! I've answered the questions below and
> re-implemented the fix (the new patch is at the end), so hold your LGTM
> for a while.
> 
> On 11.05.21, Sergey Kaplun wrote:

<snipped>

> > Side note: Also I've seen that Mike uses OSX_DEPLOYMENT_TARGET variable.
> > Moreover, CMAKE_OSX_SYSROOT should "computed based on the
> > CMAKE_OSX_DEPLOYMENT_TARGET or the host platform" according to [4].
> > And by itself, it means the minimum possible IOS version, where an
> > application may run [5]. May be we should fix this too with a separate
> > issue and patch (to protect users from building LuaJIT on ancient
> > devices)?
> 
> Sorry, I don't get this one. What exactly is bothering you here?

Just friendly reminder. It's not related to the patch. Just a side
note. :) I remembered about it only because it is part of OSX twists.
There is no need to do it in this patch, but maybe later?

> 

<snipped>

> > > +)
> > > +  AppendFlags(CMAKE_C_FLAGS "${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}")
> > > +endif()
> > 
> > Also, as far as this misbehaviour is occuring only for LuaJITTestArch()
> > macro we may avoid tweaking of global CMAKE_C_FLAGS, but just append it
> > to TESTARCH_C_FLAGS if it is necessary.
> 
> Unfortunately, CMake is a crap. At first, these flags are required at
> the configuration phase, but everything works fine at the build phase.
> As a result of investigation, I've found that CMake emits[1] these flags
> (both -arch and -isysroot) to a separate flags.make file located deep
> into CMakeFiles/ directory. Moreover, they are not available via CMake
> variables (used at configuration phase). They are just <fprintf>-ed to
> the freaking file being included in build.make. Nice work, dudes! If
> they wanted the most foolproof solution, they made it!
> 
> However, thanks to CMake authors for their tests: I've taken the recipe
> there[2], so you can consider this as "Официальная позиция CMake".
> Again, the changes are below.

Thanks for the investigation and clarification!

> 

<snipped>

> > 
> > [1]: https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html
> > [2]: https://cmake.org/cmake/help/v3.1/manual/cmake-variables.7.html
> > [3]: https://github.com/LuaJIT/LuaJIT/blob/8dc3cd6c84dfc81539604340b7884408e1c71d55/doc/install.html#L437
> > [4]: https://cmake.org/cmake/help/v3.1/variable/CMAKE_OSX_SYSROOT.html
> > [5]: https://developer.apple.com/library/archive/documentation/ToolsLanguages/Conceptual/Xcode_Overview/WorkingwithTargets.html
> > 
> > -- 
> > Best regards,
> > Sergey Kaplun
> 
> ================================================================================
> 
> build: pass sysroot to MacOS SDK
> 
> 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.
> 
> Needed for tarantool/tarantool#6065
> Relates to tarantool/tarantool#5629
> Follows up tarantool/tarantool#4862

What's about 5983? Shouldn't it be mentioned too?

> 
> Signed-off-by: Igor Munkin <imun at tarantool.org>
> ---
>  cmake/LuaJITUtils.cmake | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/cmake/LuaJITUtils.cmake b/cmake/LuaJITUtils.cmake
> index d9f8b12a..3497edc4 100644
> --- a/cmake/LuaJITUtils.cmake
> +++ b/cmake/LuaJITUtils.cmake
> @@ -1,4 +1,12 @@
>  function(LuaJITTestArch outvar strflags)
> +  # XXX: This routine uses external headers (e.g. system ones),
> +  # which location is specified either implicitly (within CMake
> +  # machinery) or explicitly (manually by configuration options).
> +  # Need -isysroot flag on recentish MacOS after command line
> +  # tools no longer provide headers in /usr/include.
> +  if(CMAKE_OSX_SYSROOT)

Nit: This variable should be taken into account only for OS X
platforms [1]. I suppose not only by CMake, but by our build system too.

I've got the error on Linux if I try to build LuaJIT like the following
(by mistake of course):

| $ uname -s
| Linux
| $ cmake . -DCMAKE_OSX_SYSROOT="/tmp/blablabalblablbalalbla" -DLUA_USE_ASSERT=ON -DCMAKE_BUILD_TYPE=Debug
| In file included from lua.h:14,
|                  from lj_arch.h:9:
| /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory
|     9 | # include_next <stdint.h>
|       |                ^~~~~~~~~~
| compilation terminated.
| CMake Error at cmake/LuaJITUtils.cmake:48 (message):
|   [LuaJITArch] Unsupported target architecture
| Call Stack (most recent call first):
|   cmake/SetTargetFlags.cmake:16 (LuaJITArch)
|   src/CMakeLists.txt:17 (include)

> +    set(strflags "${strflags} -isysroot ${CMAKE_OSX_SYSROOT}")
> +  endif()
>    # 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.
> 
> ================================================================================
> 
> [1]: https://gitlab.kitware.com/cmake/cmake/-/blob/master/Source/cmLocalGenerator.cxx#L1911-1916
> [2]: https://gitlab.kitware.com/cmake/cmake/-/blob/master/Tests/FindPackageModeMakefileTest/CMakeLists.txt#L24-28
> 
> 
> -- 
> Best regards,
> IM

[1]: https://cmake.org/cmake/help/v3.0/variable/CMAKE_OSX_SYSROOT.html

-- 
Best regards,
Sergey Kaplun


More information about the Tarantool-patches mailing list