diff --git a/CMakeLists.txt b/CMakeLists.txt index 9afecee..3c023da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,6 +193,8 @@ set(WAVE_CORE_SOURCES Source/WaveParameters.h) add_library(WaveCore STATIC ${WAVE_CORE_SOURCES}) +# Both libraries contain thread-local state and are linked into shared plugins. +set_target_properties(WaveCore WaveM68k PROPERTIES POSITION_INDEPENDENT_CODE ON) target_include_directories(WaveCore PUBLIC Source) target_link_libraries(WaveCore PUBLIC diff --git a/cmake/PrepareMusashi.cmake b/cmake/PrepareMusashi.cmake index 5e3cfb3..182efd0 100644 --- a/cmake/PrepareMusashi.cmake +++ b/cmake/PrepareMusashi.cmake @@ -14,6 +14,16 @@ function(wave_prepare_musashi source destination) default_pc_changed_callback_data default_set_fc_callback_data) foreach(filename m68kcpu.c m68kcpu.h) file(READ "${source}/${filename}" contents) + if(filename STREQUAL "m68kcpu.c") + # Upstream repeats this tentative definition in an indented block. + # Thread-local definitions cannot be repeated with GCC 16; retain + # the first definition and make the later declarations extern. + foreach(trap_type sigjmp_buf jmp_buf) + string(REPLACE "\t${trap_type} m68ki_aerr_trap;" + "\textern ${trap_type} m68ki_aerr_trap;" + contents "${contents}") + endforeach() + endif() foreach(symbol IN LISTS execution_state) # Capture the whole prefix, which always participates in the match. # CMake < 4.1 rejects a backreference to an unmatched optional group.