Hi Vincent,

Vincent Lefevre wrote:

> 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.

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 [email protected][*] 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.



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to