Repository: mesonbuild/meson
Issue category: Bug Report

Building meson-python fails in AIX
When I tried to meson-python master branch in AIX using meson, I get the below error
```
Traceback (most recent call last):
  File "/meson/install/opt/freeware/lib/python3.9/site-packages/mesonbuild/mesonmain.py", line 193, in run
    return options.run_func(options)
  File "/meson/install/opt/freeware/lib/python3.9/site-packages/mesonbuild/msetup.py", line 365, in run
    app.generate()
  File "/meson/install/opt/freeware/lib/python3.9/site-packages/mesonbuild/msetup.py", line 188, in generate
    return self._generate(env, capture, vslite_ctx)
  File "/meson/install/opt/freeware/lib/python3.9/site-packages/mesonbuild/msetup.py", line 253, in _generate
    captured_compile_args = intr.backend.generate(capture, vslite_ctx)
  File "/meson/install/opt/freeware/lib/python3.9/site-packages/mesonbuild/backend/ninjabackend.py", line 642, in generate
    self.generate_rules()
  File "/meson/install/opt/freeware/lib/python3.9/site-packages/mesonbuild/backend/ninjabackend.py", line 1354, in generate_rules
    self.generate_dynamic_link_rules()
  File "/meson/install/opt/freeware/lib/python3.9/site-packages/mesonbuild/backend/ninjabackend.py", line 2376, in generate_dynamic_link_rules
    cmdlist = compiler.get_command_to_archive_shlib()
UnboundLocalError: local variable 'compiler' referenced before assignment
```

For this I would like to propose a simple fix that handles the scenario when compiler is empty 
```
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index cb3552d7f..7b573e4e4 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2369,7 +2369,7 @@ class NinjaBackend(backends.Backend):
 
                 options = self._rsp_options(compiler)
                 self.add_rule(NinjaRule(rule, command, args, description, **options, extra=pool))
-            if self.environment.machines[for_machine].is_aix():
+            if self.environment.machines[for_machine].is_aix() and complist:
                 rule = 'AIX_LINKER{}'.format(self.get_rule_suffix(for_machine))
                 description = 'Archiving AIX shared library'
                 cmdlist = compiler.get_command_to_archive_shlib()
```

Kindly let me know if can I raise a PR and you're okay with this.


Functions to edit:
mesonbuild/backend/ninjabackend.py:NinjaBackend.generate_dynamic_link_rules

Patch:
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index cb3552d7f0c1..7b573e4e4d8a 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2369,7 +2369,7 @@ def generate_dynamic_link_rules(self) -> None:
 
                 options = self._rsp_options(compiler)
                 self.add_rule(NinjaRule(rule, command, args, description, **options, extra=pool))
-            if self.environment.machines[for_machine].is_aix():
+            if self.environment.machines[for_machine].is_aix() and complist:
                 rule = 'AIX_LINKER{}'.format(self.get_rule_suffix(for_machine))
                 description = 'Archiving AIX shared library'
                 cmdlist = compiler.get_command_to_archive_shlib()