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 <thiago.macieira@intel.com>
This commit is contained in:
Giuseppe D'Angelo 2020-05-25 18:53:31 +02:00
parent 9c31acbf47
commit fa98adbd04
3 changed files with 23 additions and 0 deletions

View File

@ -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" ]
}
},

View File

@ -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 +=

View File

@ -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 \