From fa98adbd04de9d44ce921436b92589a41f285dcd Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 25 May 2020 18:53:31 +0200 Subject: [PATCH] Fix compilation of PCRE2 under Intel CET Ubuntu 20.04 enables -fcf-protection by default. PCRE2 10.35 sees this but complains that -mshstk is also necessary to build its JIT. Detect whether the compiler is enabling Intel CET automatically, and if so, build PCRE2 with the right options. Pick-to: 5.15 Change-Id: I3440e689b81f4f07055f211a4fa7331a43eb410d Reviewed-by: Thiago Macieira --- configure.json | 16 ++++++++++++++++ mkspecs/common/gcc-base.conf | 2 ++ src/3rdparty/pcre2/pcre2.pri | 5 +++++ 3 files changed, 23 insertions(+) diff --git a/configure.json b/configure.json index 6d1385dafe..c174b45262 100644 --- a/configure.json +++ b/configure.json @@ -635,6 +635,17 @@ "label": "ccache", "type": "files", "files": [ "ccache" ] + }, + "intelcet": { + "label": "Support for Intel Control-flow Enforcement Technology", + "type": "compile", + "test": { + "main": [ + "#if !defined(__CET__)", + "# error Intel CET not available", + "#endif" + ] + } } }, @@ -1401,6 +1412,11 @@ "autoDetect": "features.shared", "condition": "features.dlopen || config.win32 || !features.shared", "output": [ "privateFeature" ] + }, + "intelcet": { + "label": "Using Intel CET", + "condition": "tests.intelcet", + "output": [ "privateFeature" ] } }, diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf index 1f919d270a..3c2d5fdd53 100644 --- a/mkspecs/common/gcc-base.conf +++ b/mkspecs/common/gcc-base.conf @@ -54,6 +54,7 @@ QMAKE_CFLAGS_SPLIT_SECTIONS += -ffunction-sections -fdata-sections QMAKE_CFLAGS_LTCG = -flto -fno-fat-lto-objects QMAKE_CFLAGS_LTCG_FATOBJECTS = -ffat-lto-objects QMAKE_CFLAGS_DISABLE_LTCG = -fno-lto +QMAKE_CFLAGS_SHSTK = -mshstk QMAKE_CXXFLAGS += $$QMAKE_CFLAGS QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS @@ -74,6 +75,7 @@ QMAKE_CXXFLAGS_SPLIT_SECTIONS += $$QMAKE_CFLAGS_SPLIT_SECTIONS QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG QMAKE_CXXFLAGS_LTCG_FATOBJECTS = $$QMAKE_CFLAGS_LTCG_FATOBJECTS QMAKE_CXXFLAGS_DISABLE_LTCG = $$QMAKE_CFLAGS_DISABLE_LTCG +QMAKE_CXXFLAGS_SHSTK = $$QMAKE_CFLAGS_SHSTK QMAKE_LFLAGS += QMAKE_LFLAGS_DEBUG += diff --git a/src/3rdparty/pcre2/pcre2.pri b/src/3rdparty/pcre2/pcre2.pri index fa901f783f..b11ec7302a 100644 --- a/src/3rdparty/pcre2/pcre2.pri +++ b/src/3rdparty/pcre2/pcre2.pri @@ -5,6 +5,11 @@ win32: MODULE_DEFINES += PCRE2_STATIC DEFINES += HAVE_CONFIG_H +qtConfig(intelcet) { + QMAKE_CFLAGS += QMAKE_CFLAGS_SHSTK + QMAKE_CXXFLAGS += QMAKE_CXXFLAGS_SHSTK +} + SOURCES += \ $$PWD/src/pcre2_auto_possess.c \ $$PWD/src/pcre2_chartables.c \