From 349e74c06cd6be2705c7767f3c23935910fdadd4 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Thu, 28 Jul 2022 13:04:46 +0200 Subject: [PATCH] Move the check for -fPIC compile flag to qcompilerdetection.h Task-number: QTBUG-99313 Change-Id: I9072b73a75599381f5f2be0799bca5bf149122de Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 7 +++++++ src/corelib/global/qglobal.h | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 7dc3b61ccd..557b1ce0ad 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1203,4 +1203,11 @@ static_assert(!std::is_convertible_v, "On MSVC you must pass the /permissive- option to the compiler."); #endif +#if defined(QT_BOOTSTRAPPED) || defined(QT_USE_PROTECTED_VISIBILITY) || !defined(__ELF__) || defined(__PIC__) +// this is fine +#elif defined(QT_REDUCE_RELOCATIONS) +# error "You must build your code with position independent code if Qt was configured with -reduce-relocations. "\ + "Compile your code with -fPIC (and not with -fPIE)." +#endif + #endif // QCOMPILERDETECTION_H diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index f6a6013518..c24bb6e198 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1227,13 +1227,6 @@ Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nu #define QT_MODULE(x) -#if defined(QT_BOOTSTRAPPED) || defined(QT_USE_PROTECTED_VISIBILITY) || !defined(__ELF__) || defined(__PIC__) -// this is fine -#elif defined(QT_REDUCE_RELOCATIONS) -# error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\ - "Compile your code with -fPIC (and not with -fPIE)." -#endif - // This macro can be used to calculate member offsets for types with a non standard layout. // It uses the fact that offsetof() is allowed to support those types since C++17 as an optional // feature. All our compilers do support this, but some issue a warning, so we wrap the offsetof()