Skip to content

Commit

Permalink
Make qglobal.h complain if you use -fPIE
Browse files Browse the repository at this point in the history
Prior to Qt 5.4.2 (commit 36d6eb7), we
allowed it, but now we need to enforce that it is not used. Note that
-fPIE does define __PIC__, so we need this to catch the use of -fPIE.

[ChangeLog][Important Behavior Changes] On x86 and x86-64 systems with
ELF binaries (especially Linux), due to a new optimization in GCC 5.x in
combination with a recent version of GNU binutils, compiling Qt
applications with -fPIE is no longer enough. Applications now need to be
compiled with the -fPIC option if Qt's option "reduce relocations" is
active. Note that Clang is known to generate incompatible code even with
-fPIC if the -flto option is active.

Task-number: QTBUG-45755
Change-Id: I66a35ce5f88941f29aa6ffff13dd210e0aa2728f
Reviewed-by: Dmitry Shachnev <[email protected]>
Reviewed-by: Simon Hausmann <[email protected]>
  • Loading branch information
thiagomacieira authored and Simon Hausmann committed May 13, 2015
1 parent 3a72662 commit 3eca75d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions dist/changes-5.4.2
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ information about a particular change.
common EXIF-format (big-endian) was not working until 5.4.1. 5.4.2 restores the
behavior of 5.4.0 and earlier for most EXIF-tagged JPEGs.
EXIF orientation will be an opt-in starting with Qt 5.5.
- On x86 and x86-64 systems with ELF binaries (especially Linux), due to
a new optimization in GCC 5.x in combination with a recent version of
GNU binutils, compiling Qt applications with -fPIE is no longer
enough. Applications now need to be compiled with the -fPIC option if
Qt's option "reduce relocations" is active. Note that Clang is known
to generate incompatible code even with -fPIC if the -flto option is
active.

****************************************************************************
* Library *
Expand Down
4 changes: 2 additions & 2 deletions src/corelib/global/qglobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1047,9 +1047,9 @@ Q_CORE_EXPORT int qrand();
# define QT_NO_SHAREDMEMORY
#endif

#if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && !defined(__PIC__)
#if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && (!defined(__PIC__) || defined(__PIE__))
# error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\
"Compile your code with -fPIC."
"Compile your code with -fPIC (-fPIE is not enough)."
#endif

namespace QtPrivate {
Expand Down

0 comments on commit 3eca75d

Please sign in to comment.