Dtrace cmake fix for clang

When there are GCC-incompatible compiler flags dtrace fails like this:

gcc: error: unrecognized command-line option ‘-fno-limit-debug-info’
gcc: error: unrecognized command-line option ‘-mbranches-within-32B-boundaries’
"gcc .dtrace-temp.3fd6bacf.c" failed
Usage /usr/bin/dtrace [--help] [-h | -G] [-C [-I<Path>]] -s File.d [-o <File>]
This commit is contained in:
Aleksey Midenkov 2024-12-03 13:49:42 +03:00
parent 8a32ae5d6d
commit c20f09ddcf

View file

@ -125,16 +125,20 @@ FUNCTION(DTRACE_INSTRUMENT target)
WORKING_DIRECTORY ${objdir}
)
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
# dtrace on Linux runs gcc and uses flags from environment
SET(CFLAGS_SAVED $ENV{CFLAGS})
SET(ENV{CFLAGS} ${CMAKE_C_FLAGS})
IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# dtrace on Linux runs gcc and uses flags from environment
SET(CFLAGS_SAVED $ENV{CFLAGS})
SET(ENV{CFLAGS} ${CMAKE_C_FLAGS})
ENDIF()
SET(outfile "${CMAKE_BINARY_DIR}/probes_mysql.o")
# Systemtap object
EXECUTE_PROCESS(
COMMAND ${DTRACE} -G -s ${CMAKE_SOURCE_DIR}/include/probes_mysql.d.base
-o ${outfile}
)
SET(ENV{CFLAGS} ${CFLAGS_SAVED})
IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
SET(ENV{CFLAGS} ${CFLAGS_SAVED})
ENDIF()
ENDIF()
# Do not try to extend the library if we have not built the .o file