Skip to content

Commit c20f09d

Browse files
committed
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>]
1 parent 8a32ae5 commit c20f09d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cmake/dtrace.cmake

+8-4
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,20 @@ FUNCTION(DTRACE_INSTRUMENT target)
125125
WORKING_DIRECTORY ${objdir}
126126
)
127127
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
128-
# dtrace on Linux runs gcc and uses flags from environment
129-
SET(CFLAGS_SAVED $ENV{CFLAGS})
130-
SET(ENV{CFLAGS} ${CMAKE_C_FLAGS})
128+
IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
129+
# dtrace on Linux runs gcc and uses flags from environment
130+
SET(CFLAGS_SAVED $ENV{CFLAGS})
131+
SET(ENV{CFLAGS} ${CMAKE_C_FLAGS})
132+
ENDIF()
131133
SET(outfile "${CMAKE_BINARY_DIR}/probes_mysql.o")
132134
# Systemtap object
133135
EXECUTE_PROCESS(
134136
COMMAND ${DTRACE} -G -s ${CMAKE_SOURCE_DIR}/include/probes_mysql.d.base
135137
-o ${outfile}
136138
)
137-
SET(ENV{CFLAGS} ${CFLAGS_SAVED})
139+
IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
140+
SET(ENV{CFLAGS} ${CFLAGS_SAVED})
141+
ENDIF()
138142
ENDIF()
139143

140144
# Do not try to extend the library if we have not built the .o file

0 commit comments

Comments
 (0)