[PATCH] D129142: [LLD][ELF] Drop duplicates from rpath
Stephan Bergmann via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 5 23:20:29 PDT 2022
sberg updated this revision to Diff 442445.
sberg added a comment.
addressed comments on test file
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129142/new/
https://reviews.llvm.org/D129142
Files:
lld/ELF/Driver.cpp
lld/docs/ReleaseNotes.rst
lld/test/ELF/duplicated-rpath.test
Index: lld/test/ELF/duplicated-rpath.test
===================================================================
--- /dev/null
+++ lld/test/ELF/duplicated-rpath.test
@@ -0,0 +1,12 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+
+## Duplicated /path1 and /path2 shall only appear once each:
+# RUN: ld.lld %t.o -rpath=/path1 -rpath=/path12 -rpath=/path2 -rpath=/path2 -rpath=/path1 -shared -o %t
+# RUN: llvm-readobj --dynamic-table %t | FileCheck %s
+# CHECK: Library runpath: [/path1:/path12:/path2]
+
+## Degenerate case where an -rpath argument already contains a colon:
+# RUN: ld.lld %t.o -rpath=/path1 -rpath=/path1:/path2 -rpath=/path2 -shared -o %t
+# RUN: llvm-readobj --dynamic-table %t | FileCheck --check-prefix=DEGENERATE %s
+# DEGENERATE: Library runpath: [/path1:/path1:/path2:/path2]
Index: lld/docs/ReleaseNotes.rst
===================================================================
--- lld/docs/ReleaseNotes.rst
+++ lld/docs/ReleaseNotes.rst
@@ -31,6 +31,9 @@
* ``--no-fortran-common`` (pre 12.0.0 behavior) is now the default.
* ``FORCE_LLD_DIAGNOSTICS_CRASH`` environment variable is now available to force LLD to crash.
(`D128195 <https://reviews.llvm.org/D128195>`_)
+* Duplicate ``-rpath`` arguments with an identical path are ignored now, matching GNU ld and gold
+ behavior.
+ (`D129142 <https://reviews.llvm.org/D129142>`_)
Breaking changes
----------------
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -47,6 +47,7 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/UniqueVector.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/LTO/LTO.h"
#include "llvm/Object/Archive.h"
@@ -594,7 +595,10 @@
static std::string getRpath(opt::InputArgList &args) {
std::vector<StringRef> v = args::getStrings(args, OPT_rpath);
- return llvm::join(v.begin(), v.end(), ":");
+ llvm::UniqueVector<StringRef> u;
+ for (StringRef p : v)
+ u.insert(p);
+ return llvm::join(u.begin(), u.end(), ":");
}
// Determines what we should do if there are remaining unresolved
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129142.442445.patch
Type: text/x-patch
Size: 2212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220706/f585be00/attachment.bin>
More information about the llvm-commits
mailing list