Skip to content

feat: add macos-intel ci#143

Open
martinjrobins wants to merge 15 commits into
mainfrom
macos-intel
Open

feat: add macos-intel ci#143
martinjrobins wants to merge 15 commits into
mainfrom
macos-intel

Conversation

@martinjrobins

Copy link
Copy Markdown
Owner

No description provided.

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).
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant