From 4ad62d7f03da9ac29daae73d2e9fc68417991a31 Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Wed, 8 Nov 2023 22:47:41 +0900 Subject: [PATCH] Get library name patterns with proper prefixes and suffixes on OS/2 --- mesonbuild/compilers/mixins/clike.py | 31 +++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 914a1fb0472e..889fa4c3548d 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -990,9 +990,24 @@ def symbols_have_underscore_prefix(self, env: 'Environment') -> bool: def _get_patterns(self, env: 'Environment', prefixes: T.List[str], suffixes: T.List[str], shared: bool = False) -> T.List[str]: patterns: T.List[str] = [] - for p in prefixes: + if env.machines[self.for_machine].is_os2(): + # On OS/2, search order for shared libs is + # 1. libfoo_dll.a + # 2. foo_dll.a + # 3. libfoo.a + # 4. foo.a + # 5. foo.dll + # For static libs, `_s' is used instead of `_dll'. for s in suffixes: - patterns.append(p + '{}.' + s) + for p in prefixes: + if s.startswith('_dll.') or s.startswith('_s.'): + patterns.append(p + '{}' + s) + else: + patterns.append(p + '{}.' + s) + else: + for p in prefixes: + for s in suffixes: + patterns.append(p + '{}.' + s) if shared and env.machines[self.for_machine].is_openbsd(): # Shared libraries on OpenBSD can be named libfoo.so.X.Y: # https://www.openbsd.org/faq/ports/specialtopics.html#SharedLibs @@ -1015,7 +1030,9 @@ def get_library_naming(self, env: 'Environment', libtype: LibType, strict: bool # people depend on it. Also, some people use prebuilt `foo.so` instead # of `libfoo.so` for unknown reasons, and may also want to create # `foo.so` by setting name_prefix to '' - if strict and not isinstance(self, VisualStudioLikeCompiler): # lib prefix is not usually used with msvc + # lib prefix is not usually used with msvc and OS/2 + if strict and not isinstance(self, VisualStudioLikeCompiler) \ + and not env.machines[self.for_machine].is_os2(): prefixes = ['lib'] else: prefixes = ['lib', ''] @@ -1038,6 +1055,14 @@ def get_library_naming(self, env: 'Environment', libtype: LibType, strict: bool # TI C28x compilers can use both extensions for static or dynamic libs. stlibext = ['a', 'lib'] shlibext = ['dll', 'so'] + elif env.machines[self.for_machine].is_os2(): + from ...options import OptionKey + if env.coredata.get_option(OptionKey('emxomf')): + stlibext = ['_s.lib', '_s.a', 'lib', 'a'] + shlibext = ['_dll.lib', '_dll.a', 'lib', 'a', 'dll'] + else: + stlibext = ['_s.a', 'a'] + shlibext = ['_dll.a', 'a', 'dll'] else: # Linux/BSDs shlibext = ['so']