Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building meson-python fails in AIX #13878

Open
prajwal-ibm opened this issue Nov 6, 2024 · 2 comments · May be fixed by #13881
Open

Building meson-python fails in AIX #13878

prajwal-ibm opened this issue Nov 6, 2024 · 2 comments · May be fixed by #13881

Comments

@prajwal-ibm
Copy link

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.

@KamathForAIX
Copy link
Contributor

cc: @eli-schwartz

I can confirm this bug exists and the fix solves the issue.

@eli-schwartz
Copy link
Member

Ah hmm, right. This happens because we only iterate over all configured project languages that also support using a linker, and then create AIX_LINKER for the last one basically. This fails for projects that don't have any configured languages, which is okay since they also do not need to run the AIX_LINKER archiving rule.

The fix seems reasonable...

prajwal-ibm added a commit to prajwal-ibm/meson that referenced this issue Nov 7, 2024
@prajwal-ibm prajwal-ibm linked a pull request Nov 7, 2024 that will close this issue
prajwal-ibm added a commit to prajwal-ibm/meson that referenced this issue Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants