Skip to content

Commit

Permalink
Fix compilation of PCRE2 under Intel CET
Browse files Browse the repository at this point in the history
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.

Change-Id: I3440e689b81f4f07055f211a4fa7331a43eb410d
Reviewed-by: Thiago Macieira <[email protected]>
(cherry picked from commit 7c8c827)
(cherry picked from commit fa98adb)
  • Loading branch information
dangelog committed Jun 1, 2020
1 parent 4de8dd5 commit 61fb227
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions configure.json
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,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"
]
}
}
},

Expand Down Expand Up @@ -1412,6 +1423,11 @@
"autoDetect": "features.shared",
"condition": "features.dlopen || config.win32 || !features.shared",
"output": [ "privateFeature" ]
},
"intelcet": {
"label": "Using Intel CET",
"condition": "tests.intelcet",
"output": [ "privateFeature" ]
}
},

Expand Down
2 changes: 2 additions & 0 deletions mkspecs/common/gcc-base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 +=
Expand Down
5 changes: 5 additions & 0 deletions src/3rdparty/pcre2/pcre2.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ load(qt_helper_lib)

DEFINES += HAVE_CONFIG_H

qtConfig(intelcet) {
QMAKE_CFLAGS += $$QMAKE_CFLAGS_SHSTK
QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_SHSTK
}

# platform/compiler specific definitions
uikit|qnx|winrt: DEFINES += PCRE2_DISABLE_JIT
win32:contains(QT_ARCH, "arm"): DEFINES += PCRE2_DISABLE_JIT
Expand Down

0 comments on commit 61fb227

Please sign in to comment.