Several PsyQ compatibility entry points are unavailable in the linked PsyZ library

Open
#234 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
c, wasm

Research direction

Start by checking the PsyZ Emscripten library’s defined symbols at revision 35c673ecf1c4ba799a812d701918c2c52935475b and comparing them with the listed Matrix/GTE, SPU, Kernel, and GPU entry points. The issue provides repro.c and CMake instructions to reproduce the SPU linker failure. Done means the requested entry points are available in the portable library; validate each subsystem’s behavior with focused tests for the concerns listed in the issue.

Written by the indexing model from the issue text.

Description

PsyZ 35c673ecf1c4ba799a812d701918c2c52935475b declares several useful PsyQ
entry points without providing them in its Emscripten library. Existing game
code using those APIs needs local replacements before it can link.

Minimal reproduction

repro.c takes the address of the declared SpuSetCommonMasterVolume.
No audio initialization or game code is involved. Save the attachment as repro.c and build using the instructions below. Tested with Emscripten 6.0.13.

Actual linker result:

undefined symbol: SpuSetCommonMasterVolume

Expected: the declared compatibility entry point links successfully.

Scope found while porting

The following names are absent from the defined-symbol list of the built library:

Area Entry points
Matrix / GTE ApplyMatrixSV, Square0, RotTransSV, MulMatrix0, ApplyRotMatrixLV, Lzc
SPU SpuSetKeyOnWithAttr, SpuSetCommonMasterVolume, SpuSetCommonCDVolume, SpuSetCommonCDMix
Kernel SwEnterCriticalSection, SwExitCriticalSection
GPU SetDrawStp

Some names occur in the repository's decompilation tree as assembly placeholders;
that is different from being available in the portable library. This is an
inventory of names we needed, not a claim that all have identical implementation
complexity or that our replacements are complete PsyQ specifications.

The SPU link failure was reproduced directly. The rest were checked against the
built archive and source. Matrix saturation/flags, aliasing, kernel locking and
GPU command lengths need their own focused tests when implemented. This can be
split into subsystem issues if preferred; no graphics attachment is needed.

Building the standalone example

Save the attached file as repro.c, and place this CMakeLists.txt beside it:

cmake_minimum_required(VERSION 3.21)
project(sdk_link_repro C CXX)
set(CMAKE_C_STANDARD 11)
add_compile_options(-pthread)
add_link_options(-pthread)
set(SDL_PTHREADS ON CACHE BOOL "" FORCE)
add_subdirectory("${PSYZ_ROOT}/psyz" psyz EXCLUDE_FROM_ALL)
add_executable(repro repro.c)
target_link_libraries(repro PRIVATE psyz)
target_link_options(repro PRIVATE -sASSERTIONS=1 -sPTHREAD_POOL_SIZE=2)
psyz_web_configure_target(repro OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/site")

Use a PsyZ checkout at the revision above, with its SDL submodule initialized:

emcmake cmake -S . -B build -DPSYZ_ROOT=/path/to/psyz -DCMAKE_BUILD_TYPE=Release
cmake --build build -j8

This example is expected to fail at the link step on the recorded baseline; it does not need to be opened in a browser.

Dominant language
C
Stars
107
Forks
26
Avg merge
2d 21h
Merged PRs (30d)
5

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Xeeynamo/psyz

All issues in Xeeynamo/psyz

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.