From a85abe131b86893b97ee917cdb282d1624468b10 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 5 Jun 2024 16:02:24 +0200 Subject: Improve -rpath duplicate suppression logic even more --- libbuild2/cc/link-rule.cxx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index 93b2715..96b9898 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -3351,6 +3351,9 @@ namespace build2 origin = p.directory (); } + // Note: suppress duplicates at the options level, similar to + // rpath_libraries(). + bool origin_used (false); for (const dir_path& p: cast (l)) { @@ -3387,7 +3390,8 @@ namespace build2 else o += p.string (); - sargs.push_back (move (o)); + if (find (sargs.begin (), sargs.end (), o) == sargs.end ()) + sargs.push_back (move (o)); } // According to the Internet, `-Wl,-z,origin` is not needed except @@ -3405,7 +3409,12 @@ namespace build2 fail << ctgt << " does not support rpath-link"; for (const dir_path& p: cast (l)) - sargs.push_back ("-Wl,-rpath-link," + p.string ()); + { + string o ("-Wl,-rpath-link," + p.string ()); + + if (find (sargs.begin (), sargs.end (), o) == sargs.end ()) + sargs.push_back (move (o)); + } } } -- cgit v1.1