Skip to content

Conversation

@SuuperW
Copy link

@SuuperW SuuperW commented Nov 28, 2025

Arisotura and others added 30 commits August 15, 2025 22:32
* Upgrade to 2025.07.25
* Configure vcpkg settings in vcpkg.json, this avoids needing to
  duplicate the vcpkg hash used in several places, and also avoids
  needing to set overlay ports/triplets directories from CMake
* Add caching workaround so that builds won't take forever every time
* Build on windows-2025
Call JitEnableWrite() immediately following the allocation of the JIT
code memory in the x64 compiler to make certain that it is in RW mode.

This call is made following allocation in the A64 compiler already, see
9ad3d42 ("hopefully fix macos").

Switching the memory protection between RW and RX is required on systems
that enforce an executable-space protection policy, such as NetBSD and
OpenBSD, with PaX MPROTECT and W^X respectively.

However, adherence to these policies for these platforms is not
implemented yet, so at this moment in time this call should be a no-op
on x64.
Call mprotect to switch the code memory protection between RW and RX
when needed on NetBSD, which is required due to PaX MPROTECT being
enabled on all binaries by default by the operating system.

This removes the need to run `paxctl +m melonDS`.

This patch was tested on a x64 VM running NetBSD 10.1. I can confirm
that this fixes JIT on NetBSD, however fastmem does not work as of yet
due to a segfault.

Although invoking mprotect does incur a performance penalty, it is still
faster than running without JIT.

A potentially faster alternative is to back the JIT code memory with an
anonymous file descriptor in physical memory, then map this physical
memory to two virtual memory addresses: one with RW permissions for code
generation, the other with RX permissions for code execution.

Instead of using platform-specific methods to create the anonymous file
descriptor, such as memfd_create on Linux, we could copy a 'trick' that
we use in fastmem already: calling shm_open, a POSIX standard, with a
random name, and immediately unlinking it.

However, this would add some more complexity and would be a bit harder
to implement. For now, this works fine. Perhaps another time...
Call the reset function of the JIT object instead of resetting the block
cache directly when disabling the JIT compiler, to ensure that the
protection on the code memory is switched to RW as required.

It is imperative that calls to ResetBlockCache() directly must be
preceeded by JitEnableWrite() to comply with executable-space protection
on systems that require it.

This fixes a segfault on NetBSD, due its PaX MPROTECT policy, that
occured when disabling JIT during runtime.
Set the protection on the code memory to RW when the fault handler
rewrites code, and set it back to RX, the protection prior to the
interrupt, after doing so.

This fixes a segfault that occurred on NetBSD, due to its PaX MPROTECT
policy, when trying to run fastmem.

This could potentially be the reason as to why fastmem does not work on
Apple Silicon Macs, although I am unable to confirm as I do not possess
such a device to test with.
* sockaddr_in is a forward declaration on *BSD, explicitly include the correct header

* fix building with ENABLE_JIT on OpenBSD targets

* add wxallowed linker flag for openbsd targets

* OpenBSD armjit sc_exr -> sc_elr

* wxallowed -> wxneeded

* force mmap for jit on OpenBSD

* disable fastmem on OpenBSD

* fix typo in disabling fastmem for OpenBSD

* add missing space in this if
* fix: GDB stub reading wrong code for vCont packet

* Implementation did contain bug, fixup
Adapt the existing OpenBSD workflow to also run on FreeBSD and NetBSD,
using the dynamic-uses action and a matrix strategy for each OS.
Cast the data pointer to const u8*, not u8*, to fix a compiler warning.
)

* Add high-quality resampling using blip-buf to the core

This also gets rid of the need for the frontend to resample the audio,
as it can simply ask the core to produce audio at whatever sample rate
it desires.

* allow setting an audio output skew to alter the timing slightly
  This makes up for the difference of e.g. the frontend targeting a clean
  60FPS instead of the actual 59.8...FPS.

* remove hack that was used to have the SPU produce silence
This removes the need to include private headers from QtGui, which
should remove the need to install the relevant package and make melonDS
easier to build in nonstandard environments.
fixes the Qt dependency on macOS
Arisotura and others added 17 commits November 6, 2025 22:00
* support for importing cheats from usrcheat.dat
* expand cheat format to add support for the extra info in usrcheat.dat
* add said features to the cheat editor
* improve cheat editor UI (add support for moving stuff around, etc)
Fixes audioGetNumSamplesOut sometimes breaking audio completely on start
because of using the value uninitialized.

Full credit to Arisotura for somehow figuring this one out
* Fix glMemoryBarrier flags

* Scale TileSize with internal resolution

* Clean up tile size calc

* Use a different CoarseTileCountY with size 32 tiles

* Better tile scaling calc

* Actually good way to get the MS bit

* Tie BinCombined's local_size_x to the coarse tiles' area

* Work count X is unrelated to the local size here

* Adjust ClearCoarseBinMask's local size according to TileSize

* Add extra barrier for radeonsi.
* Basic support for building with Visual Studio/clang-cl

Clang is required, MSVC support needs too many code changes.
ARM64 doesn't seem to work at the moment because of a bug in Qt.

* Fix close being used instead of closesocket in GdbStub in Windows

The GdbStub was closing sockets on windows by using "close" rather than "closesocket"

* fix the gdbstub unconditionally including unistd.h on windows and make it default-on again

* detect VS toolchain and arm64 with vcpkg, also get rid of some warnings
on Windows

* fix Qt indexOf ambiguity

* stupid math library issues

* add _USE_MATH_DEFINES so M_PI exists
* work around faad2 uncondtionally linking libm even on Windows where it doesn't exist

* Fix JIT linkage code for x86-64 in clang-cl builds

* Make it build with non-cl clang as well

* fix closesocket change breaking on macOS due to missing unistd include

* little build cleanups

---------

Co-authored-by: Edoardo Lolletti <[email protected]>
Co-authored-by: Gloria Goertz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants