Handle libunwind_xdac partial C11 support (#42997)
authorSteve MacLean <Steve.MacLean@microsoft.com>
Mon, 5 Oct 2020 16:40:00 +0000 (12:40 -0400)
committerGitHub <noreply@github.com>
Mon, 5 Oct 2020 16:40:00 +0000 (12:40 -0400)
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
src/coreclr/src/pal/src/libunwind/configure.cmake

index 5ac6201..4c06e69 100644 (file)
 
 #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
index ef56247..8e9c00a 100644 (file)
@@ -59,6 +59,16 @@ int main(int argc, char **argv)
     return 0;
 }" HAVE__BUILTIN_UNREACHABLE)
 
+check_c_source_compiles("
+#include <stdalign.h>
+
+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)