Apply H.J. Lu's patch to pass -mshstk to the compiler when Intel CET is

enabled. CMake version invented by PH, but only tested on non-CET system.
This commit is contained in:
Philip.Hazel 2020-05-25 16:03:24 +00:00
parent 768c7fe67e
commit e73119cbfa
4 changed files with 44 additions and 0 deletions

View File

@ -92,6 +92,7 @@
# library versioning. # library versioning.
# 2020-04-25 Carlo added function check for mkostemp used in ProtExecAllocator # 2020-04-25 Carlo added function check for mkostemp used in ProtExecAllocator
# 2020-04-28 PH added function check for memfd_create based on Carlo's patch # 2020-04-28 PH added function check for memfd_create based on Carlo's patch
# 2020-05-25 PH added a check for Intel CET
PROJECT(PCRE2 C) PROJECT(PCRE2 C)
@ -146,6 +147,24 @@ CHECK_C_SOURCE_COMPILES(
) )
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
# Check whether Intel CET is enabled, and if so, adjust compiler flags. This
# code was written by PH, trying to imitate the logic from the autotools
# configuration.
CHECK_C_SOURCE_COMPILES(
"#ifndef __CET__
#error CET is not enabled
#endif
int main() { return 0; }"
INTEL_CET_ENABLED
)
IF (INTEL_CET_ENABLED)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mshstk")
ENDIF(INTEL_CET_ENABLED)
# User-configurable options # User-configurable options
# #
# Note: CMakeSetup displays these in alphabetical order, regardless of # Note: CMakeSetup displays these in alphabetical order, regardless of

View File

@ -1,6 +1,15 @@
Change Log for PCRE2 Change Log for PCRE2
-------------------- --------------------
Version 10.36-RC1 25-May-2020
-----------------------------
1. Add CET_CFLAGS so that when Intel CET is enabled, pass -mshstk to
compiler. This fixes https://bugs.exim.org/show_bug.cgi?id=2578. Patch for
Makefile.am and configure.ac by H.J. Lu. Equivalent patch for CMakeLists.txt
invented by PH.
Version 10.35 09-May-2020 Version 10.35 09-May-2020
--------------------------- ---------------------------

View File

@ -391,6 +391,7 @@ nodist_libpcre2_8_la_SOURCES = \
libpcre2_8_la_CFLAGS = \ libpcre2_8_la_CFLAGS = \
-DPCRE2_CODE_UNIT_WIDTH=8 \ -DPCRE2_CODE_UNIT_WIDTH=8 \
$(VISIBILITY_CFLAGS) \ $(VISIBILITY_CFLAGS) \
$(CET_CFLAGS) \
$(AM_CFLAGS) $(AM_CFLAGS)
libpcre2_8_la_LIBADD = libpcre2_8_la_LIBADD =
endif # WITH_PCRE2_8 endif # WITH_PCRE2_8

View File

@ -1006,6 +1006,21 @@ fi # enable_coverage
AM_CONDITIONAL([WITH_GCOV],[test "x$enable_coverage" = "xyes"]) AM_CONDITIONAL([WITH_GCOV],[test "x$enable_coverage" = "xyes"])
AC_MSG_CHECKING([whether Intel CET is enabled])
AC_LANG_PUSH([C])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,
[[#ifndef __CET__
# error CET is not enabled
#endif]])],
[pcre2_cc_cv_intel_cet_enabled=yes],
[pcre2_cc_cv_intel_cet_enabled=no])
AC_MSG_RESULT([$pcre2_cc_cv_intel_cet_enabled])
if test "$pcre2_cc_cv_intel_cet_enabled" = yes; then
CET_CFLAGS="-mshstk"
AC_SUBST([CET_CFLAGS])
fi
AC_LANG_POP([C])
# Produce these files, in addition to config.h. # Produce these files, in addition to config.h.
AC_CONFIG_FILES( AC_CONFIG_FILES(
Makefile Makefile