mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-26 19:33:31 +00:00
[SDK][CMAKE] Link libgcc_eh into C++ targets when available
The build uses -nostdlib which prevents GCC from auto-linking libgcc_eh.a. This library provides the SEH unwind symbols (_Unwind_Resume, __emutls_get_address, etc.) needed by C++ exception handling. Without it, any C++ target compiled with -fexceptions fails to link with undefined references to these symbols. Add a libgcc_eh INTERFACE target that conditionally pulls in libgcc_eh.a when the toolchain provides it (as on SEH-enabled x86_64), falling back to a no-op otherwise (SJLJ/DWARF toolchains).
This commit is contained in:
+9
-2
@@ -657,12 +657,19 @@ set_target_properties(libgcc PROPERTIES IMPORTED_LOCATION ${LIBGCC_LOCATION})
|
||||
# libgcc needs kernel32 and winpthread (an appropriate CRT must be linked manually)
|
||||
target_link_libraries(libgcc INTERFACE libwinpthread libkernel32)
|
||||
|
||||
add_library(libgcc_eh INTERFACE)
|
||||
target_link_libraries(libgcc_eh INTERFACE libgcc)
|
||||
# only add libgcc_eh.a if it exists (SEH toolchains have it, SJLJ/DWARF do not)
|
||||
execute_process(COMMAND ${GXX_EXECUTABLE} -print-file-name=libgcc_eh.a OUTPUT_VARIABLE _LIBGCC_EH_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(EXISTS "${_LIBGCC_EH_PATH}")
|
||||
target_link_libraries(libgcc_eh INTERFACE "${_LIBGCC_EH_PATH}")
|
||||
endif()
|
||||
|
||||
add_library(libsupc++ STATIC IMPORTED GLOBAL)
|
||||
execute_process(COMMAND ${GXX_EXECUTABLE} -print-file-name=libsupc++.a OUTPUT_VARIABLE LIBSUPCXX_LOCATION)
|
||||
string(STRIP ${LIBSUPCXX_LOCATION} LIBSUPCXX_LOCATION)
|
||||
set_target_properties(libsupc++ PROPERTIES IMPORTED_LOCATION ${LIBSUPCXX_LOCATION})
|
||||
# libsupc++ requires libgcc and stdc++compat
|
||||
target_link_libraries(libsupc++ INTERFACE libgcc stdc++compat)
|
||||
target_link_libraries(libsupc++ INTERFACE libgcc_eh libgcc stdc++compat)
|
||||
|
||||
add_library(libmingwex STATIC IMPORTED)
|
||||
execute_process(COMMAND ${GXX_EXECUTABLE} -print-file-name=libmingwex.a OUTPUT_VARIABLE LIBMINGWEX_LOCATION)
|
||||
|
||||
Reference in New Issue
Block a user