Skip to content

build(libusb): build libusb without pipe2 on macOS, where pipe2 needs macOS 27 - #19920

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
XIIYAZ:fix/libusb-pipe2-macos-before-27
Nov 15, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
XIIYAZ:fix/libusb-pipe2-macos-before-27

Conversation

@XIIYAZ

@XIIYAZ XIIYAZ commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

What

libusb-cmake sets HAVE_PIPE2 from check_function_exists(pipe2 HAVE_PIPE2). The macOS 27 SDK declares pipe2 with __API_AVAILABLE(macos(27.0), ...), so the check passes, usbi_create_event calls pipe2, and with a lower minimum version the symbol is weakly imported and null on macOS 26. sceUsbdInit then jumps to address 0:

* stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #1: libSceUsbd.prx`usbi_create_event + 20
    frame #2: libSceUsbd.prx`usbi_io_init + 248
    frame #3: libSceUsbd.prx`libusb_init_context + 704
    frame #4: libSceUsbd.prx`sceUsbdInit + 65

The compiler also warns 'pipe2' is only available on macOS 27.0 or newer at events_posix.c:87.

On Apple, HAVE_PIPE2 is now preset to false before add_subdirectory(3rdparty/libusb-cmake); check_function_exists skips a variable that is already defined, so libusb takes its own pipe + fcntl(FD_CLOEXEC) path, which works on every macOS version. No third-party file changes; Linux and Windows are unchanged. This is the libusb side of the libkernel pipe2 call fixed in #19903.

Tested

macOS 26.7.3, Apple M4, Xcode SDK 27.2, Apple clang 21.0.0, CMake 4.4.4, Ninja, full build (-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_OSX_ARCHITECTURES=x86_64, tests under Rosetta) on main with #17425, #11049, #11437 and #19903 merged locally:

  • Before: guest_usbd segfaults with the backtrace above.
  • After: the generated libusb config.h has /* #undef HAVE_PIPE2 */, the events_posix.c availability warning is gone, and guest_usbd passes.

python3 tools/check_conventions.py --base origin/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@ycbuzi

ycbuzi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Tested 678bfa24dc merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Linux: Debian 13 in ChromeOS's Linux environment on a Pentium Silver N6000 (4 cores, SSE4.2, no AVX), GCC 14.2.0, relinker-only build (-DANYPS5_RELINKER_ONLY=ON): run 1: 99% tests passed, 5 tests failed out of 907; run 2: 99% tests passed, 5 tests failed out of 907; run 3: 99% tests passed, 5 tests failed out of 907. 5 of the failing tests fail on main too.

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 1835 CMakeLists.txt
PR 7642 CMakeLists.txt
PR 9508 CMakeLists.txt
PR 10193 CMakeLists.txt
PR 10897 CMakeLists.txt
PR 13928 CMakeLists.txt
PR 13929 CMakeLists.txt
PR 16391 CMakeLists.txt
PR 17558 CMakeLists.txt

@kali113

kali113 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Tested on macOS: Apple M5 Pro, macOS 27.2.1, x86_64 build under Rosetta, Vulkan SDK 1.4.363.1 (MoltenVK).

I haven't looked into the causes.

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit 575b0a8 into boykopovar:main Nov 15, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants