[PSEH] Add implementation for GCC amd64

Also, put include directory next to the library and use
target_include_directories(.. INTERFACE ..) to get this right.
This is because :
 - Having includes & implementation in two different places buggers me
 - This makes sure that there is no "if it compiles everything is fine" behaviour from anyone
   because now even static libraries need it for GCC amd64 build
Also add __USE_PSEH2__ define for the non SEH-aware compilers out there and use it in a few headers
where we define macros involving __try
This commit is contained in:
Jérôme Gardou 2021-04-22 11:11:34 +02:00 committed by Jérôme Gardou
parent d31856cda1
commit ba74a05a17
14 changed files with 230 additions and 50 deletions

View file

@ -12,13 +12,15 @@ elseif(ARCH STREQUAL "arm")
arm/seh_prolog.s)
endif()
if(MSVC OR ARCH STREQUAL "amd64")
if(MSVC OR ((CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (ARCH STREQUAL "amd64")))
list(APPEND SOURCE dummy.c)
add_asm_files(pseh_asm ${ASM_SOURCE})
add_library(pseh ${SOURCE} ${pseh_asm})
add_dependencies(pseh asm)
elseif((CMAKE_C_COMPILER_ID STREQUAL "GNU") AND (ARCH STREQUAL "amd64"))
# for GCC amd64 this is just an interface library, with our home-made plugin
add_library(pseh INTERFACE)
target_compile_options(pseh INTERFACE -fplugin=$<TARGET_FILE:native-gcc_plugin_seh>)
else()
if(USE_PSEH3)
@ -43,4 +45,13 @@ else()
target_link_libraries(pseh chkstk)
add_dependencies(pseh psdk)
target_include_directories(pseh PRIVATE include/pseh)
endif()
target_include_directories(pseh INTERFACE include)
# Make it clear that we are using PSEH2
if ((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR
((CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (NOT (ARCH STREQUAL "amd64"))))
target_compile_definitions(pseh INTERFACE __USE_PSEH2__)
endif()