From c454492e4fd88252b4baed0bb18a0021ac0871e8 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Fri, 2 Oct 2020 19:16:32 -0400 Subject: [PATCH] Handle libunwind_xdac partial C11 support For newer Windows SDKs, the stdalign.h header is present, but the alignas macr is not defined unless the compiler adds the std:c11 or newer. Until we can set the std:c11 flag, work around the missing alignas macro using cmake config. --- src/coreclr/src/pal/src/libunwind/config.h.in | 9 +++++++++ src/coreclr/src/pal/src/libunwind/configure.cmake | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/coreclr/src/pal/src/libunwind/config.h.in b/src/coreclr/src/pal/src/libunwind/config.h.in index 5ac6201e08b501..4c06e69879688c 100644 --- a/src/coreclr/src/pal/src/libunwind/config.h.in +++ b/src/coreclr/src/pal/src/libunwind/config.h.in @@ -17,4 +17,13 @@ #cmakedefine HAVE_ATOMIC_OPS_H +#cmakedefine HAVE_STDALIGN_H +#cmakedefine HAVE_STDALIGN_ALIGNAS + +#if defined(_MSC_VER) && defined(HAVE_STDALIGN_H) && !defined(HAVE_STDALIGN_ALIGNAS) +// alignment is a performance optimization for the cross compile libunwind +// Simply ignore it if it is not supported by the compiler +#define alignas(x) +#endif + #endif diff --git a/src/coreclr/src/pal/src/libunwind/configure.cmake b/src/coreclr/src/pal/src/libunwind/configure.cmake index ef56247ae166a2..8e9c00abfbeb9b 100644 --- a/src/coreclr/src/pal/src/libunwind/configure.cmake +++ b/src/coreclr/src/pal/src/libunwind/configure.cmake @@ -59,6 +59,16 @@ int main(int argc, char **argv) return 0; }" HAVE__BUILTIN_UNREACHABLE) +check_c_source_compiles(" +#include + +int main(void) +{ + alignas(128) char result = 0; + + return result; +}" HAVE_STDALIGN_ALIGNAS) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h) add_definitions(-DHAVE_CONFIG_H=1)