Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threads are needed by many SDL subsystems and may not be disabled when compiling for 3DS #12313

Open
CrossScarDev opened this issue Feb 17, 2025 · 4 comments

Comments

@CrossScarDev
Copy link

I'm making a game with SDL3 and I had successfully compiled it for the 3DS but the second time I tried to compile it I get this error.

I'm building my project with this command:

cmake -S. -Bbuild-3ds -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/3DS.cmake" -DCMAKE_BUILD_TYPE=Release

Here is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.16)

include(FetchContent)

FetchContent_Declare(
  cmrc
  DOWNLOAD_EXTRACT_TIMESTAMP OFF
  URL https://github.com/vector-of-bool/cmrc/archive/refs/tags/2.0.1.tar.gz
  FIND_PACKAGE_ARGS
)
FetchContent_MakeAvailable(cmrc)
include(${cmrc_SOURCE_DIR}/CMakeRC.cmake)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

project(souls-of-tartarus)

FetchContent_Declare(
  LDtkLoader
  DOWNLOAD_EXTRACT_TIMESTAMP OFF
  URL https://github.com/Madour/LDtkLoader/archive/refs/tags/1.5.3.1.tar.gz
  FIND_PACKAGE_ARGS
)
FetchContent_MakeAvailable(LDtkLoader)

FetchContent_Declare(
  SDL3
  DOWNLOAD_EXTRACT_TIMESTAMP OFF
  URL https://github.com/libsdl-org/SDL/archive/refs/tags/release-3.2.4.tar.gz
  FIND_PACKAGE_ARGS
)
FetchContent_MakeAvailable(SDL3)

FetchContent_Declare(
  SDL3_image
  DOWNLOAD_EXTRACT_TIMESTAMP OFF
  URL https://github.com/libsdl-org/SDL_image/archive/refs/tags/release-3.2.0.tar.gz
  FIND_PACKAGE_ARGS
)
FetchContent_MakeAvailable(SDL3_image)

cmrc_add_resource_library(resources ALIAS resources::rc resources/tilemap.png resources/level.ldtk resources/player.png)

add_executable(${PROJECT_NAME} src/main.cpp src/player.cpp src/camera.cpp)

target_link_libraries(${PROJECT_NAME} PRIVATE LDtkLoader::LDtkLoader SDL3_image::SDL3_image SDL3::SDL3 resources::rc)

if("${PLATFORM}" STREQUAL "Web")
  target_link_options(${PROJECT_NAME} PUBLIC -sNO_DISABLE_EXCEPTION_CATCHING PUBLIC --shell-file build-resources/shell.html)
  set(CMAKE_EXECUTABLE_SUFFIX ".html")
  set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/web OUTPUT_NAME "index")
endif()

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/build-resources/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/build-resources)
@madebr
Copy link
Contributor

madebr commented Feb 17, 2025

Our CMake script unconditionally considers threads available on Nintendo 3DS.

SDL/CMakeLists.txt

Lines 2862 to 2896 in 3b4cfc1

elseif(N3DS)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/main/n3ds/*.c")
if(SDL_AUDIO)
set(SDL_AUDIO_DRIVER_N3DS 1)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/n3ds/*.c")
set(HAVE_SDL_AUDIO TRUE)
endif()
set(SDL_FILESYSTEM_N3DS 1)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/filesystem/n3ds/*.c")
set(HAVE_SDL_FILESYSTEM TRUE)
# !!! FIXME: do we need a FSops implementation for this?
if(SDL_JOYSTICK)
set(SDL_JOYSTICK_N3DS 1)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/joystick/n3ds/*.c")
set(HAVE_SDL_JOYSTICK TRUE)
endif()
if(SDL_POWER)
set(SDL_POWER_N3DS 1)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/power/n3ds/*.c")
set(HAVE_SDL_POWER TRUE)
endif()
set(SDL_THREAD_N3DS 1)
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/thread/n3ds/*.c")
sdl_sources(
"${SDL3_SOURCE_DIR}/src/thread/generic/SDL_syscond.c"
"${SDL3_SOURCE_DIR}/src/thread/generic/SDL_systls.c"
"${SDL3_SOURCE_DIR}/src/thread/generic/SDL_sysrwlock.c"
)
set(HAVE_SDL_THREADS TRUE)

Please debug on your system why it does not enter this if(N3DS) branch, and does not do set(HAVE_SDL_THREADS TRUE).

@CrossScarDev
Copy link
Author

This might be a bug with devkitpro because I can get it to compile if I use -DN3DS=1 but the file extension is wrong, so the compilers seem to be set correctly, but some things aren't.

@madebr
Copy link
Contributor

madebr commented Feb 20, 2025

All we do on ci is pass -DCMAKE_TOOLCHAIN_FILE=${DEVKITPRO}/cmake/3DS.cmake to cmake.

@CrossScarDev
Copy link
Author

just tried that and it didn't work

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

No branches or pull requests

2 participants