qt5base-lts/mkspecs
Thiago Macieira 19b7f854a2 Enable -mno-direct-extern-access and ELF protected visibility
The -mno-direct-extern-access tells the compiler and linker that
references to symbols outside this ELF module mustn't be direct and must
instead always go through the GOT or PLT (the PLT can additionally be
disabled with -fno-plt). The ELF protected visibility tells the compiler
and linker that this symbol is present in the dynamic symbol table as an
export, but it cannot be interposed by another ELF module.

This option is required for user code to link properly to Qt, otherwise
they will get linker errors (assuming GNU binutils >= 2.39) or runtime
failures (glibc >= 2.35). Both versions of glibc and binutils are older
than GCC 12, so it's a safe assumption they are in use and downgrading
the toolchain or libc is not supported. Adding this option to the
compilation is assured for CMake and qmake-based projects.

For example, all accessess to QCoreApplication::self in QtCore, after
this change and with GCC 12 are relocation-free and direct:

000000000013ebf0 <QCoreApplicationPrivate::checkInstance(char const*)>:
  13ebf0:       cmpq   $0x0,0x4f73d0(%rip)        # 635fc8 <QCoreApplication::self>
  13ebf8:       setne  %al
  13ebfb:       je     a90fe <QCoreApplicationPrivate::checkInstance(char const*) [clone .cold]>
  13ec01:       ret

Meanwhile, accesses to the same variable in other modules are indirect
via the GOT:

   66650:       mov    0x876e1(%rip),%rax        # edd38 <QCoreApplication::self@Qt_6>
   66657:       cmpq   $0x0,(%rax)

This replaces the -Bsymbolic and -Bsymbolic-functions (broken)
functionality that Qt has been using or attempting to use since ~2006.

See https://gitlab.com/x86-psABIs/x86-64-ABI/-/issues/8#note_606975128

