From e801e0435ea69b64443dd16ef5a13e93ea13546c Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 28 Jun 2020 12:57:08 -0700 Subject: symbolextractor: use try/finally in solaris_syms when wrapping gnu_syms As suggested by dcbaker in https://github.com/mesonbuild/meson/pull/7370#pullrequestreview-436872661 Signed-off-by: Alan Coopersmith --- mesonbuild/scripts/symbolextractor.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mesonbuild/scripts/symbolextractor.py b/mesonbuild/scripts/symbolextractor.py index 524027539..f4084bea8 100644 --- a/mesonbuild/scripts/symbolextractor.py +++ b/mesonbuild/scripts/symbolextractor.py @@ -124,9 +124,11 @@ def gnu_syms(libfilename: str, outfilename: str): def solaris_syms(libfilename: str, outfilename: str): # gnu_syms() works with GNU nm & readelf, not Solaris nm & elfdump origpath = os.environ['PATH'] - os.environ['PATH'] = '/usr/gnu/bin:' + origpath - gnu_syms(libfilename, outfilename) - os.environ['PATH'] = origpath + try: + os.environ['PATH'] = '/usr/gnu/bin:' + origpath + gnu_syms(libfilename, outfilename) + finally: + os.environ['PATH'] = origpath def osx_syms(libfilename: str, outfilename: str): # Get the name of the library -- cgit v1.2.3 From 5b82bb8689b3cb598289f734de21e07a64fa6898 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 7 Jul 2020 19:02:08 -0700 Subject: SolarisDynamicLinker: Check if linker supports -z type=pie As suggested by dcbaker in https://github.com/mesonbuild/meson/pull/7370#discussion_r445145889 Signed-off-by: Alan Coopersmith --- mesonbuild/linkers.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py index 4264e7da2..c6c677ccc 100644 --- a/mesonbuild/linkers.py +++ b/mesonbuild/linkers.py @@ -1100,7 +1100,13 @@ class SolarisDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker): def get_pie_args(self) -> T.List[str]: # Available in Solaris 11.2 and later - return ['-z', 'type=pie'] + pc, stdo, stde = mesonlib.Popen_safe(self.exelist + self._apply_prefix('-zhelp')) + for line in (stdo + stde).split('\n'): + if '-z type' in line: + if 'pie' in line: + return ['-z', 'type=pie'] + break + return [] def get_asneeded_args(self) -> T.List[str]: return self._apply_prefix(['-z', 'ignore']) -- cgit v1.2.3 From 20d405ec18845a18694e4985701dd89523d6dc73 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 7 Jul 2020 19:13:36 -0700 Subject: SolarisDynamicLinker: report ld's version instead of gcc's Signed-off-by: Alan Coopersmith --- mesonbuild/environment.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index bf09a883e..00922c11c 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -930,9 +930,15 @@ class Environment: cls = GnuBFDDynamicLinker linker = cls(compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v) elif 'Solaris' in e or 'Solaris' in o: + for line in (o+e).split('\n'): + if 'ld: Software Generation Utilities' in line: + v = line.split(':')[2].lstrip() + break + else: + v = 'unknown version' linker = SolarisDynamicLinker( compiler, for_machine, comp_class.LINKER_PREFIX, override, - version=search_version(e)) + version=v) else: raise EnvironmentException('Unable to determine dynamic linker') return linker -- cgit v1.2.3