SDL: removed NaCL support.

From e89a1f9157a938b0184c3a530134e3dec351c582 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 22 Nov 2022 20:10:47 +0300
Subject: [PATCH] removed NaCL support.

---
 build-scripts/nacl-buildbot.sh          |  61 ---
 build-scripts/naclbuild.sh              | 105 ------
 configure.ac                            |  50 ---
 docs/README-nacl.md                     | 103 -----
 docs/README.md                          |   1 -
 include/SDL_assert.h                    |   2 +-
 include/SDL_config.h.in                 |   3 -
 include/SDL_main.h                      |   9 -
 include/SDL_platform.h                  |  16 -
 src/SDL_log.c                           |   3 -
 src/audio/SDL_audio.c                   |   3 -
 src/audio/SDL_sysaudio.h                |   1 -
 src/audio/nacl/SDL_naclaudio.c          | 160 --------
 src/audio/nacl/SDL_naclaudio.h          |  42 ---
 src/dynapi/SDL_dynapi.h                 |   2 -
 src/file/SDL_rwops.c                    |   4 -
 src/filesystem/nacl/SDL_sysfilesystem.c |  43 ---
 src/main/nacl/SDL_nacl_main.c           |  93 -----
 src/render/opengles2/SDL_gles2funcs.h   |   4 -
 src/thread/pthread/SDL_systhread.c      |  14 +-
 src/video/SDL_sysvideo.h                |   1 -
 src/video/SDL_video.c                   |   5 +-
 src/video/nacl/SDL_naclevents.c         | 440 ----------------------
 src/video/nacl/SDL_naclevents_c.h       |  30 --
 src/video/nacl/SDL_naclglue.c           |  24 --
 src/video/nacl/SDL_naclopengles.c       | 174 ---------
 src/video/nacl/SDL_naclopengles.h       |  38 --
 src/video/nacl/SDL_naclvideo.c          | 187 ----------
 src/video/nacl/SDL_naclvideo.h          |  67 ----
 src/video/nacl/SDL_naclwindow.c         |  78 ----
 src/video/nacl/SDL_naclwindow.h         |  32 --
 test/nacl/Makefile                      |  63 ----
 test/nacl/background.js                 |  40 --
 test/nacl/common.js                     | 474 ------------------------
 test/nacl/index.html                    |  21 --
 test/nacl/manifest.json                 |  22 --
 test/testgles2.c                        |   7 +-
 test/testgles2_sdf.c                    |   7 +-
 38 files changed, 11 insertions(+), 2418 deletions(-)
 delete mode 100755 build-scripts/nacl-buildbot.sh
 delete mode 100755 build-scripts/naclbuild.sh
 delete mode 100644 docs/README-nacl.md
 delete mode 100644 src/audio/nacl/SDL_naclaudio.c
 delete mode 100644 src/audio/nacl/SDL_naclaudio.h
 delete mode 100644 src/filesystem/nacl/SDL_sysfilesystem.c
 delete mode 100644 src/main/nacl/SDL_nacl_main.c
 delete mode 100644 src/video/nacl/SDL_naclevents.c
 delete mode 100644 src/video/nacl/SDL_naclevents_c.h
 delete mode 100644 src/video/nacl/SDL_naclglue.c
 delete mode 100644 src/video/nacl/SDL_naclopengles.c
 delete mode 100644 src/video/nacl/SDL_naclopengles.h
 delete mode 100644 src/video/nacl/SDL_naclvideo.c
 delete mode 100644 src/video/nacl/SDL_naclvideo.h
 delete mode 100644 src/video/nacl/SDL_naclwindow.c
 delete mode 100644 src/video/nacl/SDL_naclwindow.h
 delete mode 100644 test/nacl/Makefile
 delete mode 100644 test/nacl/background.js
 delete mode 100644 test/nacl/common.js
 delete mode 100644 test/nacl/index.html
 delete mode 100644 test/nacl/manifest.json

