From 67a24c260b910c5ada1c8c266c6d1bed9d8c5a04 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 22 Apr 2015 13:09:36 +0200 Subject: [PATCH] rpath: use new DTAGS if available this allows LD_LIBRARY_PATH to take precedence over the hard-coded rpath, which is the only sane thing to do (which is also why i'm not adding an option to disable it). this behavior is consistent with non-linux systems. the windows version has no auto-detection, just like for gold linker usage. Task-number: QTBUG-3069 Change-Id: Ief9ba032291c898d75d76ecc740390954382a804 Reviewed-by: Simon Hausmann --- configure | 10 ++++++++++ mkspecs/common/gcc-base-unix.conf | 1 + mkspecs/features/default_post.prf | 1 + tools/configure/configureapp.cpp | 12 ++++++++++++ 4 files changed, 24 insertions(+) diff --git a/configure b/configure index 6b59a888d4..8116d731e2 100755 --- a/configure +++ b/configure @@ -728,6 +728,7 @@ CFG_EVENTFD=auto CFG_RPATH=yes CFG_FRAMEWORK=auto CFG_USE_GOLD_LINKER=auto +CFG_ENABLE_NEW_DTAGS=auto DEFINES= INCLUDES= D_FLAGS= @@ -3442,6 +3443,13 @@ if [ "$CFG_USE_GOLD_LINKER" != "no" ]; then fi fi +# auto-detect --enable-new-dtags support +if linkerSupportsFlag $TEST_COMPILER --enable-new-dtags; then + CFG_ENABLE_NEW_DTAGS=yes +else + CFG_ENABLE_NEW_DTAGS=no +fi + # auto-detect -fstack-protector-strong support (for QNX only currently) if [ "$XPLATFORM_QNX" = "yes" ]; then if compilerSupportsFlag $TEST_COMPILER -fstack-protector-strong; then @@ -6067,6 +6075,7 @@ fi [ "$CFG_STRIP" = "no" ] && QMAKE_CONFIG="$QMAKE_CONFIG nostrip" [ "$CFG_PRECOMPILE" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG precompile_header" [ "$CFG_USE_GOLD_LINKER" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG use_gold_linker" +[ "$CFG_ENABLE_NEW_DTAGS" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG enable_new_dtags" if [ "$CFG_SEPARATE_DEBUG_INFO" = "yes" ]; then QT_CONFIG="$QT_CONFIG separate_debug_info" fi @@ -6980,6 +6989,7 @@ unset build_mode release echo " Using sanitizer(s)...... $CFG_SANITIZERS" echo " Using C++11 ............ $CFG_CXX11" echo " Using gold linker....... $CFG_USE_GOLD_LINKER" +echo " Using new DTAGS ........ $CFG_ENABLE_NEW_DTAGS" echo " Using PCH .............. $CFG_PRECOMPILE" echo " Target compiler supports:" if [ "$CFG_ARCH" = "i386" -o "$CFG_ARCH" = "x86_64" ]; then diff --git a/mkspecs/common/gcc-base-unix.conf b/mkspecs/common/gcc-base-unix.conf index 29e0521927..f82c8a8430 100644 --- a/mkspecs/common/gcc-base-unix.conf +++ b/mkspecs/common/gcc-base-unix.conf @@ -16,6 +16,7 @@ QMAKE_LFLAGS_SONAME += -Wl,-soname, QMAKE_LFLAGS_THREAD += QMAKE_LFLAGS_RPATH = -Wl,-rpath, QMAKE_LFLAGS_RPATHLINK = -Wl,-rpath-link, +QMAKE_LFLAGS_NEW_DTAGS = -Wl,--enable-new-dtags QMAKE_LFLAGS_USE_GOLD = -fuse-ld=gold # -Bsymbolic-functions (ld) support diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index e967399258..8e68b95dd5 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -63,6 +63,7 @@ debug { } use_gold_linker: QMAKE_LFLAGS += $$QMAKE_LFLAGS_USE_GOLD +enable_new_dtags: QMAKE_LFLAGS += $$QMAKE_LFLAGS_NEW_DTAGS dll:win32: QMAKE_LFLAGS += $$QMAKE_LFLAGS_DLL static:mac: QMAKE_LFLAGS += $$QMAKE_LFLAGS_STATIC_LIB diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index c0e98507c7..8ea5b2ed3b 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -244,6 +244,8 @@ Configure::Configure(int& argc, char** argv) dictionary[ "USE_GOLD_LINKER" ] = "no"; + dictionary[ "ENABLE_NEW_DTAGS" ] = "no"; + dictionary[ "SHARED" ] = "yes"; dictionary[ "STATIC_RUNTIME" ] = "no"; @@ -471,6 +473,10 @@ void Configure::parseCmdLine() dictionary[ "USE_GOLD_LINKER" ] = "yes"; else if (configCmdLine.at(i) == "-no-use-gold-linker") dictionary[ "USE_GOLD_LINKER" ] = "no"; + else if (configCmdLine.at(i) == "-enable-new-dtags") + dictionary[ "ENABLE_NEW_DTAGS" ] = "yes"; + else if (configCmdLine.at(i) == "-disable-new-dtags") + dictionary[ "ENABLE_NEW_DTAGS" ] = "no"; else if (configCmdLine.at(i) == "-shared") dictionary[ "SHARED" ] = "yes"; else if (configCmdLine.at(i) == "-static") @@ -1793,6 +1799,9 @@ bool Configure::displayHelp() desc("USE_GOLD_LINKER", "yes", "-use-gold-linker", "Link using the GNU gold linker (gcc only)."); desc("USE_GOLD_LINKER", "no", "-no-use-gold-linker", "Do not link using the GNU gold linker.\n"); + desc("ENABLE_NEW_DTAGS", "yes", "-enable-new-dtags", "Use new DTAGS for RPATH (Linux only)."); + desc("ENABLE_NEW_DTAGS", "no", "-disable-new-dtags", "Do not use new DTAGS for RPATH.\n"); + desc("SHARED", "yes", "-shared", "Create and use shared Qt libraries."); desc("SHARED", "no", "-static", "Create and use static Qt libraries.\n"); @@ -2675,6 +2684,9 @@ void Configure::generateOutputVars() if (dictionary[ "USE_GOLD_LINKER" ] == "yes") qmakeConfig += "use_gold_linker"; + if (dictionary[ "ENABLE_NEW_DTAGS" ] == "yes") + qmakeConfig += "enable_new_dtags"; + if (dictionary[ "SHARED" ] == "no") qtConfig += "static"; else