[Tarantool-patches] [V2] luajit: pass properly compile options to LuaJIT for RelWithDebInfo

Alexander Turenko alexander.turenko at tarantool.org
Tue Jul 28 17:03:51 MSK 2020


> -    set (luajit_cflags ${CMAKE_C_FLAGS})
> +    string (TOUPPER ${CMAKE_BUILD_TYPE} upper_build_type)
> +    set (c_flags_init "CMAKE_C_FLAGS_${upper_build_type}")
> +    set (luajit_cflags ${${c_flags_init}})

Debug:

-- CMAKE_C_FLAGS:  -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -fopenmp -msse2
-- CMAKE_C_FLAGS_DEBUG: -g -ggdb -O0

RelWithDebInfo:

-- CMAKE_C_FLAGS:  -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -fopenmp -msse2
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O2 -g -DNDEBUG -ggdb -O2

So all those -fno-omit-frame-pointer was applied to luajit and we should
proceed with each such option very carefully. For example, cite from
cmake/compiler.cmake:

 | #
 | # Set flags for all include files: those maintained by us and
 | # coming from third parties.
 | # Since we began using luajit, which uses gcc stack unwind
 | # internally, we also need to make sure all code is compiled
 | # with unwind info.
 | #
 | 
 | add_compile_flags("C;CXX" "-fexceptions" "-funwind-tables")
 | 
 | # We must set -fno-omit-frame-pointer here, since we rely
 | # on frame pointer when getting a backtrace, and it must
 | # be used consistently across all object files.
 | # The same reasoning applies to -fno-stack-protector switch.
 | 
 | if (ENABLE_BACKTRACE)
 |     add_compile_flags("C;CXX"
 |         "-fno-omit-frame-pointer"
 |         "-fno-stack-protector")
 | endif()

I would be okay to just enable '-g -ggdb' without changing base flags
from CMAKE_C_FLAGS to CMAKE_C_FLAGS_{DEBUG,RELWITHDEBINFO}, but see
below.

>      set (luajit_ldflags ${CMAKE_EXE_LINKER_FLAGS})
>      separate_arguments(luajit_cflags)
>      separate_arguments(luajit_ldflags)
> @@ -168,19 +170,12 @@ macro(luajit_build)
>              "-pagezero_size 10000 -image_base 100000000")
>      endif()
>  
> -    # We are consciously ommiting debug info in RelWithDebInfo mode

So there was a reason. I don't know it, but we should know if we want to
change it. Can it be related to performance?

I would ask Nick Zavaritsky if you really want to know. I searched over
commits and discussions that may be relevant, but didn't found anything.

I asked about this in [1].

[1]: https://github.com/tarantool/tarantool/issues/4827#issuecomment-665059210

WBR, Alexander Turenko.


More information about the Tarantool-patches mailing list