[Development] Qt 4.x and Qt 5 frameworks should use @rpath (QTBUG-31814)

Adam Strzelecki ono at java.pl
Fri Aug 1 17:13:43 CEST 2014


Hello,

Since 5.4 feature freeze is going to happen soon, I want to escalate long standing problem described in QTBUG-31814.

Long story short, Qt is using some nasty install prefix padding and dylib rewrite (via install_name_tool) during Qt SDK install to handle user defined Qt SDK frameworks placement. This might be OK if we were in 2005 using OSX 10.4, but since 10.5 there is @rpath that makes whole process far less complicated.

Therefore there is absolutely no need for:

(1) MAKE_INSTALL_PADDING in qtsdk/packaging-tools/build_wrapper.py anyway dylibs are padded with -headerpad_max_install_names

(2) no need for MacReplaceInstallNamesOperation::relocateBinary(..) in installer-framework

(3) no need for similar relocation in macqtdeploy script, this would be especially useful in future when OSX uses ZFS's COW (no idea if HFS does already COW at block level when copying)

All we need to do is build all Qt dylibs with install_name = @rpath/pathrelative_to_lib_folder/some.dylib and make sure qmake adds following linker flags to all apps linking to Qt:

-Wl,-rpath, at loader_path/../Frameworks
-Wl,-rpath, at executable_path/../Frameworks
-Wl,-rpath,/absolute/path/to/dev/Qt/Frameworks

Then macdeployqt is just about removing last rpath from binary, leaving only these relative. No need to touch ever libraries once they are built.

This also makes whole SDK process installation pure copy process.

I am willing to help but this has to be changed in several projects qtsdk, installer-framework, qtbase (Qmake) in order to make it work.



Here is proposal for change in Qmake:

(1) adding QMAKE_RPATHPREFIX variable specyfying list of path prefixes that will be replaced by @rpath when linking OSX library, by default this will contain Qt SDK lib/ dir

(2) adding @rpath replacement in UnixMakefileGenerator::init2() before:

project->values("QMAKE_LFLAGS_SONAME").first() += escapeFilePath(soname);

Where prefix from QMAKE_RPATHPREFIX found in soname is replaced by "@rpath"



Once this is done qtbase Qmake project should define QMAKE_RPATHPREFIX to be Qt SDK install_prefix/lib during build process.


WDYT?

Regards,
-- 
Adam Strzelecki




More information about the Development mailing list