Skip to content

Commit 789d229

Browse files
committed
Don't default to SDLv1 for un-versioned SDL includes
With SDL you can choose to either include the header files via the explictly version prefix (e.g. `<SDL/SDL_audio.h>` or `<SDL2/SDL_audio.h>`. Or some folks configure the include path such that the unversioned includes can be used (`#include <SDL_audio.h>`). Emscripten allows the unversioned form by putting the `SDL` or `SDL2` directory on the include path based on the USE_SDL settings, but the fact that were defaulting to enabling version 1 was causing some issues (See #18072 and #184402 for more details). After this change we default to not adding either of these include paths. This means that folks who want to use un-versioned includes will now need to opt into one version of the other via `-sUSE_SDL`. Note that folks using the explict `<SDL/SDL_audio.h>` includes are not effected by this (that will always result in an SDL v1 header being included). In order to make it more obvious that use of `<SDL_audio.h>` now requires an opt in, I created dummy headers that should give effected users and clear error message. We've already been doing this in STRICT module for a while now. Fixes: #18072, #18440
1 parent 53a219a commit 789d229

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+89
-18
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions

emcc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,9 @@ def array_contains_any_of(hay, needles):
917917
if array_contains_any_of(user_args, SIMD_NEON_FLAGS):
918918
cflags += ['-D__ARM_NEON__=1']
919919

920+
if not settings.USE_SDL:
921+
cflags += ['-Xclang', '-iwithsysroot' + os.path.join('/include', 'fakesdl')]
922+
920923
return cflags + ['-Xclang', '-iwithsysroot' + os.path.join('/include', 'compat')]
921924

922925

@@ -1916,9 +1919,6 @@ def phase_linker_setup(options, state, newargs):
19161919
default_setting('IGNORE_MISSING_MAIN', 0)
19171920
default_setting('ALLOW_UNIMPLEMENTED_SYSCALLS', 0)
19181921

1919-
if not settings.AUTO_JS_LIBRARIES:
1920-
default_setting('USE_SDL', 0)
1921-
19221922
if 'GLOBAL_BASE' not in user_settings and not settings.SHRINK_LEVEL and not settings.OPT_LEVEL:
19231923
# When optimizing for size it helps to put static data first before
19241924
# the stack (sincs this makes instructions for accessing this data

src/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ var LEGALIZE_JS_FFI = true;
14061406
// When AUTO_JS_LIBRARIES is set to 0 this defaults to 0 and SDL
14071407
// is not linked in.
14081408
// [compile+link]
1409-
var USE_SDL = 1;
1409+
var USE_SDL = 0;
14101410

14111411
// Specify the SDL_gfx version that is being linked against. Must match USE_SDL
14121412
// [compile+link]

system/include/fakesdl/SDL.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"

system/include/fakesdl/SDL_audio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"

0 commit comments

Comments
 (0)