diff --git a/build-scripts/nacl-buildbot.sh b/build-scripts/nacl-buildbot.sh
deleted file mode 100755
index efd345b9ac92..000000000000
--- a/build-scripts/nacl-buildbot.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-
-# This is the script buildbot.libsdl.org uses to cross-compile SDL3 from
-#  amd64 Linux to NaCl.
-
-# PLEASE NOTE that we have reports that SDL built with pepper_49 (current
-#  stable release as of November 10th, 2016) is broken. Please retest
-#  when something newer becomes stable and then decide if this was SDL's
-#  bug or NaCl's bug.  --ryan.
-export NACL_SDK_ROOT="/nacl_sdk/pepper_47"
-
-TARBALL="$1"
-if [ -z $1 ]; then
-    TARBALL=sdl-nacl.tar.xz
-fi
-
-OSTYPE=`uname -s`
-if [ "$OSTYPE" != "Linux" ]; then
-    # !!! FIXME
-    echo "This only works on x86 or x64-64 Linux at the moment." 1>&2
-    exit 1
-fi
-
-if [ "x$MAKE" == "x" ]; then
-    NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
-    let NCPU=$NCPU+1
-    MAKE="make -j$NCPU"
-fi
-
-BUILDBOTDIR="nacl-buildbot"
-PARENTDIR="$PWD"
-
-set -e
-set -x
-rm -f $TARBALL
-rm -rf $BUILDBOTDIR
-mkdir -p $BUILDBOTDIR
-pushd $BUILDBOTDIR
-
-# !!! FIXME: ccache?
-export CC="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-clang"
-export CFLAGS="$CFLAGS -I$NACL_SDK_ROOT/include -I$NACL_SDK_ROOT/include/pnacl"
-export AR="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
-export LD="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
-export RANLIB="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ranlib"
-
-../configure --host=pnacl --prefix=$PWD/nacl-sdl3-installed
-$MAKE
-$MAKE install
-# Fix up a few things to a real install path
-perl -w -pi -e "s#$PWD/nacl-sdl3-installed#/usr/local#g;" ./nacl-sdl3-installed/lib/libSDL3.la ./nacl-sdl3-installed/lib/pkgconfig/sdl3.pc ./nacl-sdl3-installed/bin/sdl3-config
-mkdir -p ./usr
-mv ./nacl-sdl3-installed ./usr/local
-
-popd
-tar -cJvvf $TARBALL -C $BUILDBOTDIR usr
-rm -rf $BUILDBOTDIR
-
-set +x
-echo "All done. Final installable is in $TARBALL ...";
-
diff --git a/build-scripts/naclbuild.sh b/build-scripts/naclbuild.sh
deleted file mode 100755
index ad284d0e9521..000000000000
--- a/build-scripts/naclbuild.sh
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/bin/bash
-if [ -z "$1" ] && [ -z "$NACL_SDK_ROOT" ]; then
-    echo "Usage: ./naclbuild ~/nacl/pepper_35"
-    echo "This will build SDL for Native Client, and testgles2.c as a demo"
-    echo "You can set env vars CC, AR, LD and RANLIB to override the default PNaCl toolchain used"
-    echo "You can set env var SOURCES to select a different source file than testgles2.c"
-    exit 1
-fi
-
-if [ -n "$1" ]; then
-    NACL_SDK_ROOT="$1"
-fi
-
-CC=""
-
-if [ -n "$2" ]; then
-    CC="$2"
-fi
-
-echo "Using SDK at $NACL_SDK_ROOT"
-
-export NACL_SDK_ROOT="$NACL_SDK_ROOT"
-export CFLAGS="$CFLAGS -I$NACL_SDK_ROOT/include -I$NACL_SDK_ROOT/include/pnacl"
-
-NCPUS="1"
-case "$OSTYPE" in
-    darwin*)
-        NCPU=`sysctl -n hw.ncpu`
-        ;; 
-    linux*)
-        if [ -n `which nproc` ]; then
-            NCPUS=`nproc`
-        fi  
-        ;;
-  *);;
-esac
-
-CURDIR=`pwd -P`
-SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )"
-BUILDPATH="$SDLPATH/build/nacl"
-TESTBUILDPATH="$BUILDPATH/test"
-SDL3_STATIC="$BUILDPATH/build/.libs/libSDL3.a"
-mkdir -p $BUILDPATH
-mkdir -p $TESTBUILDPATH
-
-if [ -z "$CC" ]; then
-    export CC="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-clang"
-fi
-if [ -z "$AR" ]; then
-    export AR="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
-fi
-if [ -z "$LD" ]; then
-    export LD="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
-fi
-if [ -z "$RANLIB" ]; then
-    export RANLIB="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ranlib"
-fi
-
-if [ -z "$SOURCES" ]; then
-    export SOURCES="$SDLPATH/test/testgles2.c"
-fi
-
-if [ ! -f "$CC" ]; then
-    echo "Could not find compiler at $CC"
-    exit 1
-fi
-
-
-
-
-cd $BUILDPATH
-$SDLPATH/configure --host=pnacl --prefix $TESTBUILDPATH
-make -j$NCPUS CFLAGS="$CFLAGS -I./include"
-make install
-
-if [ ! -f "$SDL3_STATIC" ]; then
-    echo "Build failed! $SDL3_STATIC"
-    exit 1
-fi
-
-echo "Building test"
-cp -f $SDLPATH/test/nacl/* $TESTBUILDPATH
-# Some tests need these resource files
-cp -f $SDLPATH/test/*.bmp $TESTBUILDPATH
-cp -f $SDLPATH/test/*.wav $TESTBUILDPATH
-cp -f $SDL3_STATIC $TESTBUILDPATH
-
-# Copy user sources
-_SOURCES=($SOURCES)
-for src in "${_SOURCES[@]}"
-do
-    cp $src $TESTBUILDPATH
-done
-export SOURCES="$SOURCES"
-
-cd $TESTBUILDPATH
-make -j$NCPUS CONFIG="Release" CFLAGS="$CFLAGS -I$TESTBUILDPATH/include/SDL3 -I$SDLPATH/include"
-make -j$NCPUS CONFIG="Debug" CFLAGS="$CFLAGS -I$TESTBUILDPATH/include/SDL3 -I$SDLPATH/include"
-
-echo
-echo "Run the test with: "
-echo "cd $TESTBUILDPATH;python -m SimpleHTTPServer"
-echo "Then visit http://localhost:8000 with Chrome"
-
-cd $CURDIR
diff --git a/configure.ac b/configure.ac
index b92d0b8c9ff0..8371faa2ce02 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1529,33 +1529,6 @@ dnl See if libdecor is available
     fi
 }
 
-dnl Check for Native Client stuff
-CheckNativeClient()
-{
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-          #if !defined(__native_client__)
-          #error "NO NACL"
-          #endif
-        ]],[])], [
-        AC_DEFINE(SDL_VIDEO_DRIVER_NACL, 1, [ ])
-        AC_DEFINE(SDL_AUDIO_DRIVER_NACL, 1, [ ])
-        AC_DEFINE(HAVE_POW, 1, [ ])
-        AC_DEFINE(HAVE_OPENGLES2, 1, [ ])
-        AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
-        AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
-
-        SDL_LIBS="-lppapi_simple -lppapi_gles2 $SDL_LIBS"
-
-        SDLMAIN_SOURCES="$srcdir/src/main/nacl/*.c"
-        SOURCES="$SOURCES $srcdir/src/audio/nacl/*.c"
-        SUMMARY_audio="${SUMMARY_audio} nacl"
-        have_audio=yes
-        SOURCES="$SOURCES $srcdir/src/video/nacl/*.c"
-        SUMMARY_video="${SUMMARY_video} nacl opengles2"
-        have_video=yes
-        ],[])
-}
-
 CheckRPI()
 {
     AC_ARG_ENABLE(video-rpi,
@@ -4147,29 +4120,6 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-weak_framework,QuartzCore -Wl,-weak_framework,Metal"
         fi
         ;;
-    *-nacl|*-pnacl)
-        ARCH=nacl
-        CheckNativeClient
-        CheckDummyAudio
-        CheckDummyVideo
-        CheckOffscreenVideo
-        CheckInputEvents
-        CheckPTHREAD
-        CheckO_CLOEXEC
-
-        # Set up files for the timer library
-        if test x$enable_timers = xyes; then
-            AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
-            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
-            have_timers=yes
-        fi
-
-        if test x$enable_filesystem = xyes; then
-            AC_DEFINE(SDL_FILESYSTEM_NACL, 1, [ ])
-            SOURCES="$SOURCES $srcdir/src/filesystem/nacl/*.c"
-            have_filesystem=yes
-        fi
-        ;;
     *-*-emscripten* )
         if test x$enable_video = xyes; then
             AC_DEFINE(SDL_VIDEO_DRIVER_EMSCRIPTEN, 1, [ ])
diff --git a/docs/README-nacl.md b/docs/README-nacl.md
deleted file mode 100644
index 53ada33c31c1..000000000000
--- a/docs/README-nacl.md
+++ /dev/null
@@ -1,103 +0,0 @@
-Native Client
-================================================================================
-
-Requirements: 
-
-* Native Client SDK (https://developer.chrome.com/native-client), 
-  (tested with Pepper version 33 or higher).
-
-The SDL backend for Chrome's Native Client has been tested only with the PNaCl
-toolchain, which generates binaries designed to run on ARM and x86_32/64 
-platforms. This does not mean it won't work with the other toolchains!
-
-================================================================================
-Building SDL for NaCl
-================================================================================
-
-Set up the right environment variables (see naclbuild.sh), then configure SDL with:
-
-    configure --host=pnacl --prefix some/install/destination
-    
-Then "make". 
-
-As an example of how to create a deployable app a Makefile project is provided 
-in test/nacl/Makefile, which includes some monkey patching of the common.mk file 
-provided by NaCl, without which linking properly to SDL won't work (the search 
-path can't be modified externally, so the linker won't find SDL's binaries unless 
-you dump them into the SDK path, which is inconvenient).
-Also provided in test/nacl is the required support file, such as index.html, 
-manifest.json, etc.
-SDL apps for NaCl run on a worker thread using the ppapi_simple infrastructure.
-This allows for blocking calls on all the relevant systems (OpenGL ES, filesystem),
-hiding the asynchronous nature of the browser behind the scenes...which is not the
-same as making it disappear!
-
-
-================================================================================
-Running tests
-================================================================================
-
-Due to the nature of NaCl programs, building and running SDL tests is not as
-straightforward as one would hope. The script naclbuild.sh in build-scripts 
-automates the process and should serve as a guide for users of SDL trying to build 
-their own applications.
-
-Basic usage:
-    
-    ./naclbuild.sh path/to/pepper/toolchain (i.e. ~/naclsdk/pepper_35)
-    
-This will build testgles2.c by default.
-
-If you want to build a different test, for example testrendercopyex.c:
-    
-    SOURCES=~/sdl/SDL/test/testrendercopyex.c ./naclbuild.sh ~/naclsdk/pepper_35
-    
-Once the build finishes, you have to serve the contents with a web server (the
-script will give you instructions on how to do that with Python).
-
-================================================================================
-RWops and nacl_io
-================================================================================
-
-SDL_RWops work transparently with nacl_io. Two functions control the mount points:
-    
-    int mount(const char* source, const char* target, 
-                      const char* filesystemtype, 
-                      unsigned long mountflags, const void *data);
-    int umount(const char *target);
-    
-    For convenience, SDL will by default mount an httpfs tree at / before calling 
-the app's main function. Such setting can be overridden by calling:
-    
-    umount("/");
-
-And then mounting a different filesystem at /
-
-It's important to consider that the asynchronous nature of file operations on a
-browser is hidden from the application, effectively providing the developer with
-a set of blocking file operations just like you get in a regular desktop 
-environment, which eases the job of porting to Native Client, but also introduces 
-a set of challenges of its own, in particular when big file sizes and slow 
-connections are involved.
-
-For more information on how nacl_io and mount points work, see:
-    
-    https://developer.chrome.com/native-client/devguide/coding/nacl_io
-    https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h
-
-To be able to save into the directory "/save/" (like backup of game) :
-
-    mount("", "/save", "html5fs", 0, "type=PERSISTENT");
-
-And add to manifest.json :
-
-    "permissions": [
-        "unlimitedStorage"
-    ]
-
-================================================================================
-TODO - Known Issues
-================================================================================
-* Testing of all systems with a real application (something other than SDL's tests)
-* Key events don't seem to work properly
-
diff --git a/docs/README.md b/docs/README.md
index 9af1ceb6bb6c..99220ff91647 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -34,7 +34,6 @@ More documentation and FAQs are available online at [the wiki](http://wiki.libsd
 - [iOS](README-ios.md)
 - [Linux](README-linux.md)
 - [macOS](README-macos.md)
-- [Native Client](README-nacl.md)
 - [Supported Platforms](README-platforms.md)
 - [Porting information](README-porting.md)
 - [PSP](README-psp.md)
diff --git a/include/SDL_assert.h b/include/SDL_assert.h
index e71cf9792dbc..df399b5dd622 100644
--- a/include/SDL_assert.h
+++ b/include/SDL_assert.h
@@ -53,7 +53,7 @@ assert can have unique static variables associated with it.
     #define SDL_TriggerBreakpoint() __debugbreak()
 #elif _SDL_HAS_BUILTIN(__builtin_debugtrap)
     #define SDL_TriggerBreakpoint() __builtin_debugtrap()
-#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) )
+#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
     #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
 #elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) )  /* this might work on other ARM targets, but this is a known quantity... */
     #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index 1c6fcbdcc526..c9904c683f06 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -285,7 +285,6 @@
 #undef SDL_AUDIO_DRIVER_DUMMY
 #undef SDL_AUDIO_DRIVER_EMSCRIPTEN
 #undef SDL_AUDIO_DRIVER_HAIKU
