Fix CMake Script for libunwind Feature Check
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 29 Feb 2016 08:11:10 +0000 (17:11 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 3 Mar 2016 15:28:11 +0000 (00:28 +0900)
Check the availability correctly for Linux.

The cmake configuration script has been trying to find out
the availability of functions directly with check_function_exists,
which depends on the symbol names in .so files.
However, the libunwind implementation uses macros to
redefine functions names for each architecture making it
impossible to directly look up symbol tables of .so files.

In order to allow the script to use the information in
header files, check_function_exists should be replaced
with check_cxx_source_compiles.

Besides config.h.in had missing declarations for the
CMAKE variables

Fix dotnet/coreclr#3372

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Commit migrated from https://github.com/dotnet/coreclr/commit/3c0d5e85c59107a4710317f445bec0528cbe232b

src/coreclr/src/pal/src/config.h.in
src/coreclr/src/pal/src/configure.cmake

index 68cb81b..784383f 100644 (file)
@@ -53,6 +53,8 @@
 #cmakedefine01 HAS_SYSV_SEMAPHORES
 #cmakedefine01 HAS_PTHREAD_MUTEXES
 #cmakedefine01 HAVE_TTRACE
+#cmakedefine HAVE_UNW_GET_SAVE_LOC
+#cmakedefine HAVE_UNW_GET_ACCESSORS
 
 #cmakedefine01 HAVE_STAT_TIMESPEC
 #cmakedefine01 HAVE_STAT_NSEC
index be6114d..daa9962 100644 (file)
@@ -73,8 +73,28 @@ check_function_exists(directio HAVE_DIRECTIO)
 check_function_exists(semget HAS_SYSV_SEMAPHORES)
 check_function_exists(pthread_mutex_init HAS_PTHREAD_MUTEXES)
 check_function_exists(ttrace HAVE_TTRACE)
-check_function_exists(unw_get_save_loc HAVE_UNW_GET_SAVE_LOC)
-check_function_exists(unw_get_accessors HAVE_UNW_GET_ACCESSORS)
+set(CMAKE_REQUIRED_LIBRARIES unwind unwind-generic)
+check_cxx_source_compiles("
+#include <libunwind.h>
+
+int main(int argc, char **argv) {
+  unw_cursor_t cursor;
+  unw_save_loc_t saveLoc;
+  int reg = UNW_REG_IP;
+  unw_get_save_loc(&cursor, reg, &saveLoc);
+
+  return 0;
+}" HAVE_UNW_GET_SAVE_LOC)
+check_cxx_source_compiles("
+#include <libunwind.h>
+
+int main(int argc, char **argv) {
+  unw_addr_space_t as;
+  unw_get_accessors(as);
+
+  return 0;
+}" HAVE_UNW_GET_ACCESSORS)
+set(CMAKE_REQUIRED_LIBRARIES)
 
 check_struct_has_member ("struct stat" st_atimespec "sys/types.h;sys/stat.h" HAVE_STAT_TIMESPEC)
 check_struct_has_member ("struct stat" st_atimensec "sys/types.h;sys/stat.h" HAVE_STAT_NSEC)