From fe7a34c56ee61cdc40483b3adabdee94acf78ee8 Mon Sep 17 00:00:00 2001 From: James Dansereau <106631954+jkdansereau@users.noreply.github.com> Date: Wed, 2 Sep 2026 22:31:33 -0400 Subject: [PATCH] linux-build: port/shim/sched.h routes C++ TUs to the host The decomp's src/sched.h (N64 OSSc* scheduler) is on the include path and shadows the system header. libstdc++'s / gthr headers in the fast3d C++ TUs #include and need the real one (cpu_set_t, sched_yield) -- with -std=gnu++20 libstdc++ defines _GNU_SOURCE so also references cpu_set_t. New shim: C++ -> generated hostsched.h (absolute path, hoststring pattern); C -> #include_next so src/sched.h still wins as before. Windows build verified green (240/241). --- CMakeLists.txt | 9 +++++++++ port/include/hostsched.h.in | 9 +++++++++ port/shim/sched.h | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 port/include/hostsched.h.in create mode 100644 port/shim/sched.h diff --git a/CMakeLists.txt b/CMakeLists.txt index cc7a56d3..ebf19ccd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,6 +152,15 @@ configure_file( "${CMAKE_SOURCE_DIR}/port/include/hoststring.h.in" "${CMAKE_BINARY_DIR}/port/include/hoststring.h" @ONLY) +# Host path for port/shim/sched.h. The decomp's src/sched.h is on +# the include path and shadows the system header; libstdc++'s /gthr +# headers in the fast3d C++ TUs need the real (cpu_set_t, +# sched_yield). Both MinGW and Linux keep at bin/../include. +get_filename_component(PORT_HOST_SCHED_H "${_PORT_GCC_DIR}/../include/sched.h" ABSOLUTE) +configure_file( + "${CMAKE_SOURCE_DIR}/port/include/hostsched.h.in" + "${CMAKE_BINARY_DIR}/port/include/hostsched.h" @ONLY) + # Host path for port/shim/stdlib.h. The N64 include/stdlib.h # typedefs lldiv_t/ldiv_t, which conflict with the host's when both land in # one C++ TU (fast3d): MinGW's own sec_api/stdlib_s.h does `#include diff --git a/port/include/hostsched.h.in b/port/include/hostsched.h.in new file mode 100644 index 00000000..6d15a3f1 --- /dev/null +++ b/port/include/hostsched.h.in @@ -0,0 +1,9 @@ +#ifndef PORT_HOSTSCHED_H +#define PORT_HOSTSCHED_H +/* Generated by CMake from hostsched.h.in — do not edit. + * Includes the HOST by absolute path so that port/shim/sched.h can + * give C++ TUs (fast3d, libstdc++'s /gthr headers) the real + * — cpu_set_t, sched_yield — instead of the decomp's src/sched.h, + * which sits on the include path and would otherwise shadow it. */ +#include "@PORT_HOST_SCHED_H@" +#endif diff --git a/port/shim/sched.h b/port/shim/sched.h new file mode 100644 index 00000000..256c003d --- /dev/null +++ b/port/shim/sched.h @@ -0,0 +1,18 @@ +/* + * PC port shim for . + * + * The decomp ships src/sched.h (the N64 OSSc* scheduler client interface), + * which is on the compiler include path. libstdc++'s / gthr headers + * (pulled into the fast3d C++ TUs) do `#include ` and need the HOST + * header — cpu_set_t, sched_yield — so C++ TUs must be routed to the real + * by absolute path (generated hostsched.h, same trick as + * port/shim/string.h). C TUs keep resolving to the decomp's own + * src/sched.h, exactly as on the console. + * + * Inert in the N64 build (port/shim is not on its include path). + */ +#if defined(__cplusplus) +#include "hostsched.h" +#else +#include_next +#endif