diff options
| author | Eli Schwartz <eschwartz93@gmail.com> | 2023-09-01 17:23:29 -0400 |
|---|---|---|
| committer | Eli Schwartz <eschwartz93@gmail.com> | 2023-09-26 02:36:15 -0400 |
| commit | 5b317c5658f5865aea76b5a5afda2cdc8bd50959 (patch) | |
| tree | 9bb31e094a59d2c64faf94d8b2fcc07c5a55811d /mesonbuild/compilers | |
| parent | fb6fd5aa1770970e94968b302dfe3026aa08e245 (diff) | |
| download | meson-5b317c5658f5865aea76b5a5afda2cdc8bd50959.tar.gz | |
compilers: use correct version comparison for openbsd libraries
It should *be* a version comparison. We are guaranteed to get a
two-element version number, which also parses as a float but a float
doesn't correctly handle version sorting when the second component
differs in number of digits.
The standard way to handle this is by comparing tuples such that each
component is an integer. Do so here.
Fixes #12195
Co-authored-by: George Koehler <xkernigh@netscape.net>
(for unittests)
Diffstat (limited to 'mesonbuild/compilers')
| -rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 61e671921..38af08c42 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -1084,6 +1084,10 @@ class CLikeCompiler(Compiler): @staticmethod def _sort_shlibs_openbsd(libs: T.List[str]) -> T.List[str]: + def tuple_key(x: str) -> T.Tuple[int, ...]: + ver = x.rsplit('.so.', maxsplit=1)[1] + return tuple(int(i) for i in ver.split('.')) + filtered: T.List[str] = [] for lib in libs: # Validate file as a shared library of type libfoo.so.X.Y @@ -1091,12 +1095,11 @@ class CLikeCompiler(Compiler): if len(ret) != 2: continue try: - float(ret[1]) + tuple(int(i) for i in ret[1].split('.')) except ValueError: continue filtered.append(lib) - float_cmp = lambda x: float(x.rsplit('.so.', maxsplit=1)[1]) - return sorted(filtered, key=float_cmp, reverse=True) + return sorted(filtered, key=tuple_key, reverse=True) @classmethod def _get_trials_from_pattern(cls, pattern: str, directory: str, libname: str) -> T.List[Path]: |
