-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Enhance shared library support for AIX #12352
Conversation
Respected @eli-schwartz and community members, Kindly review this pull request. Let me know what you think. |
I'm putting this on my schedule to review on Sunday. :) |
Thank you. |
Respected @eli-schwartz and community members, I addressed the comments mentioned in the review. Kindly let me know what you think now and if any further changes needed from my end. While I tried to add conditions for AIX code so that no other targets are affected I still see one failure in checks which I could not figure out why my changes have caused the same. You all are experts and have immense knowledge of meson, Kindly let me know what can be the root cause of the same with respect to these changes. Have a nice day ahead. |
This failing test (msys2 clang handling of LLVM) is failing everywhere, not just on your PR. Don't worry about it. |
Thank you so much for this confirmation @eli-schwartz. So I made the suggested changes. Kindly let me know if any more changes are needed. Have a nice day ahead. Thanks and regards, |
88cf00b
to
2bac266
Compare
Respected @eli-schwartz and community members, Kindly let me know if I missed something in the review comments. I addressed the review changes suggested and squashed the commit into one message. Kindly merge this PR if there are no changes needed. Thank you for your guidance. Regards, |
mesonbuild/backend/ninjabackend.py
Outdated
if self.environment.machines[for_machine].is_aix(): | ||
rule = 'AIX_LINKER{}'.format(self.get_rule_suffix(for_machine)) | ||
description = 'Archiving AIX shared library' | ||
cmdlist = compiler.get_command_to_archive_shlib() | ||
args = [] | ||
options = {} | ||
self.add_rule(NinjaRule(rule, cmdlist, args, description, **options, extra=None)) | ||
if self.environment.machines[for_machine].is_aix(): | ||
rule = 'AIX_LINKER{}'.format(self.get_rule_suffix(for_machine)) | ||
description = 'Archiving AIX shared library' | ||
cmdlist = compiler.get_command_to_archive_shlib() | ||
args = [] | ||
options = {} | ||
self.add_rule(NinjaRule(rule, cmdlist, args, description, **options, extra=None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this indentation being removed here? It looks like you are dropping off the end of the for loop and only producing one rule, using whichever for_machine turns out to be last...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right here. I changed it back. Also, while I changed it back, I saw an error while building Scipy, which looked like this:
File "/meson_install/opt/freeware/lib/python3.9/site-packages/mesonbuild/backend/ninjabackend.py", line 1315, in generate_rules
self.generate_dynamic_link_rules()
File "/meson_install/opt/freeware/lib/python3.9/site-packages/mesonbuild/backend/ninjabackend.py", line 2388, in generate_dynamic_link_rules
cmdlist = compiler.get_command_to_archive_shlib()
File "/meson_install/opt/freeware/lib/python3.9/site-packages/mesonbuild/compilers/compilers.py", line 963, in get_command_to_archive_shlib
return self.linker.get_command_to_archive_shlib()
AttributeError: 'NoneType' object has no attribute 'get_command_to_archive_shlib'
I added a guard in the compilers.py file. Kindly see the changes there and let me know. This is because linker object was none.
Apologies for the lateness of the reply, there were some IRL things going on (all good news, I promise! 😄) |
Thank you for your reply. No problem. Please let me know now. I have made those changes. |
Previously, AIX support was updated to archive shared libraries per AIX platform conventions, which expect .a files that contain .so files. This is usually correct, but an edge case occurs for loadable plugins, e.g. what meson creates for `shared_module()`. A notable example is python extensions (SciPy, for example). These should *not* be archived, because the .so file itself needs to be loaded as a plugin. For example, SciPy fails to import in the python interpreter. Handle this by differentiating between plugins and regular libraries, and only archiving when safe to do so. Fixes mesonbuild#12219
A compiler may not have a linker: ``` 'NoneType' object has no attribute 'get_command_to_archive_shlib' ```
1563bac
to
cfec255
Compare
I have tweaked the commit messages and moved some code in the second commit back into the first commit where it seemed to belong. Here is a range-diff of the changes: $ git --no-pager range-diff origin/master 1563bac5e cfec25502
1: 2bac26601 ! 1: f4d19db25 Use target_aix_so_archive to decide to archive shared library in AIX
@@ Metadata
Author: Aditya Vidyadhar Kamath <[email protected]>
## Commit message ##
- Use target_aix_so_archive to decide to archive shared library in AIX
+ Use target.aix_so_archive to decide to archive shared library in AIX
- Enhance shared library support for AIX
+ Previously, AIX support was updated to archive shared libraries per AIX
+ platform conventions, which expect .a files that contain .so files. This
+ is usually correct, but an edge case occurs for loadable plugins, e.g.
+ what meson creates for `shared_module()`. A notable example is python
+ extensions (SciPy, for example).
- Change == to is and simplify patch to fix build break
+ These should *not* be archived, because the .so file itself needs to be
+ loaded as a plugin. For example, SciPy fails to import in the python
+ interpreter.
- Simplify the logic by overriding aix_so_archive in SharedModule
+ Handle this by differentiating between plugins and regular libraries,
+ and only archiving when safe to do so.
- Check if AIX is the machine always
-
- Fix to cross compile build break
-
- Avoid using aix_so_archive in other targets
-
- Remove unnecessary conditions
-
- Add comment to condition change in install section for AIX
-
- Simply if condition to a simple and logic
-
- Use only target.aix_so_archive and change one cond to original
+ Fixes #12219
## mesonbuild/backend/backends.py ##
@@ mesonbuild/backend/backends.py: class Backend:
@@ mesonbuild/backend/ninjabackend.py: class NinjaBackend(backends.Backend):
def should_use_dyndeps_for_target(self, target: 'build.BuildTarget') -> bool:
if mesonlib.version_compare(self.ninja_version, '<1.10.0'):
-@@ mesonbuild/backend/ninjabackend.py: 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():
-- rule = 'AIX_LINKER{}'.format(self.get_rule_suffix(for_machine))
-- description = 'Archiving AIX shared library'
-- cmdlist = compiler.get_command_to_archive_shlib()
-- args = []
-- options = {}
-- self.add_rule(NinjaRule(rule, cmdlist, args, description, **options, extra=None))
-+ if self.environment.machines[for_machine].is_aix():
-+ rule = 'AIX_LINKER{}'.format(self.get_rule_suffix(for_machine))
-+ description = 'Archiving AIX shared library'
-+ cmdlist = compiler.get_command_to_archive_shlib()
-+ args = []
-+ options = {}
-+ self.add_rule(NinjaRule(rule, cmdlist, args, description, **options, extra=None))
-
- args = self.environment.get_build_command() + \
- ['--internal',
@@ mesonbuild/backend/ninjabackend.py: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
else:
dependencies = target.get_dependencies()
@@ mesonbuild/backend/ninjabackend.py: https://gcc.gnu.org/bugzilla/show_bug.cgi?id
# they are all built
#Add archive file if shared library in AIX for build all.
- if isinstance(t, build.SharedLibrary):
-- if self.environment.machines[t.for_machine].is_aix():
-+ if self.environment.machines[t.for_machine].is_aix():
-+ if isinstance(t, build.SharedLibrary) and t.aix_so_archive:
++ 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])
- targetlist.append(os.path.join(self.get_target_dir(t), t.get_outputs()[0]))
## mesonbuild/build.py ##
@@ mesonbuild/build.py: class SharedLibrary(BuildTarget):
2: 1563bac5e < -: --------- Fix to 'NoneType' object has no attribute 'get_command_to_archive_shlib'
-: --------- > 2: cfec25502 Fix traceback on AIX in shlib archiving code |
Thank you @eli-schwartz for the merge and your guidance. I learned a lot from you. Thank you, community members. |
This PR is for fixing issue number #12219 in meson for AIX operating system as discussed.