--- ./vendored-meson/meson/mesonbuild/compilers/compilers.py_orig	2023-12-06 23:04:23.148265226 -0600
+++ ./vendored-meson/meson/mesonbuild/compilers/compilers.py	2023-12-06 23:05:37.926285876 -0600
@@ -960,6 +960,8 @@
         return self.linker.get_archive_name(filename)
 
     def get_command_to_archive_shlib(self) -> T.List[str]:
+        if not self.linker:
+            return []
         return self.linker.get_command_to_archive_shlib()
 
     def thread_flags(self, env: 'Environment') -> T.List[str]:
--- ./vendored-meson/meson/mesonbuild/backend/backends.py_orig	2023-12-06 23:06:06.873415174 -0600
+++ ./vendored-meson/meson/mesonbuild/backend/backends.py	2023-12-06 23:07:56.249559555 -0600
@@ -339,6 +339,9 @@
         # On all other platforms, we link to the library directly.
         if isinstance(target, build.SharedLibrary):
             link_lib = target.get_import_filename() or target.get_filename()
+            # In AIX, if we archive .so, the blibpath must link to archived shared library otherwise to the .so file.
+            if mesonlib.is_aix() and target.aix_so_archive:
+                link_lib = re.sub('[.][a]([.]?([0-9]+))*([.]?([a-z]+))*', '.a', link_lib.replace('.so', '.a'))
             return os.path.join(self.get_target_dir(target), link_lib)
         elif isinstance(target, build.StaticLibrary):
             return os.path.join(self.get_target_dir(target), target.get_filename())
--- ./vendored-meson/meson/mesonbuild/backend/ninjabackend.py_orig	2023-12-06 23:08:24.446342332 -0600
+++ ./vendored-meson/meson/mesonbuild/backend/ninjabackend.py	2023-12-06 23:09:53.377017013 -0600
@@ -1054,8 +1054,9 @@
         #In AIX, we archive shared libraries. If the instance is a shared library, we add a command to archive the shared library
         #object and create the build element.
         if isinstance(target, build.SharedLibrary) and self.environment.machines[target.for_machine].is_aix():
-            elem = NinjaBuildElement(self.all_outputs, linker.get_archive_name(outname), 'AIX_LINKER', [outname])
-            self.add_build(elem)
+            if target.aix_so_archive:
+                elem = NinjaBuildElement(self.all_outputs, linker.get_archive_name(outname), 'AIX_LINKER', [outname])
+                self.add_build(elem)
 
     def should_use_dyndeps_for_target(self, target: 'build.BuildTarget') -> bool:
         if mesonlib.version_compare(self.ninja_version, '<1.10.0'):
@@ -3505,11 +3506,6 @@
         else:
             dependencies = target.get_dependencies()
         internal = self.build_target_link_arguments(linker, dependencies)
-        #In AIX since shared libraries are archived the dependencies must
-        #depend on .a file with the .so and not directly on the .so file.
-        if self.environment.machines[target.for_machine].is_aix():
-            for i, val in enumerate(internal):
-                internal[i] = linker.get_archive_name(val)
         commands += internal
         # Only non-static built targets need link args and link dependencies
         if not isinstance(target, build.StaticLibrary):
@@ -3714,7 +3710,7 @@
                 # Add the first output of each target to the 'all' target so that
                 # they are all built
                 #Add archive file if shared library in AIX for build all.
-                if isinstance(t, build.SharedLibrary):
+                if isinstance(t, build.SharedLibrary)  and t.aix_so_archive:
                     if self.environment.machines[t.for_machine].is_aix():
                         linker, stdlib_args = self.determine_linker_and_stdlib_args(t)
                         t.get_outputs()[0] = linker.get_archive_name(t.get_outputs()[0])
--- ./vendored-meson/meson/mesonbuild/build.py_orig	2023-12-06 23:10:15.572128198 -0600
+++ ./vendored-meson/meson/mesonbuild/build.py	2023-12-06 23:11:15.656056131 -0600
@@ -2147,7 +2147,10 @@
     known_kwargs = known_shlib_kwargs
 
     typename = 'shared library'
+    # Used by AIX to decide whether to archive shared library or not.
+    aix_so_archive = True
 
+
     def __init__(
             self,
             name: str,
@@ -2494,6 +2497,9 @@
     known_kwargs = known_shmod_kwargs
 
     typename = 'shared module'
+
+    # Used by AIX to not archive shared library for dlopen mechanism
+    aix_so_archive = False
 
     def __init__(
             self,
--- ./vendored-meson/meson/mesonbuild/minstall.py_orig	2023-12-06 23:12:47.568514173 -0600
+++ ./vendored-meson/meson/mesonbuild/minstall.py	2023-12-06 23:14:36.134510019 -0600
@@ -714,7 +714,7 @@
             # install the archive in which the shared library exists. The below code does the same.
             # We change the .so files having lt_version or so_version to archive file install.
             if is_aix():
-                if '.so' in t.fname:
+                if not os.path.exists(t.fname) and '.so' in t.fname:
                     t.fname = re.sub('[.][a]([.]?([0-9]+))*([.]?([a-z]+))*', '.a', t.fname.replace('.so', '.a'))
             if not self.should_install(t):
                 continue
