feat: add macos-intel ci#143
Open
martinjrobins wants to merge 15 commits into
Open
Conversation
KyleMayes/install-llvm-action@v2 doesn't support all LLVM versions on macOS Intel x64 (unsupported for 17.0, 18.1; segfault for 15.0). Switch to Homebrew for all LLVM < 19.1 on macos-15-intel, matching the approach already used for LLVM >= 19.1.
Homebrew install may fail during the post-install link step due to conflicts (e.g. python@3.12 as a dependency of llvm@16). The formula is still installed and usable even if linking fails.
The generic x86 relocation handler (handle_relocation_generic_x86) works with the object crate's abstracted RelocationKind interface, which is format-agnostic. This enables JIT compilation on Intel macOS where ARCH=x86_64 and the format is MachO.
On Intel macOS, LLVM generates section-targeted relocations (not just symbol-targeted ones). Fix is_jump_table_entry to only classify external symbols as jump entries, and extend handle_relocation to resolve Section targets via their loaded section address.
On Intel macOS, LLVM generates relocations targeting sections directly (via RelocationTarget::Section). Extend the section mapping scan to discover these sections so they're available in mapped_sections when handle_relocation resolves them.
Section-based relocations on x86_64 MachO have the addend already encoded as the PC-relative displacement in file space. Since all sections are mapped contiguously in a single mmap, the relative positions are preserved, so the addend needs no adjustment for Relative/PltRelative kinds. For Absolute, compute section_ptr + addend. This fixes the wrong values produced by the generic handler which incorrectly applied S - P to already-correct PC-relative addends.
…kinds These are generated by LLVM on x86_64 macOS when using the PIC relocation model. Treat Got/GotBaseOffset like Absolute (S+A) and GotRelative/GotBaseRelative like Relative (S+A-P, or addend-as-is for section-based).
…ocation kinds" This reverts commit 4371853.
…ries The generic handler's S+A-P formula is wrong for MachO x86_64 because the implicit addend already contains the file-space PC-relative displacement. Compute the correct displacement as: A + (jump_ptr - mmap_base) where mmap_base = text_runtime - text_file_address. This prevents SIGSEGV when JIT code calls external functions via jump table entries on Intel macOS.
The addend for X86_64_RELOC_UNSIGNED is the file-absolute address of the target. The correct runtime address is: addend + (section_runtime - section_file_addr) Not section_runtime + addend, which doubly adds section_file_addr.
Aarch64 uses 26-bit branch displacements, not 32-bit. Delegate back to the aarch64-specific relocation handler for non-x86_64.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.