Unlike the standard ld, ld.gold doesn't take LD_RUN_PATH into account. In particular, this breaks the build of some programs (like GNU MPFR) when LD_RUN_PATH is used together with autoconf's AC_RUN_IFELSE.
Hi Vincent, Vincent Lefevre wrote: How about this patch (untested)? If it looks reasonable and works ok, please feel free to file this at http://sourceware.org/bugzilla/ or send the patch with whatever tweaks seem appropriate to binutils@sourceware.org[*] with [PATCH RFC] in the subject, cc-ing me. If you want to make people extra happy, a testcase for gold/testsuite/ would be nice. Hope that helps, Jonathan [*] archive: http://sourceware.org/ml/binutils gold/options.cc | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git i/gold/options.cc w/gold/options.cc index fe9a00e0..e898de53 100644 --- i/gold/options.cc +++ w/gold/options.cc @@ -1095,6 +1095,30 @@ General_options::finalize() if (this->nmagic() || this->omagic()) this->set_static(true); + // LD_RUN_PATH determines the default for -rpath. + if (this->rpath().empty()) + { + const char* rpath_env = getenv("LD_RUN_PATH"); + if (!rpath_env) + rpath_env = ""; + std::string s(rpath_env); + + for (size_t pos = 0, sep = s.find(':'); + ; + pos = sep + 1, sep = s.find(':', pos)) + { + if (sep == pos) + continue; + + if (sep != std::string::npos) + s[sep] = '\0'; + this->add_to_rpath(s.c_str() + pos); + + if (sep == std::string::npos) + break; + } + } + // If --thread_count is specified, it applies to // --thread-count-{initial,middle,final}, though it doesn't override // them.
tags 660813 upstream forwarded 660813 http://sourceware.org/bugzilla/show_bug.cgi?id=13764 thanks Hi Jonathan, Thanks, this solves the problem. Unfortunately I don't know how to do this for this particular case (there isn't a -rpath test alone to take it as an example...). There's also the man page to update. I've given some information in my upstream bug report.
The bug has always been present in binutils (the binary package), but its effect was visible particularly when binutils-gold was installed. Now binutils-gold is no longer built. The problem still exists, e.g. when providing -fuse-ld=gold, but no longer due to an effect of some package being installed. Thus I'm downgrading the severity to normal; the ld.bfd(1) man page documents LD_RUN_PATH, but not the ld.gold(1) one, so that it could be seen as a wishlist, but if /usr/bin/ld can point to ld.gold, this will break some user-side builds (with no good workaround as -fuse-ld=bfd is not portable). I could reproduce the problem when configuring MPFR on my machine with: ./configure --with-gmp=/usr/local/gmp-debug CFLAGS='-fuse-ld=gold' (/usr/local/gmp-debug being a version different from the /usr one). I got: checking if gmp.h version and libgmp version are the same... (5.0.1/5.1.2) no configure: WARNING: ========================================================== configure: WARNING: 'gmp.h' and 'libgmp' seem to have different versions or configure: WARNING: we cannot run a program linked with GMP (if you cannot configure: WARNING: see the version numbers above). A cause may be different configure: WARNING: GMP versions with different ABI's or the use of --with-gmp configure: WARNING: or --with-gmp-include with a system include directory configure: WARNING: (such as /usr/include or /usr/local/include). configure: WARNING: However since we can't use 'libtool' inside the configure, configure: WARNING: we can't be sure. See 'config.log' for details. configure: WARNING: CC="gcc" configure: WARNING: CFLAGS="-fuse-ld=gold" configure: WARNING: CPPFLAGS=" -I/usr/local/gmp-debug/include" configure: WARNING: LDFLAGS=" -L/usr/local/gmp-debug/lib" configure: WARNING: LIBS="-lgmp " configure: WARNING: Temporary LD_RUN_PATH was "/usr/local/gmp-debug/lib". configure: WARNING: ========================================================== The patch from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=660813#10 still works: checking if gmp.h version and libgmp version are the same... (5.0.1/5.0.1) yes (with the same configure line).
Am 23.07.2013 16:58, schrieb Vincent Lefevre: the -fuse-ld option is now supported upstream starting with binutils 2.23 and gcc-4.8. way more portable than the -B practice, or diverting the ld binary. please could somebody of you forward this upstream, and follow-up on feedback? thanks, Matthias
so that the use -fuse-ld=bfd (added by a configure script) may make a build fail.
Dear , Can I have your attention and possibly help me for humanity's sake please. I am writing this message with a heavy heart filled with sorrows and sadness. Please if you can respond, i have an issue that i will be most grateful if you could help me deal with it please. Susan