Repository navigation
build(libkernel): compile Exception on macOS - #11249
iamthehimansh wants to merge 1 commit into
Conversation
System/src/Exception.cpp converts the host signal context to and from the guest machine context through Linux's gregs array and fpregs pointer. On macOS the general registers are named fields of mcontext_t->__ss and the x87/SSE state is an FXSAVE-layout block in mcontext_t->__fs, so macOS now copies those fields directly. A static_assert checks that the Darwin float state really has the FXSAVE layout the copy relies on. Linux and Windows compile the same code as before.
MarcZX10
left a comment
There was a problem hiding this comment.
I reviewed the full macOS conversion. The general registers map field-for-field between Darwin __ss and GuestMcontext, and the FXSAVE offsets are checked at MXCSR, XMM0, and the end of XMM15 before copying the state image. The 512-byte host read fits the guest state assertion; the reverse path copies the same 416 bytes as the Linux implementation. The Apple branch is isolated from the existing Linux conversion.
git diff --check and current-main conventions pass. Hosted eligibility, conventions, intake, labels and report pass; product/build jobs are skipped by policy. I did not run the macOS runtime test locally. The author reports this same code passed the named guest exception/signal tests in the previous full macOS run (1,960 tests), and the changed translation unit compiles on the current branch. No concrete defect found.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
MarcZX10
left a comment
There was a problem hiding this comment.
I am updating my earlier approval after checking the exact overlap against current open #7201. #7201 is still open and contains this same Exception.cpp context conversion; this PR itself says 46 of its 56 added lines also appear there. CONTRIBUTING requires the authors to agree which overlapping change lands first and record any prerequisite on Depends on. The current description says this PR can land independently, but does not show coordination with #7201’s author. Please record the agreed merge order and list a dependency if #7201 must land first, or coordinate that this focused PR is the replacement for this portion of #7201. The technical review of this head remains sound; this request is specifically for the documented overlap/merge-order rule.
|
macOS test report. Apple M4 Pro, macOS 27.0.1, Apple clang 21, x86_64 Release under Rosetta 2, MoltenVK 1.4.2. I looked for the smallest set of open PRs that boots titles on macOS from current This PR is needed: with it removed from that set (head |
|
@imellag thanks, that's a very useful set to have written down. On the AI-assisted: yes (Cana) |
|
Follow-up to my earlier note about a separate macOS Vulkan loader PR: @maximilianfv opened #11554 with the same change, plus AI-assisted: yes (Cana) |
|
Correction: the "0 validation messages" in my comment above was wrong, because the validation layer wasn't loading in my runs. With it loaded, #11554 shows 1 validation error per run, from the image-table test's own descriptor layout. My loader-only version shows 2, so #11554's extra portability subset removes one error. Details on #11554. AI-assisted: yes (Cana) |
|
Closing this in favour of @mugurc's #4630, which was opened earlier and makes the same AI-assisted: yes (Cana) |
What
Next part of splitting #8658:
libkernel'sSystem/src/Exception.cppdoes not compile on macOS. The change is macOS-only; Linux and Windows compile the same code as before.It converts the host signal context to and from the guest machine context through Linux's
gregsarray andfpregspointer. On macOS the general registers are named fields ofmcontext_t->__ss, and the x87/SSE state is an FXSAVE-layout block insidemcontext_t->__fs. macOS now copies those fields directly. Astatic_assertchecks that the Darwin float state has the FXSAVE layout (MXCSR at 24, XMM0 at 160) that the copy relies on, so a header change fails the build instead of corrupting registers.Overlap
@marion909's #7201 ("Macos port", 100 files, needs a rebase) also converts the Darwin machine context in this file, and 46 of this PR's 56 added lines appear there too. This PR carries only
Exception.cpp, so it can land on its own. It differs in one place: it copies the full 512-byte FXSAVE image from__fsinto the guest state, checks the Darwin layout with astatic_assertat MXCSR, XMM0 and the end of XMM15, and writes back only the 416 register bytes. #7201 copies 416 bytes in both directions. If #7201 lands first, I'll close this or rebase it onto that.Tested
macOS 26 on an Apple M2 Pro, x86_64 under Rosetta 2, Release with Ninja, on
mainatb90d009d9:System/src/Exception.cpp.ocompiles, wheremainfails it. Thelibkerneltests cannot run on macOS until the rest oflibkernelbuilds (#10552, #7804, #10898 and follow-ups), so this is a compile check only. In #8658's full macOS run (1,960 tests) the same code passedguest_exception_handler,guest_raise_exception,guest_signals,guest_signal_setsandguest_signal_list. For Linux and Windows, I checked the file's view underunifdef -U__APPLE__, with-D__linux__and with-D_WIN32: it equalsmain.python3 tools/check_conventions.py --base origin/mainpasses.Checklist
main; Macos port #7201 also implements this conversion (see Overlap)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)