-#undef SDL_AUDIO_DRIVER_NACL
 #undef SDL_AUDIO_DRIVER_NETBSD
 #undef SDL_AUDIO_DRIVER_OPENSLES
 #undef SDL_AUDIO_DRIVER_OSS
@@ -387,7 +386,6 @@
 #undef SDL_VIDEO_DRIVER_X11_XSHAPE
 #undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS
 #undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
-#undef SDL_VIDEO_DRIVER_NACL
 #undef SDL_VIDEO_DRIVER_VIVANTE
 #undef SDL_VIDEO_DRIVER_VIVANTE_VDK
 #undef SDL_VIDEO_DRIVER_QNX
@@ -437,7 +435,6 @@
 #undef SDL_FILESYSTEM_RISCOS
 #undef SDL_FILESYSTEM_UNIX
 #undef SDL_FILESYSTEM_WINDOWS
-#undef SDL_FILESYSTEM_NACL
 #undef SDL_FILESYSTEM_EMSCRIPTEN
 #undef SDL_FILESYSTEM_VITA
 #undef SDL_FILESYSTEM_PSP
diff --git a/include/SDL_main.h b/include/SDL_main.h
index b35b07536665..3c702c06cae1 100644
--- a/include/SDL_main.h
+++ b/include/SDL_main.h
@@ -83,15 +83,6 @@
 /* We need to export SDL_main so it can be launched from Java */
 #define SDLMAIN_DECLSPEC    DECLSPEC
 
