Skip to content

Commit 0202230

Browse files
authored
Fix 'elf.h' file not found on macOS 10.15 (#1789)
See: #1744 This is a backport of the fix that was merged into runtime for master: dotnet/runtime#42756
1 parent f08ac8a commit 0202230

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
From 8dc136685608bb1cbaadc2fe9b21f870f6f4fe4e Mon Sep 17 00:00:00 2001
2+
From: Jan Vorlicek <janvorli@microsoft.com>
3+
Date: Fri, 25 Sep 2020 12:57:57 -0700
4+
Subject: [PATCH] Fix bad configure tests
5+
6+
There was an extra -c in the CMAKE_REQUIRED_FLAGS set for testing
7+
HAVE_UNW_GET_ACCESSORS and HAVE_UNW_GET_SAVE_LOC that was breaking
8+
build of coreclr under homebrew. The option was somehow making
9+
these checks behave on ARM Linux, eveb though it is not clear to
10+
me why, as it was just causing this option to be passed to the
11+
compiler twice at different positions of the command line of
12+
the cmake tests.
13+
This change fixes it by using check_symbol_exists instead of
14+
check_c_source_compiles, since just removing the duplicite -c
15+
was resulting in the check failing on ARM / ARM64 Linux due
16+
to a missing symbol from libunwind during linking.
17+
---
18+
src/coreclr/src/pal/src/configure.cmake | 26 ++-----------------------
19+
1 file changed, 2 insertions(+), 24 deletions(-)
20+
21+
diff --git a/src/pal/src/configure.cmake b/src/pal/src/configure.cmake
22+
index 893f88c44f3d..0a2a4411aa96 100644
23+
--- a/src/pal/src/configure.cmake
24+
+++ b/src/pal/src/configure.cmake
25+
@@ -1049,8 +1049,6 @@ if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
26+
list(INSERT CMAKE_REQUIRED_INCLUDES 0 ${CMAKE_CURRENT_SOURCE_DIR}/libunwind/include ${CMAKE_CURRENT_BINARY_DIR}/libunwind/include)
27+
endif()
28+
29+
-set(CMAKE_REQUIRED_FLAGS "-c -Werror=implicit-function-declaration")
30+
-
31+
check_c_source_compiles("
32+
#include <libunwind.h>
33+
#include <ucontext.h>
34+
@@ -1062,29 +1060,9 @@ int main(int argc, char **argv)
35+
return 0;
36+
}" UNWIND_CONTEXT_IS_UCONTEXT_T)
37+
38+
-check_c_source_compiles("
39+
-#include <libunwind.h>
40+
-
41+
-int main(int argc, char **argv) {
42+
- unw_cursor_t cursor;
43+
- unw_save_loc_t saveLoc;
44+
- int reg = UNW_REG_IP;
45+
- unw_get_save_loc(&cursor, reg, &saveLoc);
46+
-
47+
- return 0;
48+
-}" HAVE_UNW_GET_SAVE_LOC)
49+
-
50+
-check_c_source_compiles("
51+
-#include <libunwind.h>
52+
-
53+
-int main(int argc, char **argv) {
54+
- unw_addr_space_t as;
55+
- unw_get_accessors(as);
56+
-
57+
- return 0;
58+
-}" HAVE_UNW_GET_ACCESSORS)
59+
+check_symbol_exists(unw_get_save_loc libunwind.h HAVE_UNW_GET_SAVE_LOC)
60+
+check_symbol_exists(unw_get_accessors libunwind.h HAVE_UNW_GET_ACCESSORS)
61+
62+
-set(CMAKE_REQUIRED_FLAGS)
63+
if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
64+
list(REMOVE_AT CMAKE_REQUIRED_INCLUDES 0 1)
65+
endif()

0 commit comments

Comments
 (0)