tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Qt5 issues in LXQt from wip



On Mon, 20 Apr 2015 00:04:45 +0200
"Kamil Rytarowski" <n54%gmx.com@localhost> wrote:

> Regarding PIE, what's your platform?
> I read that qt5 sources compiled with `-reduce-relocations' require
> `-fPIE'.
> 
> #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 or
> -fPIE." #endif
> 
> -- from ${PREFIX}/qt5/include/QtCore/qglobal.h

My platform is NetBSD 6.1.5 with native gcc (4.5.3).
And yes, your observation is correct. The problem is that PIE is only to
be used by executables[1]. In some cases(liblxqt, lxqt-config) PIE is to
build the objects that are included in the shared libraries and it
leads to error messages like this:
Linking CXX shared library liblxqt.so
ld: CMakeFiles/lxqt.dir/lxqtplugininfo.cpp.o: relocation R_X86_64_PC32
against symbol `_ZN4LxQt10PluginInfo4loadERK7QString' can not be used
when making a shared object; recompile with -fPIC ld: final link
failed: Bad value

When set(Qt5_EXECUTABLE_COMPILE_FLAG "-fPIE") is commented out in
Qt5CoreConfigExtras.cmake everything works as expected,
PIC is used for shared libraries and PIE is used for the executables.
I think qt5 sets CMAKE_POSITION_INDEPENDENT_CODE[2] to TRUE and then
cmake handles the rest. 
I am considering to patch qt5-qtbase to comment out
set(Qt5_EXECUTABLE_COMPILE_FLAG "-fPIE") to fix this
but I wonder if this impacts other things.

Regards,
 Niclas

1.https://gcc.gnu.org/onlinedocs/gcc-4.8.4/gcc/Code-Gen-Options.html#index-fPIC-2392
2.http://www.cmake.org/cmake/help/v3.2/variable/CMAKE_POSITION_INDEPENDENT_CODE.html


Home | Main Index | Thread Index | Old Index