-#elif defined(__NACL__)
-/* On NACL we use ppapi_simple to set up the application helper code,
-   then wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before 
-   starting the user main function.
-   All user code is run in a separate thread by ppapi_simple, thus 
-   allowing for blocking io to take place via nacl_io
-*/
-#define SDL_MAIN_NEEDED
-
 #elif defined(__PSP__)
 /* On PSP SDL provides a main function that sets the module info,
    activates the GPU and starts the thread required to be able to exit
diff --git a/include/SDL_platform.h b/include/SDL_platform.h
index a8e3ac225ec7..02093bc8cddf 100644
--- a/include/SDL_platform.h
+++ b/include/SDL_platform.h
@@ -201,22 +201,6 @@
 #define __PS2__ 1
 #endif
 
-/* The NACL compiler defines __native_client__ and __pnacl__
- * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi
- */
-#if defined(__native_client__)
-#undef __LINUX__
-#undef __NACL__
-#define __NACL__ 1
-#endif
-#if defined(__pnacl__)
-#undef __LINUX__
-#undef __PNACL__
-#define __PNACL__ 1
-/* PNACL with newlib supports static linking only */
-#define __SDL_NOGETPROCADDR__
-#endif
-
 #if defined(__vita__)
 #define __VITA__ 1
 #endif
