Jan Tojnar 2020-07-12 18:19:10 +02:00
parent c19222143e
commit d8ac41f863
No known key found for this signature in database
GPG Key ID: 7FAB2A15F7A607A4
2 changed files with 28 additions and 56 deletions

View File

@ -8,11 +8,11 @@
python3.pkgs.buildPythonApplication rec {
pname = "meson";
version = "0.54.2";
version = "0.55.0";
src = python3.pkgs.fetchPypi {
inherit pname version;
sha256 = "0m84zb0q67vnxmd6ldz477w6yjdnk9c44xhlwh1g1pzqx3m6wwd7";
sha256 = "Chriv+KuFKxHWTU3+TKQ+3npt3XFW0xTwoK8PKN0WzU=";
};
patches = [
@ -51,6 +51,10 @@ python3.pkgs.buildPythonApplication rec {
# workaround until https://github.com/mesonbuild/meson/pull/6512 lands.
depsHostHostPropagated = [ pkgsHostHost.stdenv.cc ];
pythonPath = [
python3.pkgs.setuptools # for pkg_resources
];
# 0.45 update enabled tests but they are failing
doCheck = false;
# checkInputs = [ ninja pkgconfig ];

View File

@ -1,56 +1,24 @@
--- a/mesonbuild/linkers.py
+++ b/mesonbuild/linkers.py
@@ -527,8 +527,10 @@ class GnuLikeDynamicLinkerMixin:
# In order to avoid relinking for RPATH removal, the binary needs to contain just
# enough space in the ELF header to hold the final installation RPATH.
paths = ':'.join(all_paths)
- if len(paths) < len(install_rpath):
- padding = 'X' * (len(install_rpath) - len(paths))
+ store_paths = ':'.join(filter(lambda path: path.startswith('@storeDir@'), all_paths))
+ extra_space_needed = len(install_rpath + (':' if install_rpath and store_paths else '') + store_paths) - len(paths)
+ if extra_space_needed > 0:
+ padding = 'X' * extra_space_needed
if not paths:
paths = padding
else:
@@ -902,8 +904,10 @@ class SolarisDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
# In order to avoid relinking for RPATH removal, the binary needs to contain just
# enough space in the ELF header to hold the final installation RPATH.
paths = ':'.join(all_paths)
- if len(paths) < len(install_rpath):
- padding = 'X' * (len(install_rpath) - len(paths))
+ store_paths = ':'.join(filter(lambda path: path.startswith('@storeDir@'), all_paths))
+ extra_space_needed = len(install_rpath + (':' if install_rpath and store_paths else '') + store_paths) - len(paths)
+ if extra_space_needed > 0:
+ padding = 'X' * extra_space_needed
if not paths:
paths = padding
else:
--- a/mesonbuild/scripts/depfixer.py
+++ b/mesonbuild/scripts/depfixer.py
@@ -303,6 +303,14 @@ class Elf(DataSizes):
return
self.bf.seek(rp_off)
old_rpath = self.read_str()
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -453,6 +453,21 @@ class Backend:
args.extend(self.environment.coredata.get_external_link_args(target.for_machine, lang))
except Exception:
pass
+
+ if new_rpath:
+ new_rpath += b':'
+ else:
+ new_rpath = b''
+ nix_ldflags = os.environ.get('NIX_LDFLAGS', '').split()
+ next_is_path = False
+ # Try to add rpaths set by user or ld-wrapper so that they are not removed.
+ # Based on https://github.com/NixOS/nixpkgs/blob/69711a2f5ffe8cda208163be5258266172ff527f/pkgs/build-support/bintools-wrapper/ld-wrapper.sh#L148-L177
+ for flag in nix_ldflags:
+ if flag == '-rpath' or flag == '-L':
+ next_is_path = True
+ elif next_is_path or flag.startswith('-L/'):
+ if flag.startswith('-L/'):
+ flag = flag[2:]
+ if flag.startswith('@storeDir@'):
+ dirs.add(flag)
+ next_is_path = False
+
+ new_rpath += b':'.join(filter(lambda path: path.startswith(b'@storeDir@'), old_rpath.split(b':')))
+
if len(old_rpath) < len(new_rpath):
sys.exit("New rpath must not be longer than the old one.")
# The linker does read-only string deduplication. If there is a
@@ -316,6 +324,10 @@ class Elf(DataSizes):
if not new_rpath:
self.remove_rpath_entry(entrynum)
else:
+ # clean old rpath to avoid stale references
+ # (see https://github.com/NixOS/nixpkgs/pull/46020)
+ self.bf.seek(rp_off)
+ self.bf.write(b'\0'*len(old_rpath))
self.bf.seek(rp_off)
self.bf.write(new_rpath)
self.bf.write(b'\0')
for arg in args:
if arg.startswith('-Wl,-rpath='):
for dir in arg.replace('-Wl,-rpath=','').split(':'):