Change-Id: Iad4b0a3e5c06570b9f5f571b26ed564aa0811e47
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-03-10 17:10:57 -08:00
..
aix-g++ Updated license headers 2016-01-15 12:25:24 +00:00
aix-g++-64 Updated license headers 2016-01-15 12:25:24 +00:00
android-clang Update Android default SDK from 29 to 30 2021-08-27 18:31:17 +00:00
common Enable -mno-direct-extern-access and ELF protected visibility 2022-03-10 17:10:57 -08:00
cygwin-g++ QtBase: replace windows.h with qt_windows.h 2021-11-23 12:53:46 +08:00
darwin-g++ Stop including net/if.h from qplatformdefs.h 2017-10-08 06:41:24 +00:00
devices Check QMake support for building apps on INTEGRITY 2021-08-26 19:32:44 +03:00
dummy move all target spec handling to qmake-based configure system 2016-12-13 18:56:34 +00:00
features Enable -mno-direct-extern-access and ELF protected visibility 2022-03-10 17:10:57 -08:00
freebsd-clang make mkspecs not mess up library and include search paths 2017-05-31 12:57:09 +00:00
freebsd-g++ make mkspecs not mess up library and include search paths 2017-05-31 12:57:09 +00:00
haiku-g++ Stop including net/if.h from qplatformdefs.h 2017-10-08 06:41:24 +00:00
hpuxi-g++-64 Stop including net/if.h from qplatformdefs.h 2017-10-08 06:41:24 +00:00
hurd-g++ Hurd: enable XOPEN largefile APIs 2022-02-10 01:41:23 +01:00
integrity-armv7 integrity: don't mess with QTPLUGIN.platforms 2018-11-21 23:08:10 +00:00
integrity-armv7-imx6 integrity: don't mess with QTPLUGIN.platforms 2018-11-21 23:08:10 +00:00
integrity-armv8-rcar integrity: don't mess with QTPLUGIN.platforms 2018-11-21 23:08:10 +00:00
integrity-x86 integrity: don't mess with QTPLUGIN.platforms 2018-11-21 23:08:10 +00:00
linux-aarch64-gnu-g++ Add new mkspec for cross-compiling Qt5 for AArch64 2017-03-31 00:34:48 +00:00
linux-arm-gnueabi-g++ Updated license headers 2016-01-15 12:25:24 +00:00
linux-clang Remove checks for glibc < 2 from qplatformdefs.h files 2020-04-23 06:41:32 +02:00
linux-clang-32 add mkspecs for linux clang 32 2018-08-31 05:34:46 +00:00
linux-clang-libc++ Updated license headers 2016-01-15 12:25:24 +00:00
linux-clang-libc++-32 add mkspecs for linux clang 32 2018-08-31 05:34:46 +00:00
linux-g++ Remove checks for glibc < 2 from qplatformdefs.h files 2020-04-23 06:41:32 +02:00
linux-g++-32 Updated license headers 2016-01-15 12:25:24 +00:00
linux-g++-64 Updated license headers 2016-01-15 12:25:24 +00:00
linux-icc qmake: Stop using -isystem flag 2020-06-06 09:53:59 +00:00
linux-icc-32 Updated license headers 2016-01-15 12:25:24 +00:00
linux-icc-64 Updated license headers 2016-01-15 12:25:24 +00:00
linux-icc-k1om linux-icc-k1om build 2017-02-21 14:27:16 +00:00
linux-llvm Remove checks for glibc < 2 from qplatformdefs.h files 2020-04-23 06:41:32 +02:00
linux-lsb-g++ Remove checks for glibc < 2 from qplatformdefs.h files 2020-04-23 06:41:32 +02:00
lynxos-g++ Remove checks for glibc < 2 from qplatformdefs.h files 2020-04-23 06:41:32 +02:00
macx-clang Remove -qt-xcb, -system-xcb from README and comments 2020-05-19 06:42:35 +00:00
macx-g++ Remove CFBundleGetInfoString from Info.plist templates 2019-10-04 13:09:34 +00:00
macx-icc Remove CFBundleGetInfoString from Info.plist templates 2019-10-04 13:09:34 +00:00
macx-ios-clang Bump Apple platform minimum versions 2021-03-10 23:39:45 +01:00
macx-tvos-clang Bump Apple platform minimum versions 2021-03-10 23:39:45 +01:00
macx-watchos-clang Bump Apple platform minimum versions 2021-03-10 23:39:45 +01:00
macx-xcode qmake: Switch to using Xcode's new build system 2021-06-08 17:28:47 +02:00
modules Adjust wiki links to the new redirect 2015-03-04 15:36:12 +00:00
netbsd-g++ make mkspecs not mess up library and include search paths 2017-05-31 12:57:09 +00:00
openbsd-g++ make mkspecs not mess up library and include search paths 2017-05-31 12:57:09 +00:00
qnx-aarch64le-qcc Enable stack-protector-strong for QNX 7.0.0 2017-06-13 14:01:24 +00:00
qnx-armle-v7-qcc Convert the old feature system 2016-09-15 08:24:10 +00:00
qnx-x86-64-qcc Enable stack-protector-strong for QNX 7.0.0 2017-06-13 14:01:24 +00:00
qnx-x86-qcc Convert the old feature system 2016-09-15 08:24:10 +00:00
solaris-cc Stop including net/if.h from qplatformdefs.h 2017-10-08 06:41:24 +00:00
solaris-cc-64 Stop including net/if.h from qplatformdefs.h 2017-10-08 06:41:24 +00:00
solaris-cc-64-stlport Updated license headers 2016-01-15 12:25:24 +00:00
solaris-cc-stlport Updated license headers 2016-01-15 12:25:24 +00:00
solaris-g++ Stop including net/if.h from qplatformdefs.h 2017-10-08 06:41:24 +00:00
solaris-g++-64 Stop including net/if.h from qplatformdefs.h 2017-10-08 06:41:24 +00:00
unsupported Cleanup leftover QWS 2021-04-14 13:00:12 +09:00
wasm-emscripten qmake: Enforce linker response files for WebAssembly on Windows 2022-02-21 12:37:19 +01:00
win32-arm64-msvc rename win32-arm64-msvc2017 to win32-arm64-msvc 2020-10-09 08:06:29 +02:00
win32-clang-g++ Clang: use -Oz instead of -O1 to optimize for size 2019-03-21 23:46:32 +00:00
win32-clang-msvc QRandom: add support for RDSEED 2019-10-09 07:31:28 -07:00
win32-g++ QDateTime: fix build with MinGW: need unistd.h very early 2021-09-29 13:18:21 -07:00
win32-icc Add new AVX512 extensions found in Intel CLX, ICL and ICX processors 2020-02-03 11:31:49 -07:00
win32-icc-k1om linux-icc-k1om build 2017-02-21 14:27:16 +00:00
win32-msvc unify windows mkspecs: define c++ flags explicitly 2018-02-22 18:45:15 +00:00