MDEV-13412 main.func_regexp_pcre fails in buildbot on ppc64le
Caused by 2fcd8c12522. It used the documented pcre API
-pcre_exec(NULL, NULL, NULL, -999, -999, 0, NULL, 0)
to calculate the pcre stack frame size. Unfortunately, modern compilers
broke it by cloning and inlining pcre match() function. 2fcd8c12522
tried to workaround it by setting the stack frame size to at least 500.
It didn't work, 500 is not a universal constant.
Now we fix our copy of pcre to not inline or clone match() - so that
stack frame detection would work again - and detect at cmake time
whether system pcre is broken or usable.
Also use stack, not (much slower) malloc in bundled pcre, unless on Windows
2017-10-05 15:01:38 +02:00
|
|
|
INCLUDE (CheckCSourceRuns)
|
|
|
|
|
2014-03-04 01:22:53 +01:00
|
|
|
SET(WITH_PCRE "auto" CACHE STRING
|
|
|
|
"Which pcre to use (possible values are 'bundled', 'system', or 'auto')")
|
|
|
|
|
|
|
|
MACRO (CHECK_PCRE)
|
|
|
|
IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto")
|
MDEV-13412 main.func_regexp_pcre fails in buildbot on ppc64le
Caused by 2fcd8c12522. It used the documented pcre API
-pcre_exec(NULL, NULL, NULL, -999, -999, 0, NULL, 0)
to calculate the pcre stack frame size. Unfortunately, modern compilers
broke it by cloning and inlining pcre match() function. 2fcd8c12522
tried to workaround it by setting the stack frame size to at least 500.
It didn't work, 500 is not a universal constant.
Now we fix our copy of pcre to not inline or clone match() - so that
stack frame detection would work again - and detect at cmake time
whether system pcre is broken or usable.
Also use stack, not (much slower) malloc in bundled pcre, unless on Windows
2017-10-05 15:01:38 +02:00
|
|
|
CHECK_LIBRARY_EXISTS(pcre pcre_stack_guard "" HAVE_PCRE_STACK_GUARD)
|
|
|
|
IF(NOT CMAKE_CROSSCOMPILING)
|
|
|
|
SET(CMAKE_REQUIRED_LIBRARIES "pcre")
|
|
|
|
CHECK_C_SOURCE_RUNS("
|
|
|
|
#include <pcre.h>
|
|
|
|
int main() {
|
|
|
|
return -pcre_exec(NULL, NULL, NULL, -999, -999, 0, NULL, 0) < 256;
|
|
|
|
}" PCRE_STACK_SIZE_OK)
|
|
|
|
SET(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
ENDIF()
|
2014-03-04 01:22:53 +01:00
|
|
|
ENDIF()
|
MDEV-13412 main.func_regexp_pcre fails in buildbot on ppc64le
Caused by 2fcd8c12522. It used the documented pcre API
-pcre_exec(NULL, NULL, NULL, -999, -999, 0, NULL, 0)
to calculate the pcre stack frame size. Unfortunately, modern compilers
broke it by cloning and inlining pcre match() function. 2fcd8c12522
tried to workaround it by setting the stack frame size to at least 500.
It didn't work, 500 is not a universal constant.
Now we fix our copy of pcre to not inline or clone match() - so that
stack frame detection would work again - and detect at cmake time
whether system pcre is broken or usable.
Also use stack, not (much slower) malloc in bundled pcre, unless on Windows
2017-10-05 15:01:38 +02:00
|
|
|
IF(NOT HAVE_PCRE_STACK_GUARD OR NOT PCRE_STACK_SIZE_OK OR
|
|
|
|
WITH_PCRE STREQUAL "bundled")
|
2014-03-04 01:22:53 +01:00
|
|
|
IF (WITH_PCRE STREQUAL "system")
|
|
|
|
MESSAGE(FATAL_ERROR "system pcre is not found or unusable")
|
|
|
|
ENDIF()
|
|
|
|
SET(PCRE_INCLUDES ${CMAKE_BINARY_DIR}/pcre ${CMAKE_SOURCE_DIR}/pcre)
|
|
|
|
ADD_SUBDIRECTORY(pcre)
|
|
|
|
ENDIF()
|
|
|
|
ENDMACRO()
|
|
|
|
|