-
Notifications
You must be signed in to change notification settings - Fork 13
fix: set module triple/data layout; drop forced 64-bit size_t override #134
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
base: main
Are you sure you want to change the base?
Conversation
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.py
|
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.py
|
|
@yuvimittal @xmnlab please have a look |
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.py
|
|
@yuvimittal @xmnlab Please have a look |
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.py
|
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.py
|
3e5333c to
0a6848f
Compare
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.py
Suggested change: And right after setting module.triple and module.data_layout in init (same block): Call _sync_pointer_bits_from_target() after assigning data_layout. (L.176)
Suggested change: |
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.py
tests/test_llvmlite_helpers.py
|
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.py
tests/test_llvmlite_helpers.pyLGTM! |
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.py
tests/test_llvmlite_helpers.pyLGTM! |
xmnlab
left a comment
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.
LGTM! thanks, appreciate it, @omsherikar
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.py
tests/test_llvmlite_helpers.py
def _host_ptr_bits() -> int:
"""Return host pointer size in bits."""
import struct
return struct.calcsize("P") * 8Then replace the final assert in test_get_size_t_type_from_triple_fallback (L.121): assert size_t_ty.width == _host_ptr_bits()
assert result.type.count == 2
mock_tm = Mock(spec_set=["triple"]) |
Thanks @xmnlab |
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.py
tests/test_llvmlite_helpers.py
|
|
@omsherikar .. I will take a time to check the review here #134 (comment) maybe there is something interesting there ... |
Okay @xmnlab I will also have a look in it. |
Pull Request description
This PR fixes incorrect
SIZE_T_TYPEinitialization and missing target configuration in the LLVM module, which could cause miscompilation on 32-bit or cross-compilation targets.Issues fixed:
ctypes, then forcibly overridden to 64-bit, causing mismatches on non-64-bit targets.Changes made:
module.triplefrom target machine to ensure correct target architecturemodule.data_layoutfrom target machine to ensure correct pointer sizes and ABISIZE_T_TYPE, allowing it to use the host-initialized value (which is correct for the target)module.tripleassignment in case attribute access failsWhy this matters:
size_tshould be 32-bit, not 64-bitsolves Correct native sizes & module target info #132
How to test these changes
Run the full test suite to ensure no regressions:
Verify string operations still work (they use SIZE_T_TYPE):
Test malloc/snprintf operations (they use SIZE_T_TYPE):
All 112 tests should pass, confirming the fix doesn't break existing functionality
Pull Request checklists
This PR is a:
About this PR:
Author's checklist:
Additional information
Code location:
src/irx/builders/llvmliteir.pyBefore:
After:
Test results:
Reviewer's checklist
Copy and paste this template for your review's note: