WIP: fix(macos): build vk_programs, vk_shader and the debug tools on Darwin #492

Draft
mooki wants to merge 2 commits from mooki/Longshot:mac/renderer-compile into main
Member

What this is for: the macOS port (#420). Three files did not compile on macOS: two in the renderer
(gpu/vk/vk_programs.cpp, gpu/vk/vk_shader.cpp), and the debug tools in host/hos_main.c, which a macOS build left
out, so the executable did not link. This PR gives each an Apple branch. Windows and Linux compile the same text as
before. Every platform rebuilds its shader caches once after this PR, because it edits gpu/vk/vk_shader.cpp, which
the shader stamp hashes. What is measured: the two renderer files compiled with the renderer's own command, for arm64
and x86_64: main's fail, this PR's build. tests/test_debug_tools_linux.py, which now also checks macOS, fails on
main's hos_main.c and passes here, in two interleaved runs each. And the full game-free suite on an Apple M4 Max
(macOS 26.7.1), compared by test name with main. Not measured: a game run on this branch; Windows and Linux builds;
macOS 14.4; an Intel Mac.

Why

A macOS build of the renderer stopped at two compile errors, and once those were fixed the executable did not link:

gpu/vk/vk_programs.cpp:46:19: error: use of undeclared identifier 'RUSAGE_THREAD'
gpu/vk/vk_shader.cpp:1306:21: error: use of undeclared identifier 'environ'; did you mean 'env_on'?
ld: Undefined symbols: _hos_oot_current_map, _hos_oot_destination, _hos_oot_teleport_ask, _hos_oot_teleport_result,
    _hos_oot_teleport_cancel, _hos_oot_age_ask, _hos_oot_state   (named by host/control.c's game table)

Problem

  • vk_programs.cpp: the program life log's thread_major_faults() asks getrusage(RUSAGE_THREAD). Darwin has no
    per-thread fault count at all: getrusage takes only RUSAGE_SELF and RUSAGE_CHILDREN (sys/resource.h), the
    per-thread thread_info flavours (THREAD_BASIC_INFO, THREAD_EXTENDED_INFO, which is proc_threadinfo) hold run
    times and scheduling but no faults or page-ins, and task_events_info, proc_taskinfo and rusage_info's
    ri_pageins count the whole task.
  • vk_shader.cpp: translator_stamp reads _environ, which host/posix/windows.h defines as environ. Darwin's
    headers do not declare environ for C++ (only crt_externs.h's _NSGetEnviron).
  • hos_main.c: the eight debug-tool regions (cheats, pouch and inventory, clock, teleport and age, flight, lift,
    free view) are guarded by #if defined(_WIN32) || defined(__linux__). A macOS build compiles them out, but
    host/control.c's game table names seven of their functions.

What changed

  • gpu/vk/vk_programs.cpp (Apple only): thread_major_faults() and its start value are not compiled on Darwin,
    with a comment giving the reason above. The life log's create line ends major_faults unavailable there instead of
    major_faults <n>. It is one token, so a parser that splits on spaces still finds the key and no number. Neither the
    task's page-in count (other threads' disk waits booked to this create call) nor a 0 (which reads as "no faults") is
    logged in its place.
  • gpu/vk/vk_shader.cpp (Apple only): a namespace-scope extern char** environ;, the declaration
    vk_menu.cpp and vk_bug_report.cpp already use. _environ keeps its spelling, which
    tests/test_program_stamp_knobs.py looks for. libdyld exports environ on both architectures, so the strict
    -undefined error link of the Vulkan dylib resolves it.
  • host/hos_main.c: the eight guards read #if defined(_WIN32) || defined(__linux__) || defined(__APPLE__).
    Every call inside has a macOS provider, nothing is stubbed: the SRW locks (host/posix/windows.h over the waits PR's
    darwin_wait.c), GetAsyncKeyState, GetForegroundWindow and GetWindowThreadProcessId (win32_posix.c),
    GetCurrentProcessId, hos_flight_input, hos_free_camera_input and hos_move_stick_held (nn_hid.c),
    hos_now_ns, hos_sys_alloc, rx_option_set, and libSystem's math and pthread calls. The #else stubs stay for
    the web build.
  • tests/test_debug_tools_linux.py: it evaluates each guard for Windows, Linux and now macOS, and also checks the
    seven functions host/control.c's game table names (17 entries in all). Before, a guard naming a third platform
    would have counted as unknown, so the test could no longer have caught one that dropped _WIN32 or __linux__.

Flags and settings

None new. The program life log (RX_VK_LOG_PROGRAM_LIFE=1) writes major_faults unavailable on macOS; the same line
elsewhere is unchanged.

Measurements

main: 5e072fc8c2adadba5ea610148be1c47800ba0cca (2026-11-14)
this PR: mac/renderer-compile @ bf85ed4ae0cff08dd6a38df9bcce9c3314d26b39
Hardware: Apple M4 Max, 16 cores, 64 GiB, macOS 26.7.1; Apple clang 21.0.0 (Command Line Tools, SDK 27); Python 3.14.10.
No GPU, no game.
Scene: none. Game-free.
Method:

  • Compiles: vk_programs.cpp and vk_shader.cpp, for arm64 and for x86_64, with nx2/build.py's own renderer
    command (renderer_flags(), plus the LONGSHOT_SHADER_STAMP the build computes for vk_shader.cpp). main's
    nx2/build.py has no macOS commands, so both sides took them from the build-flags PR (#453), whose gpu/ is
    main's byte for byte: main's two files on one side, this PR's on the other. A compile is deterministic, so one run
    per file and architecture.
  • Test: tests/test_debug_tools_linux.py from this PR, run on this PR's tree and on a copy holding main's
    host/hos_main.c, interleaved: PR, main, PR, main. main's own version of the test also runs on this PR's tree.
  • Suite: tests/run_all.py --jobs 6 on this PR, compared by test name with a main run on the same Mac.

How to reproduce: python -I -B tests/test_debug_tools_linux.py (it reads host/hos_main.c beside it). For the
compiles, a macOS build with the build-flags PR, or nx2/build.py's renderer_flags() on its own.

main @ 5e072fc8 this PR @ bf85ed4a
vk_programs.cpp, arm64 and x86_64 error: RUSAGE_THREAD undeclared Mach-O object (arm64 6d45acdc…, x86_64 5973bbfe…)
vk_shader.cpp, arm64 and x86_64 2 errors: environ undeclared Mach-O object (arm64 d892778d…, x86_64 d19af652…)
tests/test_debug_tools_linux.py, runs 1 and 2 exit 1: 26 lines of the debug tools not compiled on macOS exit 0: ok: the 17 debug tools are compiled on Windows, Linux, macOS
full game-free suite 525 passed, 19 failed, 17 skipped 525 passed, 19 failed, 17 skipped
main @ 5e072fc8 (each architecture):
gpu/vk/vk_programs.cpp:46:19: error: use of undeclared identifier 'RUSAGE_THREAD'
gpu/vk/vk_shader.cpp:1306:21: error: use of undeclared identifier 'environ'; did you mean 'env_on'?
gpu/vk/vk_shader.cpp:1306:17: error: cannot initialize a variable of type 'char **' with an lvalue of type 'bool (const char *)'

main @ 5e072fc8, tests/test_debug_tools_linux.py (each run; 26 such lines):
host/hos_main.c:581 (static int oot_pouch_change(Ctx *c, const char *name, int delta) {) is not compiled on macOS
host/hos_main.c:1129 (int hos_oot_state(int *event, int *loading, int *child) {) is not compiled on macOS
host/hos_main.c:1160 (int hos_oot_teleport_ask(int index) {) is not compiled on macOS

this PR @ bf85ed4a:
ok: the 17 debug tools are compiled on Windows, Linux, macOS

vk_shader.cpp's shader stamp for this build command changes from 0xbc2a6a5c36fef83f (main) to
0xcbcf3214c5e45816 (this PR): that is the one-time cache rebuild.

Testing

Tested:

  • The compiles and the test, as above. main's own tests/test_debug_tools_linux.py also passes on this PR's
    hos_main.c (ok: the 10 debug tools are compiled on Windows and Linux).

  • Windows and Linux see the same text (unifdef, text only, not a build):

    • unifdef -U__APPLE__ of this PR's vk_programs.cpp and vk_shader.cpp equals main's files byte for byte;
    • host/hos_main.c with -D_WIN32 -U__linux__ -U__APPLE__ (1665 lines) and with -U_WIN32 -D__linux__ -U__APPLE__ (1898 lines) equals main's.
  • The whole suite, tests/run_all.py --jobs 6, on the same Mac:

    main @ 5e072fc8:     525 passed, 19 failed, 17 skipped in 177 s (linux, 6 at once)
    this PR @ bf85ed4a:  525 passed, 19 failed, 17 skipped in 174 s (linux, 6 at once)
    
    • By test name, no check changed status: tests/test_debug_tools_linux.py passes on both (main's version checks
      Windows and Linux only). The same 17 skips.
    • The same 19 checks fail on both. They are macOS portability failures of main, which other macOS pull requests
      address: test_appimage_package_retry, test_collect_wide, test_control, test_framegen_resources,
      test_game_layout, test_low_memory_notice, test_mem_gate, test_mem_gate_children, test_mirror_trim,
      test_module_ids, test_oot_state_tap, test_pad_layout, test_pcache_header_read, test_pipeline_cache_file,
      test_pipeline_cache_save, test_pipeline_play_cache, test_prof_symbols, test_program_cache_cleanup,
      test_program_cache_one_variant.
    • No new crash report; the tree was clean before and after.
  • History, not rerun on this branch: when these two commits were first made (05b5d88f, d26e5f88, on the macOS
    integration branch), a replay of a macOS executable link with the new hos_main.c object linked with no undefined
    symbol, where it had 7 before. Integration builds that carry them have since built both images and started the game
    on macOS (see #420). That speaks for those builds, not for this branch alone.

Not tested:

  • A Windows or Linux build, and a game start there.
  • A full macOS build of this branch: on main plus this PR alone, macOS has no build commands (#453) and lacks the
    other macOS host PRs.
  • The debug tools themselves on macOS (cheats, teleport, flight, free view) in a game.
  • macOS 14.4 itself, whose libdyld exports environ per the SDK's .tbd (vk_menu.cpp relies on it already).

Needs other testers:

  • Windows (llvm-mingw) and Linux: build and start the game once; the shader caches rebuild once, and nothing else
    changes. With RX_VK_LOG_PROGRAM_LIFE=1, the create lines still end major_faults <n> (request to open).

Screenshots

Nothing on screen.

Risk and rollback

  • Every platform: vk_shader.cpp is hashed into LONGSHOT_SHADER_STAMP (nx2/build.py:1176-1182), so after
    updating, the first start translates the shader programs again, as with any edit to that file. Nothing else changes
    off Apple: the preprocessed text is main's.
  • macOS: the life log has no per-thread fault count; a reader comparing create calls by major_faults sees
    unavailable instead.
  • Rollback: revert the two commits.

Reviewer notes

  • Review 5e072fc8..bf85ed4a: two commits, no dependency. 7f40bab2 is the renderer's two files; bf85ed4a is the
    debug tools and their test.
  • The debug tools now compile on macOS, so two existing warnings show there under -Wall (the build passes
    -Wno-everything): -Wlogical-not-parentheses at !child == bridge_adult (intended: the adult flag compared with
    the bridge's) and an unused oot_item_kinds. Linux and Windows compile the same code today.
  • The test keeps its file name (test_debug_tools_linux.py); renaming it was left out.
  • Against main at dc390e59 (7 commits after this branch's base), git merge-tree finds a conflict in
    host/hos_main.c; a rebase before ready resolves it. #370 there moves the stamp's file list to
    nx2/translator_files.py, which still names vk_shader.cpp, so the one-time cache rebuild holds on both bases.

Issues

See #420.

Checklist

For everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description).
  • Rebased on current main. Based on 5e072fc8; main has since moved to dc390e59 (a conflict named under
    Reviewer notes). Rebased before ready.
  • python -I -B tests/run_all.py run and passing (any failure that also fails on main is named above). On macOS:
    525 passed, 17 skipped, and the same 19 failures as main, named under Testing.
  • Tested in the game, or what wasn't is named under Testing. No game run on this branch; named under Testing.
  • Testing filled in: what was tested, what wasn't, and what needs other testers (with test requests). The test
    request is still to open.
  • Measured: main and this PR at named commits, on the same PC, scene and settings, at least 2 interleaved runs each,
    the median reported. For a fix: the test fails on main and passes here in two interleaved runs; the compiles fail
    on main and build here.
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

If applicable

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • A game-free test added for the fix, failing on main and passing here. tests/test_debug_tools_linux.py now
    checks macOS; the renderer files' proof is the compile above.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. Not built there; the preprocessed text
    is main's. Request to open.
**What this is for:** the macOS port (#420). Three files did not compile on macOS: two in the renderer (`gpu/vk/vk_programs.cpp`, `gpu/vk/vk_shader.cpp`), and the debug tools in `host/hos_main.c`, which a macOS build left out, so the executable did not link. This PR gives each an Apple branch. Windows and Linux compile the same text as before. **Every platform rebuilds its shader caches once after this PR**, because it edits `gpu/vk/vk_shader.cpp`, which the shader stamp hashes. **What is measured:** the two renderer files compiled with the renderer's own command, for arm64 and x86_64: `main`'s fail, this PR's build. `tests/test_debug_tools_linux.py`, which now also checks macOS, fails on `main`'s `hos_main.c` and passes here, in two interleaved runs each. And the full game-free suite on an Apple M4 Max (macOS 26.7.1), compared by test name with `main`. **Not measured:** a game run on this branch; Windows and Linux builds; macOS 14.4; an Intel Mac. ## Why A macOS build of the renderer stopped at two compile errors, and once those were fixed the executable did not link: ``` gpu/vk/vk_programs.cpp:46:19: error: use of undeclared identifier 'RUSAGE_THREAD' gpu/vk/vk_shader.cpp:1306:21: error: use of undeclared identifier 'environ'; did you mean 'env_on'? ld: Undefined symbols: _hos_oot_current_map, _hos_oot_destination, _hos_oot_teleport_ask, _hos_oot_teleport_result, _hos_oot_teleport_cancel, _hos_oot_age_ask, _hos_oot_state (named by host/control.c's game table) ``` ## Problem - **`vk_programs.cpp`:** the program life log's `thread_major_faults()` asks `getrusage(RUSAGE_THREAD)`. Darwin has no per-thread fault count at all: `getrusage` takes only `RUSAGE_SELF` and `RUSAGE_CHILDREN` (`sys/resource.h`), the per-thread `thread_info` flavours (`THREAD_BASIC_INFO`, `THREAD_EXTENDED_INFO`, which is `proc_threadinfo`) hold run times and scheduling but no faults or page-ins, and `task_events_info`, `proc_taskinfo` and `rusage_info`'s `ri_pageins` count the whole task. - **`vk_shader.cpp`:** `translator_stamp` reads `_environ`, which `host/posix/windows.h` defines as `environ`. Darwin's headers do not declare `environ` for C++ (only `crt_externs.h`'s `_NSGetEnviron`). - **`hos_main.c`:** the eight debug-tool regions (cheats, pouch and inventory, clock, teleport and age, flight, lift, free view) are guarded by `#if defined(_WIN32) || defined(__linux__)`. A macOS build compiles them out, but `host/control.c`'s game table names seven of their functions. ## What changed - **`gpu/vk/vk_programs.cpp`** (Apple only): `thread_major_faults()` and its start value are not compiled on Darwin, with a comment giving the reason above. The life log's create line ends `major_faults unavailable` there instead of `major_faults <n>`. It is one token, so a parser that splits on spaces still finds the key and no number. Neither the task's page-in count (other threads' disk waits booked to this create call) nor a 0 (which reads as "no faults") is logged in its place. - **`gpu/vk/vk_shader.cpp`** (Apple only): a namespace-scope `extern char** environ;`, the declaration `vk_menu.cpp` and `vk_bug_report.cpp` already use. `_environ` keeps its spelling, which `tests/test_program_stamp_knobs.py` looks for. libdyld exports `environ` on both architectures, so the strict `-undefined error` link of the Vulkan dylib resolves it. - **`host/hos_main.c`:** the eight guards read `#if defined(_WIN32) || defined(__linux__) || defined(__APPLE__)`. Every call inside has a macOS provider, nothing is stubbed: the SRW locks (`host/posix/windows.h` over the waits PR's `darwin_wait.c`), `GetAsyncKeyState`, `GetForegroundWindow` and `GetWindowThreadProcessId` (`win32_posix.c`), `GetCurrentProcessId`, `hos_flight_input`, `hos_free_camera_input` and `hos_move_stick_held` (`nn_hid.c`), `hos_now_ns`, `hos_sys_alloc`, `rx_option_set`, and libSystem's math and pthread calls. The `#else` stubs stay for the web build. - **`tests/test_debug_tools_linux.py`:** it evaluates each guard for Windows, Linux and now macOS, and also checks the seven functions `host/control.c`'s game table names (17 entries in all). Before, a guard naming a third platform would have counted as unknown, so the test could no longer have caught one that dropped `_WIN32` or `__linux__`. ## Flags and settings None new. The program life log (`RX_VK_LOG_PROGRAM_LIFE=1`) writes `major_faults unavailable` on macOS; the same line elsewhere is unchanged. ## Measurements main: `5e072fc8c2adadba5ea610148be1c47800ba0cca` (2026-11-14) this PR: `mac/renderer-compile` @ `bf85ed4ae0cff08dd6a38df9bcce9c3314d26b39` Hardware: Apple M4 Max, 16 cores, 64 GiB, macOS 26.7.1; Apple clang 21.0.0 (Command Line Tools, SDK 27); Python 3.14.10. No GPU, no game. Scene: none. Game-free. Method: - **Compiles:** `vk_programs.cpp` and `vk_shader.cpp`, for arm64 and for x86_64, with `nx2/build.py`'s own renderer command (`renderer_flags()`, plus the `LONGSHOT_SHADER_STAMP` the build computes for `vk_shader.cpp`). `main`'s `nx2/build.py` has no macOS commands, so both sides took them from the build-flags PR (#453), whose `gpu/` is `main`'s byte for byte: `main`'s two files on one side, this PR's on the other. A compile is deterministic, so one run per file and architecture. - **Test:** `tests/test_debug_tools_linux.py` from this PR, run on this PR's tree and on a copy holding `main`'s `host/hos_main.c`, interleaved: PR, main, PR, main. `main`'s own version of the test also runs on this PR's tree. - **Suite:** `tests/run_all.py --jobs 6` on this PR, compared by test name with a `main` run on the same Mac. How to reproduce: `python -I -B tests/test_debug_tools_linux.py` (it reads `host/hos_main.c` beside it). For the compiles, a macOS build with the build-flags PR, or `nx2/build.py`'s `renderer_flags()` on its own. | | main @ 5e072fc8 | this PR @ bf85ed4a | |---|---|---| | `vk_programs.cpp`, arm64 and x86_64 | error: `RUSAGE_THREAD` undeclared | Mach-O object (arm64 `6d45acdc…`, x86_64 `5973bbfe…`) | | `vk_shader.cpp`, arm64 and x86_64 | 2 errors: `environ` undeclared | Mach-O object (arm64 `d892778d…`, x86_64 `d19af652…`) | | `tests/test_debug_tools_linux.py`, runs 1 and 2 | exit 1: 26 lines of the debug tools not compiled on macOS | exit 0: `ok: the 17 debug tools are compiled on Windows, Linux, macOS` | | full game-free suite | 525 passed, 19 failed, 17 skipped | 525 passed, 19 failed, 17 skipped | ``` main @ 5e072fc8 (each architecture): gpu/vk/vk_programs.cpp:46:19: error: use of undeclared identifier 'RUSAGE_THREAD' gpu/vk/vk_shader.cpp:1306:21: error: use of undeclared identifier 'environ'; did you mean 'env_on'? gpu/vk/vk_shader.cpp:1306:17: error: cannot initialize a variable of type 'char **' with an lvalue of type 'bool (const char *)' main @ 5e072fc8, tests/test_debug_tools_linux.py (each run; 26 such lines): host/hos_main.c:581 (static int oot_pouch_change(Ctx *c, const char *name, int delta) {) is not compiled on macOS host/hos_main.c:1129 (int hos_oot_state(int *event, int *loading, int *child) {) is not compiled on macOS host/hos_main.c:1160 (int hos_oot_teleport_ask(int index) {) is not compiled on macOS this PR @ bf85ed4a: ok: the 17 debug tools are compiled on Windows, Linux, macOS ``` `vk_shader.cpp`'s shader stamp for this build command changes from `0xbc2a6a5c36fef83f` (main) to `0xcbcf3214c5e45816` (this PR): that is the one-time cache rebuild. ## Testing **Tested:** - The compiles and the test, as above. `main`'s own `tests/test_debug_tools_linux.py` also passes on this PR's `hos_main.c` (`ok: the 10 debug tools are compiled on Windows and Linux`). - **Windows and Linux see the same text** (`unifdef`, text only, not a build): - `unifdef -U__APPLE__` of this PR's `vk_programs.cpp` and `vk_shader.cpp` equals `main`'s files byte for byte; - `host/hos_main.c` with `-D_WIN32 -U__linux__ -U__APPLE__` (1665 lines) and with `-U_WIN32 -D__linux__ -U__APPLE__` (1898 lines) equals `main`'s. - **The whole suite**, `tests/run_all.py --jobs 6`, on the same Mac: ``` main @ 5e072fc8: 525 passed, 19 failed, 17 skipped in 177 s (linux, 6 at once) this PR @ bf85ed4a: 525 passed, 19 failed, 17 skipped in 174 s (linux, 6 at once) ``` - By test name, no check changed status: `tests/test_debug_tools_linux.py` passes on both (`main`'s version checks Windows and Linux only). The same 17 skips. - The same 19 checks fail on both. They are macOS portability failures of `main`, which other macOS pull requests address: `test_appimage_package_retry`, `test_collect_wide`, `test_control`, `test_framegen_resources`, `test_game_layout`, `test_low_memory_notice`, `test_mem_gate`, `test_mem_gate_children`, `test_mirror_trim`, `test_module_ids`, `test_oot_state_tap`, `test_pad_layout`, `test_pcache_header_read`, `test_pipeline_cache_file`, `test_pipeline_cache_save`, `test_pipeline_play_cache`, `test_prof_symbols`, `test_program_cache_cleanup`, `test_program_cache_one_variant`. - No new crash report; the tree was clean before and after. - **History, not rerun on this branch:** when these two commits were first made (`05b5d88f`, `d26e5f88`, on the macOS integration branch), a replay of a macOS executable link with the new `hos_main.c` object linked with no undefined symbol, where it had 7 before. Integration builds that carry them have since built both images and started the game on macOS (see #420). That speaks for those builds, not for this branch alone. **Not tested:** - A Windows or Linux build, and a game start there. - A full macOS build of this branch: on `main` plus this PR alone, macOS has no build commands (#453) and lacks the other macOS host PRs. - The debug tools themselves on macOS (cheats, teleport, flight, free view) in a game. - macOS 14.4 itself, whose libdyld exports `environ` per the SDK's `.tbd` (`vk_menu.cpp` relies on it already). **Needs other testers:** - Windows (llvm-mingw) and Linux: build and start the game once; the shader caches rebuild once, and nothing else changes. With `RX_VK_LOG_PROGRAM_LIFE=1`, the create lines still end `major_faults <n>` (request to open). ## Screenshots Nothing on screen. ## Risk and rollback - **Every platform:** `vk_shader.cpp` is hashed into `LONGSHOT_SHADER_STAMP` (`nx2/build.py:1176-1182`), so after updating, the first start translates the shader programs again, as with any edit to that file. Nothing else changes off Apple: the preprocessed text is `main`'s. - **macOS:** the life log has no per-thread fault count; a reader comparing create calls by `major_faults` sees `unavailable` instead. - **Rollback:** revert the two commits. ## Reviewer notes - Review `5e072fc8..bf85ed4a`: two commits, no dependency. `7f40bab2` is the renderer's two files; `bf85ed4a` is the debug tools and their test. - The debug tools now compile on macOS, so two existing warnings show there under `-Wall` (the build passes `-Wno-everything`): `-Wlogical-not-parentheses` at `!child == bridge_adult` (intended: the adult flag compared with the bridge's) and an unused `oot_item_kinds`. Linux and Windows compile the same code today. - The test keeps its file name (`test_debug_tools_linux.py`); renaming it was left out. - Against `main` at `dc390e59` (7 commits after this branch's base), `git merge-tree` finds a conflict in `host/hos_main.c`; a rebase before ready resolves it. #370 there moves the stamp's file list to `nx2/translator_files.py`, which still names `vk_shader.cpp`, so the one-time cache rebuild holds on both bases. ## Issues See #420. ## Checklist ### For everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`). - [ ] Rebased on current `main`. Based on 5e072fc8; `main` has since moved to dc390e59 (a conflict named under Reviewer notes). Rebased before ready. - [x] `python -I -B tests/run_all.py` run and passing (any failure that also fails on `main` is named above). On macOS: 525 passed, 17 skipped, and the same 19 failures as `main`, named under Testing. - [x] Tested in the game, or what wasn't is named under Testing. No game run on this branch; named under Testing. - [ ] Testing filled in: what was tested, what wasn't, and what needs other testers (with test requests). The test request is still to open. - [x] Measured: main and this PR at named commits, on the same PC, scene and settings, at least 2 interleaved runs each, the median reported. For a `fix`: the test fails on `main` and passes here in two interleaved runs; the compiles fail on `main` and build here. - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### If applicable - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] A game-free test added for the fix, failing on `main` and passing here. `tests/test_debug_tools_linux.py` now checks macOS; the renderer files' proof is the compile above. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [ ] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. Not built there; the preprocessed text is `main`'s. Request to open.
vk_programs.cpp: the life log's thread_major_faults() asked getrusage for
RUSAGE_THREAD, which Darwin lacks. Darwin keeps no count of one thread's
major faults: getrusage takes RUSAGE_SELF and RUSAGE_CHILDREN only, and the
per-thread thread_info flavours (THREAD_BASIC_INFO, THREAD_EXTENDED_INFO,
which is proc_threadinfo) hold run times and scheduling, no faults or
page-ins; task_events_info, proc_taskinfo and rusage_info count the whole
task. Rather than log another thread's faults or a 0 as this create call's,
the create line there ends "major_faults unavailable".

vk_shader.cpp: translator_stamp's _environ is environ, which Darwin's
headers do not declare for C++; it gets the namespace-scope declaration
vk_menu.cpp and vk_bug_report.cpp already use (libdyld exports it).

Both are Apple-only branches: with __APPLE__ undefined the files are
byte-identical to before (unifdef -U__APPLE__).

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(macos): the debug tools are compiled on Darwin too
All checks were successful
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
PR description / Description follows the template (pull_request_target) Successful in 5s
CI / Workflow lint (actionlint) (pull_request) Successful in 7s
Third-party parts / As their notes say (pull_request) Successful in 8s
bf85ed4ae0
host/hos_main.c's eight debug-tool guards (cheats, pouch and inventory,
clock, teleport and age, flight, lift, free view) named only _WIN32 and
__linux__, so a Darwin build compiled them out, and its executable did not
link: host/control.c's game table names hos_oot_current_map,
hos_oot_destination, hos_oot_teleport_ask, hos_oot_teleport_result,
hos_oot_teleport_cancel, hos_oot_age_ask and hos_oot_state.

Every call in those regions has a Darwin provider, nothing stubbed: the SRW
locks (windows.h's Darwin branch over darwin_wait.c), GetAsyncKeyState,
GetForegroundWindow and GetWindowThreadProcessId (win32_posix.c),
GetCurrentProcessId, hos_flight_input, hos_free_camera_input and
hos_move_stick_held (nn_hid.c), hos_now_ns, hos_sys_alloc, rx_option_set,
and libSystem's math and pthread calls.

tests/test_debug_tools_linux.py now evaluates the conditions for macOS as
well and checks the seven functions the game table names; with the old
guards it fails on macOS. Windows and Linux preprocess to the same text as
before (unifdef per platform).

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
All checks were successful
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 4s
PR description / Description follows the template (pull_request_target) Successful in 5s
CI / Workflow lint (actionlint) (pull_request) Successful in 7s
Third-party parts / As their notes say (pull_request) Successful in 8s
This pull request has changes conflicting with the target branch.
  • host/hos_main.c
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'mac/renderer-compile:mooki-mac/renderer-compile'
git switch 'mooki-mac/renderer-compile'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!492
No description provided.