Files
griches--PS5_SwitchWaker/ps5/tools/cc-init-array.sh
T
Gary Riches 3c17fb22d6 Wind Waker (GameCube) for PlayStation 5: SwitchWaker on the PS5 Vulkan stack
Title PPSA99309. The build holds no game data: the player's own GZLE01 disc
image is read from the title's folder at start. 16:9, 3840x2160 output, 60 fps
by frame interpolation, DualSense symbols on the HUD, shader caches from a
console shipped and seeded on a first start. First run on a console 2026-10-12.

Claude-Session: https://claude.ai/code/session_018jvMS8Y8okH8SDZUfd8MP1
2026-10-12 15:56:25 +01:00

30 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# Wind Waker for the PlayStation 5 - compile with an init array (a compiler launcher).
#
# cc-init-array.sh COMPILER ARGUMENT...
#
# Clang's PS5 target writes constructors to .ctors, last to first, for a
# start-up that walks them backwards, and its driver refuses -fuse-init-array.
# PS5_Vulkan's CRT walks the merged array forwards, so a unit's initialisers
# ran in reverse: Dusklight's inline tables (one initialiser each, the later
# built from the earlier) read a std::map that was not constructed yet.
#
# The switch is the driver's alone: it passes -fno-use-init-array to the
# compiler proper. This asks the driver for that command (-###), drops the
# flag and runs it, which gives .init_array in the order the source has.
# Anything that is not one compile (-c) runs unchanged.
#
# SPDX-License-Identifier: MIT
case " $* " in
*" -c "*) ;;
*) exec "$@" ;;
esac
jobs=$("$@" '-###' 2>&1 | grep -- '^ *"') || exec "$@"
# one job, the compiler proper: a .S file is two (the preprocessor, then the assembler)
[ "$(printf '%s\n' "$jobs" | wc -l)" -eq 1 ] || exec "$@"
job=$(printf '%s\n' "$jobs" | grep -- ' "-cc1" ') || exec "$@"
case $job in
*'$'* | *'`'*) exec "$@" ;; # nothing the shell would expand
esac
eval "exec $(printf '%s' "$job" | sed 's/ "-fno-use-init-array"//')"