summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz93@gmail.com>2024-12-13 14:34:22 -0500
committerEli Schwartz <eschwartz93@gmail.com>2025-03-11 09:39:54 -0400
commit8689c944515d4401b1bc4dbc75910288aed006c5 (patch)
tree17cfc63fd592b2a346e83b4b886e6462943863f1
parentb19f6701025e37ca52e78eae7075cdc5a626f0ab (diff)
downloadmeson-8689c944515d4401b1bc4dbc75910288aed006c5.tar.gz
linkers: revert a binutils bug workaround, sort of
More specifically, the bug had been fixed shortly before we implemented this workaround. It's documented as only necessary for the binutils brand specifically, and was fixed upstream in 2.28. We can avoid producing these arguments at all on newer (post-2016) versions of binutils, so gate this behind a version check. This can significantly reduce the size of compiler command lines in some cases, as it encodes the full build directory. It also helps that one person who decides to put commas into their build directory name (which `-Wl,...` interprets as multiple arguments, rather than a single directory string). Bug: https://github.com/mesonbuild/meson/pull/1898 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20535 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16936
-rw-r--r--mesonbuild/linkers/linkers.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py
index b114d498b..ba642119f 100644
--- a/mesonbuild/linkers/linkers.py
+++ b/mesonbuild/linkers/linkers.py
@@ -748,11 +748,16 @@ class GnuLikeDynamicLinkerMixin(DynamicLinkerBase):
return (args, rpath_dirs_to_remove)
# Rpaths to use while linking must be absolute. These are not
- # written to the binary. Needed only with GNU ld:
+ # written to the binary. Needed only with GNU ld, and only for
+ # versions before 2.28:
+ # https://sourceware.org/bugzilla/show_bug.cgi?id=20535
# https://sourceware.org/bugzilla/show_bug.cgi?id=16936
# Not needed on Windows or other platforms that don't use RPATH
# https://github.com/mesonbuild/meson/issues/1897
#
+ # In 2.28 and on, $ORIGIN tokens inside of -rpath are respected,
+ # so we do not need to duplicate it in -rpath-link.
+ #
# In addition, this linker option tends to be quite long and some
# compilers have trouble dealing with it. That's why we will include
# one option per folder, like this:
@@ -762,8 +767,9 @@ class GnuLikeDynamicLinkerMixin(DynamicLinkerBase):
# ...instead of just one single looooong option, like this:
#
# -Wl,-rpath-link,/path/to/folder1:/path/to/folder2:...
- for p in rpath_paths:
- args.extend(self._apply_prefix('-rpath-link,' + os.path.join(build_dir, p)))
+ if self.id in {'ld.bfd', 'ld.gold'} and mesonlib.version_compare(self.version, '<2.28'):
+ for p in rpath_paths:
+ args.extend(self._apply_prefix('-rpath-link,' + os.path.join(build_dir, p)))
return (args, rpath_dirs_to_remove)