diff --git a/src/SDL_log.c b/src/SDL_log.c
index c01e31d8a917..9a407fd72cb6 100644
--- a/src/SDL_log.c
+++ b/src/SDL_log.c
@@ -496,9 +496,6 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
 #if HAVE_STDIO_H && \
     !(defined(__APPLE__) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT)))
     fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message);
-#if __NACL__
-    fflush(stderr);
-#endif
 #endif
 }
 
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index f40cdd2dcf0e..0916ad24a00d 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -48,9 +48,6 @@ static const AudioBootStrap *const bootstrap[] = {
 #if SDL_AUDIO_DRIVER_QSA
     &QSAAUDIO_bootstrap,
 #endif
-#if SDL_AUDIO_DRIVER_NACL
-    &NACLAUDIO_bootstrap,
-#endif
 #if SDL_AUDIO_DRIVER_WASAPI
     &WASAPI_bootstrap,
 #endif
diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h
index e908986e7746..dcdc5a00b7bc 100644
--- a/src/audio/SDL_sysaudio.h
+++ b/src/audio/SDL_sysaudio.h
@@ -187,7 +187,6 @@ extern AudioBootStrap ALSA_bootstrap;
 extern AudioBootStrap NETBSDAUDIO_bootstrap;
 extern AudioBootStrap DSP_bootstrap;
 extern AudioBootStrap QSAAUDIO_bootstrap;
-extern AudioBootStrap NACLAUDIO_bootstrap;
 extern AudioBootStrap WASAPI_bootstrap;
 extern AudioBootStrap DSOUND_bootstrap;
 extern AudioBootStrap WINMM_bootstrap;
diff --git a/src/audio/nacl/SDL_naclaudio.c b/src/audio/nacl/SDL_naclaudio.c
deleted file mode 100644
index c38070d8d8db..000000000000
--- a/src/audio/nacl/SDL_naclaudio.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
-  Simple DirectMedia Layer
-  Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-*/
-
-#include "../../SDL_internal.h"
-
-#if SDL_AUDIO_DRIVER_NACL
-
-#include "SDL_naclaudio.h"
-
-#include "SDL_audio.h"
-#include "SDL_mutex.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_audiodev_c.h"
-
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/pp_instance.h"
-#include "ppapi_simple/ps.h"
-#include "ppapi_simple/ps_interface.h"
-#include "ppapi_simple/ps_event.h"
-
-/* The tag name used by NACL audio */
-#define NACLAUDIO_DRIVER_NAME         "nacl"
-
-#define SAMPLE_FRAME_COUNT 4096
-
-/* Audio driver functions */
-static void nacl_audio_callback(void* samples, uint32_t buffer_size, PP_TimeDelta latency, void* data);
-
-/* FIXME: Make use of latency if needed */
-static void nacl_audio_callback(void* stream, uint32_t buffer_size, PP_TimeDelta latency, void* data) {
-    const int len = (int) buffer_size;
-    SDL_AudioDevice* _this = (SDL_AudioDevice*) data;
-    SDL_AudioCallback callback = _this->callbackspec.callback;
-
-    SDL_LockMutex(_this->mixer_lock);
-
-    /* Only do something if audio is enabled */
-    if (!SDL_AtomicGet(&_this->enabled) || SDL_AtomicGet(&_this->paused)) {
-        if (_this->stream) {
-            SDL_AudioStreamClear(_this->stream);
-        }
-        SDL_memset(stream, _this->spec.silence, len);
-    } else {
-        SDL_assert(_this->spec.size == len);
-
-        if (_this->stream == NULL) {  /* no conversion necessary. */
-            callback(_this->callbackspec.userdata, stream, len);
-        } else {  /* streaming/converting */
-            const int stream_len = _this->callbackspec.size;
-            while (SDL_AudioStreamAvailable(_this->stream) < len) {
-                callback(_this->callbackspec.userdata, _this->work_buffer, stream_len);
-                if (SDL_AudioStreamPut(_this->stream, _this->work_buffer, stream_len) == -1) {
-                    SDL_AudioStreamClear(_this->stream);
-                    SDL_AtomicSet(&_this->enabled, 0);
-                    break;
-                }
-            }
-
-            const int got = SDL_AudioStreamGet(_this->stream, stream, len);
-            SDL_assert((got < 0) || (got == len));
-            if (got != len) {
-                SDL_memset(stream, _this->spec.silence, len);
-            }
-        }
-    }
-
-    SDL_UnlockMutex(_this->mixer_lock);
-}
-
-static void NACLAUDIO_CloseDevice(SDL_AudioDevice *device) {
-    const PPB_Core *core = PSInterfaceCore();
-    const PPB_Audio *ppb_audio = PSInterfaceAudio();
-    SDL_PrivateAudioData *hidden = (SDL_PrivateAudioData *) device->hidden;
-    
-    ppb_audio->StopPlayback(hidden->audio);
-    core->ReleaseResource(hidden->audio);
-}
-
-static int
-NACLAUDIO_OpenDevice(_THIS, const char *devname) {
-    PP_Instance instance = PSGetInstanceId();
-    const PPB_Audio *ppb_audio = PSInterfaceAudio();
-    const PPB_AudioConfig *ppb_audiocfg = PSInterfaceAudioConfig();
-    
-    private = (SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *private));
-    if (private == NULL) {
-        return SDL_OutOfMemory();
-    }
-    
-    _this->spec.freq = 44100;
-    _this->spec.format = AUDIO_S16LSB;
-    _this->spec.channels = 2;
-    _this->spec.samples = ppb_audiocfg->RecommendSampleFrameCount(
-        instance, 
-        PP_AUDIOSAMPLERATE_44100, 
-        SAMPLE_FRAME_COUNT);
-    
-    /* Calculate the final parameters for this audio specification */
-    SDL_CalculateAudioSpec(&_this->spec);
-    
-    private->audio = ppb_audio->Create(
-        instance,
-        ppb_audiocfg->CreateStereo16Bit(instance, PP_AUDIOSAMPLERATE_44100, _this->spec.samples),
-        nacl_audio_callback, 
-        _this);
-    
-    /* Start audio playback while we are still on the main thread. */
-    ppb_audio->StartPlayback(private->audio);
-    
-    return 0;
-}
-
-static SDL_bool
-NACLAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
-    if (PSGetInstanceId() == 0) {
-        return SDL_FALSE;
-    }
-    
-    /* Set the function pointers */
-    impl->OpenDevice = NACLAUDIO_OpenDevice;
-    impl->CloseDevice = NACLAUDIO_CloseDevice;
-    impl->OnlyHasDefaultOutputDevice = SDL_TRUE;
-    impl->ProvidesOwnCallbackThread = SDL_TRUE;
-    /*
-     *    impl->WaitDevice = NACLAUDIO_WaitDevice;
-     *    impl->GetDeviceBuf = NACLAUDIO_GetDeviceBuf;
-     *    impl->PlayDevice = NACLAUDIO_PlayDevice;
-     *    impl->Deinitialize = NACLAUDIO_Deinitialize;
-     */
-    
-    return SDL_TRUE;
-}
-
-AudioBootStrap NACLAUDIO_bootstrap = {
-    NACLAUDIO_DRIVER_NAME, "SDL NaCl Audio Driver",
-    NACLAUDIO_Init, SDL_FALSE
-};
-
-#endif /* SDL_AUDIO_DRIVER_NACL */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/audio/nacl/SDL_naclaudio.h b/src/audio/nacl/SDL_naclaudio.h
deleted file mode 100644
index 13d8f8ca4697..000000000000
--- a/src/audio/nacl/SDL_naclaudio.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-  Simple DirectMedia Layer
-  Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-*/
-
-#include "../../SDL_internal.h"
-
-#ifndef SDL_naclaudio_h_
-#define SDL_naclaudio_h_
-
-#include "SDL_audio.h"
-#include "../SDL_sysaudio.h"
-#include "SDL_mutex.h"
-
-#include "ppapi/c/ppb_audio.h"
-
-#define _THIS  SDL_AudioDevice *_this
-#define private _this->hidden
-
-typedef struct SDL_PrivateAudioData {
-    PP_Resource audio;
-} SDL_PrivateAudioData;
-
-#endif /* SDL_naclaudio_h_ */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h
index d71946213750..1182b637ef3c 100644
--- a/src/dynapi/SDL_dynapi.h
+++ b/src/dynapi/SDL_dynapi.h
@@ -47,8 +47,6 @@
 #define SDL_DYNAMIC_API 0
 #elif defined(__ANDROID__) /* probably not useful on Android. */
 #define SDL_DYNAMIC_API 0
