Try to ensure that -fPIC is used in CMake builds (QTBUG-45755)

This commit is contained in:
Rex Dieter 2015-05-16 23:43:45 -05:00
parent 656fd93b8c
commit 30b6c96916
3 changed files with 89 additions and 2 deletions

View File

@ -0,0 +1,45 @@
From 3eca75de67b3fd2c890715b30c7899cebc096fe9 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@intel.com>
Date: Mon, 11 May 2015 18:30:00 +0900
Subject: [PATCH 260/262] Make qglobal.h complain if you use -fPIE
Prior to Qt 5.4.2 (commit 36d6eb721e7d5997ade75e289d4088dc48678d0d), 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 <mitya57@gmail.com>
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
---
dist/changes-5.4.2 | 7 +++++++
src/corelib/global/qglobal.h | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index ef84662..4547877 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -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 {
--
2.4.1

View File

@ -0,0 +1,34 @@
From 083c9269ed73e8771e1dbe10812696b45b7389f3 Mon Sep 17 00:00:00 2001
From: Evangelos Foutras <evangelos@foutrelis.com>
Date: Mon, 11 May 2015 12:20:57 +0300
Subject: [PATCH 262/262] Try to ensure that -fPIC is used in CMake builds
In commit 36d6eb721e7d5997ade75e289d4088dc48678d0d the -fPIE switch was
replaced with -fPIC in an effort to avoid generating copy relocations
which are incompatible with Qt5 when built with -reduce-relocations.
Task-number: QTBUG-45755
Change-Id: I59a55ea15052f498104848c5fd867e563ddc2290
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
---
src/corelib/Qt5CoreConfigExtras.cmake.in | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 48d5f21..d4abc5f 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -70,8 +70,9 @@ set(_qt5_corelib_extra_includes)
# Qt5_POSITION_INDEPENDENT_CODE variable is used in the # qt5_use_module
# macro to add it.
set(Qt5_POSITION_INDEPENDENT_CODE True)
-set_property(TARGET Qt5::Core PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\")
set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIC\")
+set_property(TARGET Qt5::Core PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\")
+set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_OPTIONS ${Qt5Core_EXECUTABLE_COMPILE_FLAGS})
!!IF !isEmpty(QT_NAMESPACE)
list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE)
--
2.4.1

View File

@ -37,7 +37,7 @@
Summary: Qt5 - QtBase components
Name: qt5-qtbase
Version: 5.4.1
Release: 16%{?dist}
Release: 17%{?dist}
# See LGPL_EXCEPTIONS.txt, for exception details
License: LGPLv2 with exceptions or GPLv3 with exceptions
@ -112,6 +112,9 @@ Patch336: 0136-Make-sure-there-s-a-scene-before-using-it.patch
Patch440: 0240-QLockFile-fix-deadlock-when-the-lock-file-is-corrupt.patch
Patch448: 0248-QNAM-Fix-upload-corruptions-when-server-closes-conne.patch
Patch460: 0260-Require-fPIC-instead-of-just-fPIE-for-reduce-relocat.patch
# from 5.4.2 branch
Patch461: 0260-Make-qglobal.h-complain-if-you-use-fPIE.patch
Patch462: 0262-Try-to-ensure-that-fPIC-is-used-in-CMake-builds.patch
# http://lists.qt-project.org/pipermail/announce/2015-February/000059.html
# CVE-2015-0295
@ -391,6 +394,8 @@ rm -fv mkspecs/linux-g++*/qmake.conf.multilib-optflags
%patch440 -p1 -b .0240
%patch448 -p1 -b .0248
%patch460 -p1 -b .0260
%patch461 -p1 -b .0260-2
%patch462 -p1 -b .0262
# drop -fexceptions from $RPM_OPT_FLAGS
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS | sed 's|-fexceptions||g'`
@ -913,8 +918,11 @@ fi
%changelog
* Sat May 16 2015 Rex Dieter <rdieter@fedoraproject.org> 5.4.1-17
- Try to ensure that -fPIC is used in CMake builds (QTBUG-45755)
* Thu May 14 2015 Rex Dieter <rdieter@fedoraproject.org> 5.4.1-16
- Some Qt apps crashs if they are compiled with gcc5 (QTBUG-45755)
- Some Qt apps crash if they are compiled with gcc5 (QTBUG-45755)
* Thu May 07 2015 Rex Dieter <rdieter@fedoraproject.org> 5.4.1-15
- try harder to avoid doc/multilib conflicts (#1212750)