diff --git a/.gitignore b/.gitignore
index 2b342e5145..dfceb4776d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,11 @@ doc-build/
AppDir/
uruntime
+dtrace-output/
+dtrace-out/
+log.txt
+*.core
+
# Generated source files
src/common/scm_rev.cpp
dist/english_plurals/generated_en.ts
diff --git a/.patch/spirv-tools/0001-netbsd-fix.patch b/.patch/spirv-tools/0001-netbsd-fix.patch
new file mode 100644
index 0000000000..e4b71f2938
--- /dev/null
+++ b/.patch/spirv-tools/0001-netbsd-fix.patch
@@ -0,0 +1,14 @@
+diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
+index eb4e69e..3155805 100644
+--- a/external/CMakeLists.txt
++++ b/external/CMakeLists.txt
+@@ -72,7 +72,8 @@ if (SPIRV_TOOLS_USE_MIMALLOC)
+ pop_variable(MI_BUILD_TESTS)
+ endif()
+
+-if (DEFINED SPIRV-Headers_SOURCE_DIR)
++# NetBSD doesn't have SPIRV-Headers readily available on system
++if (DEFINED SPIRV-Headers_SOURCE_DIR AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD")
+ # This allows flexible position of the SPIRV-Headers repo.
+ set(SPIRV_HEADER_DIR ${SPIRV-Headers_SOURCE_DIR})
+ else()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bc390d01b6..e32bc0eb2b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,8 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(PLATFORM_FREEBSD ON)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
set(PLATFORM_OPENBSD ON)
+elseif (${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD")
+ set(PLATFORM_NETBSD ON)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(PLATFORM_LINUX ON)
endif()
@@ -41,8 +43,7 @@ if (PLATFORM_SUN)
list(APPEND CMAKE_PREFIX_PATH "/usr/lib/qt/6.6/lib/amd64/cmake")
list(APPEND CMAKE_MODULE_PATH "/usr/lib/qt/6.6/lib/amd64/cmake")
- # amazing
- # absolutely incredible
+ # Amazing - absolutely incredible
list(APPEND CMAKE_PREFIX_PATH "/usr/lib/amd64/cmake")
list(APPEND CMAKE_MODULE_PATH "/usr/lib/amd64/cmake")
@@ -63,6 +64,15 @@ if (PLATFORM_OPENBSD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/X11R6/include")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/X11R6/include")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/X11R6/lib")
+elseif (PLATFORM_NETBSD)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/X11R7/include")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/X11R7/include")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/X11R7/lib")
+endif()
+
+# NetBSD: Fun for the whole family!
+if (PLATFORM_NETBSD)
+ set(ENV{PKG_CONFIG_PATH} "${PKG_CONFIG_PATH}:/usr/pkg/lib/ffmpeg7/pkgconfig")
endif()
# Detect current compilation architecture and create standard definitions
@@ -149,6 +159,7 @@ endif()
if (PLATFORM_FREEBSD)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
+
endif()
# Set bundled sdl2/qt as dependent options.
@@ -355,7 +366,7 @@ if (YUZU_ROOM)
add_compile_definitions(YUZU_ROOM)
endif()
-if (ANDROID OR PLATFORM_FREEBSD OR PLATFORM_OPENBSD OR PLATFORM_SUN OR APPLE)
+if ((ANDROID OR APPLE OR UNIX) AND (NOT PLATFORM_LINUX OR ANDROID) AND NOT WIN32)
if(CXX_APPLE OR CXX_CLANG)
# libc++ has stop_token and jthread as experimental
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexperimental-library")
diff --git a/docs/Caveats.md b/docs/Caveats.md
index 7bc2428bab..2a605b9844 100644
--- a/docs/Caveats.md
+++ b/docs/Caveats.md
@@ -49,4 +49,10 @@ After configuration, you may need to modify `externals/ffmpeg/CMakeFiles/ffmpeg-
Eden is not currently available as a port on FreeBSD, though it is in the works. For now, the recommended method of usage is to compile it yourself.
-The available OpenSSL port (3.0.17) is out-of-date, and using a bundled static library instead is recommended; to do so, add `-DYUZU_USE_BUNDLED_OPENSSL=ON` to your CMake configure command.
\ No newline at end of file
+The available OpenSSL port (3.0.17) is out-of-date, and using a bundled static library instead is recommended; to do so, add `-DYUZU_USE_BUNDLED_OPENSSL=ON` to your CMake configure command.
+
+## NetBSD
+
+System provides a default `g++-10` which doesn't support the current C++ codebase; install `clang-19` with `pkgin install clang-19`. Then build with `cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -B build`.
+
+Make may error out when generating C++ headers of SPIRV shaders, hence it's recommended to use `gmake` over the default system one.
diff --git a/docs/Deps.md b/docs/Deps.md
index b8a1be66d2..6777e3af9f 100644
--- a/docs/Deps.md
+++ b/docs/Deps.md
@@ -145,35 +145,33 @@ brew install molten-vk vulkan-loader
FreeBSD
-```
-devel/cmake
-devel/sdl20
-devel/boost-libs
-devel/catch2
-devel/libfmt
-devel/nlohmann-json
-devel/ninja
-devel/nasm
-devel/autoconf
-devel/pkgconf
-devel/qt6-base
-
-net/enet
+As root run: `pkg install devel/cmake devel/sdl20 devel/boost-libs devel/catch2 devel/libfmt devel/nlohmann-json devel/ninja devel/nasm devel/autoconf devel/pkgconf devel/qt6-base devel/simpleini net/enet multimedia/ffnvcodec-headers multimedia/ffmpeg audio/opus archivers/liblz4 lang/gcc12 graphics/glslang graphics/vulkan-utility-libraries graphics/spirv-tools www/cpp-httplib devel/jwt-cpp devel/unordered-dense devel/zydis`
-multimedia/ffnvcodec-headers
-multimedia/ffmpeg
+If using FreeBSD 12 or prior, use `devel/pkg-config` instead.
+
-audio/opus
+
+NetBSD
-archivers/liblz4
+Install `pkgin` if not already `pkg_add pkgin`, see also the general [pkgsrc guide](https://www.netbsd.org/docs/pkgsrc/using.html). For NetBSD 10.1 provide `cat 'PKG_PATH="https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/10.0_2025Q3/All/"' >/etc/pkg_install.conf`. If `pkgin` is taking too much time consider adding the following to `/etc/rc.conf`:
+```
+ip6addrctl=YES
+ip6addrctl_policy=ipv4_prefer
+```
-lang/gcc12
+For NetBSD +10.1: `pkgin install git cmake boost fmtlib SDL2 catch2 libjwt spirv-headers ffmpeg7 libva nlohmann-json jq libopus qt6 mbedtls3 cpp-httplib lz4 vulkan-headers nasm autoconf enet pkg-config`.
-graphics/glslang
-graphics/vulkan-utility-libraries
+glslang is not available on NetBSD, to circumvent this simply build glslang by yourself:
+```sh
+pkgin python313
+git clone https://github.com/KhronosGroup/glslang.git
+cd glslang
+python3.13 ./update_glslang_sources.py
+cmake -B build -DCMAKE_BUILD_TYPE=Release
+cmake --build build -- -j`nproc`
+cmake --install build
```
-If using FreeBSD 12 or prior, use `devel/pkg-config` instead.
diff --git a/src/dynarmic/tests/native/testenv.h b/src/dynarmic/tests/native/testenv.h
index 7a3d14eea0..9cbe52f736 100644
--- a/src/dynarmic/tests/native/testenv.h
+++ b/src/dynarmic/tests/native/testenv.h
@@ -4,6 +4,19 @@
#ifdef __AVX__
#include
#endif
+
+// NetBSD apparently still needs these... ugh
+#ifdef __cpp_lib_bit_cast
+#include
+template constexpr inline To BitCast(const From& from) {
+ return std::bit_cast(from);
+}
+#else
+template constexpr inline To BitCast(const From& from) {
+ return __builtin_bit_cast(To, from);
+}
+#endif
+
template
void CheckedRun(F&& fn) {
#ifdef __AVX__
@@ -32,18 +45,18 @@ void CheckedRun(F&& fn) {
, "+x"(xmm8), "+x"(xmm9), "+x"(xmm10), "+x"(xmm11)
:
);
- CHECK(std::bit_cast(xmm0[0]) == 0);
- CHECK(std::bit_cast(xmm1[0]) == 1);
- CHECK(std::bit_cast(xmm2[0]) == 2);
- CHECK(std::bit_cast(xmm3[0]) == 3);
- CHECK(std::bit_cast(xmm4[0]) == 4);
- CHECK(std::bit_cast(xmm5[0]) == 5);
- CHECK(std::bit_cast(xmm6[0]) == 6);
- CHECK(std::bit_cast(xmm7[0]) == 7);
- CHECK(std::bit_cast(xmm8[0]) == 8);
- CHECK(std::bit_cast(xmm9[0]) == 9);
- CHECK(std::bit_cast(xmm10[0]) == 10);
- CHECK(std::bit_cast(xmm11[0]) == 11);
+ CHECK(BitCast(xmm0[0]) == 0);
+ CHECK(BitCast(xmm1[0]) == 1);
+ CHECK(BitCast(xmm2[0]) == 2);
+ CHECK(BitCast(xmm3[0]) == 3);
+ CHECK(BitCast(xmm4[0]) == 4);
+ CHECK(BitCast(xmm5[0]) == 5);
+ CHECK(BitCast(xmm6[0]) == 6);
+ CHECK(BitCast(xmm7[0]) == 7);
+ CHECK(BitCast(xmm8[0]) == 8);
+ CHECK(BitCast(xmm9[0]) == 9);
+ CHECK(BitCast(xmm10[0]) == 10);
+ CHECK(BitCast(xmm11[0]) == 11);
#else
fn();
#endif