-#elif defined(__native_client__) && __native_client__  /* probably not useful on NACL. */
-#define SDL_DYNAMIC_API 0
 #elif defined(__EMSCRIPTEN__) && __EMSCRIPTEN__  /* probably not useful on Emscripten. */
 #define SDL_DYNAMIC_API 0
 #elif defined(SDL_BUILDING_WINRT) && SDL_BUILDING_WINRT  /* probably not useful on WinRT, given current .dll loading restrictions */
diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
index ead504c10a78..24058350d672 100644
--- a/src/file/SDL_rwops.c
+++ b/src/file/SDL_rwops.c
@@ -62,10 +62,6 @@
 #include "SDL_system.h"
 #endif
 
-#if __NACL__
-#include "nacl_io/nacl_io.h"
-#endif
-
 #if defined(__WIN32__) || defined(__GDK__)
 
 /* Functions to read/write Win32 API file pointers */
diff --git a/src/filesystem/nacl/SDL_sysfilesystem.c b/src/filesystem/nacl/SDL_sysfilesystem.c
deleted file mode 100644
index b5bbe9841f3a..000000000000
--- a/src/filesystem/nacl/SDL_sysfilesystem.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-  Simple DirectMedia Layer
-  Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-#include "SDL_error.h"
-#include "SDL_filesystem.h"
-
-#ifdef SDL_FILESYSTEM_NACL
-
-char *
-SDL_GetBasePath(void)
-{
-    SDL_Unsupported();
-    return NULL;
-}
-
-char *
-SDL_GetPrefPath(const char *org, const char *app)
-{
-    SDL_Unsupported();
-    return NULL;
-}
-
-#endif /* SDL_FILESYSTEM_NACL */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/main/nacl/SDL_nacl_main.c b/src/main/nacl/SDL_nacl_main.c
deleted file mode 100644
index a0838b184b80..000000000000
--- a/src/main/nacl/SDL_nacl_main.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-  Simple DirectMedia Layer
-  Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#if SDL_VIDEO_DRIVER_NACL
-
-/* Include the SDL main definition header */
-#include "SDL_main.h"
-
-#include "ppapi_simple/ps_main.h"
-#include "ppapi_simple/ps_event.h"
-#include "ppapi_simple/ps_interface.h"
-#include "nacl_io/nacl_io.h"
-#include "sys/mount.h"
-
-extern void NACL_SetScreenResolution(int width, int height, Uint32 format);
-
-int
-nacl_main(int argc, char *argv[])
-{
-    int status;
-    PSEvent* ps_event;
-    PP_Resource event;  
-    struct PP_Rect rect;
-    int ready = 0;

(Patch may be truncated, please check the link at the top of this post.)