Browse code

Port upstream LLVM commits to fix bb #8723.

commit 481d402ab03e163e180d2650fae13704858f8d81
Author: Eric Christopher <echristo@apple.com>
Date: Fri Dec 3 07:45:22 2010 +0000

Apparently OS X 10.4 doesn't have __crashreporter_info__.

Try to fix building on the wayback machine.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120801 91177308-0d34-0410-b5e6-96231b3b80d8

commit 51e57139b3fdcf6b25453fa987463b33ff8f9adc
Author: Eric Christopher <echristo@apple.com>
Date: Tue Dec 7 02:05:42 2010 +0000

Two things: Fix testcase to use extern - otherwise the link will always
succeed. Also make the testcase clearer as to what we're doing and
emit a checking notification to the log.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121101 91177308-0d34-0410-b5e6-96231b3b80d8

Török Edvin authored on 2011/01/20 17:10:47
Showing 5 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Jan 20 10:11:32 EET 2011 (edwin)
2
+------------------------------------
3
+ * libclamav/c++/llvm: port 2 upstream commits to fix bb#8723.
4
+
1 5
 Thu Jan 20 10:02:24 EET 2011 (edwin)
2 6
 ------------------------------------
3 7
  * unit_tests/check_bytecode.c: fix build on etch (bb #2399),
... ...
@@ -1272,9 +1272,25 @@ if test "$llvm_cv_enable_libffi" = "yes" ; then
1272 1272
   AC_CHECK_HEADERS([ffi.h ffi/ffi.h])
1273 1273
 fi
1274 1274
 
1275
-dnl Try to find Darwin specific crash reporting library.
1275
+dnl Try to find Darwin specific crash reporting libraries.
1276 1276
 AC_CHECK_HEADERS([CrashReporterClient.h])
1277 1277
 
1278
+dnl Try to find Darwin specific crash reporting global.
1279
+AC_MSG_CHECKING([__crashreporter_info__])
1280
+AC_LINK_IFELSE(
1281
+  AC_LANG_SOURCE(
1282
+    [[extern const char *__crashreporter_info__;
1283
+      int main() {
1284
+        __crashreporter_info__ = "test";
1285
+        return 0;
1286
+      }
1287
+    ]]),
1288
+  AC_MSG_RESULT(yes)
1289
+  AC_DEFINE(HAVE_CRASHREPORTER_INFO, 1, Can use __crashreporter_info__),
1290
+  AC_MSG_RESULT(no)
1291
+  AC_DEFINE(HAVE_CRASHREPORTER_INFO, 0,
1292
+            Define if __crashreporter_info__ exists.))
1293
+
1278 1294
 dnl===-----------------------------------------------------------------------===
1279 1295
 dnl===
1280 1296
 dnl=== SECTION 7: Check for types and structures
... ...
@@ -11631,6 +11631,33 @@ fi
11631 11631
 done
11632 11632
 
11633 11633
 
11634
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking __crashreporter_info__" >&5
11635
+$as_echo_n "checking __crashreporter_info__... " >&6; }
11636
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11637
+/* end confdefs.h.  */
11638
+extern const char *__crashreporter_info__;
11639
+      int main() {
11640
+        __crashreporter_info__ = "test";
11641
+        return 0;
11642
+      }
11643
+
11644
+_ACEOF
11645
+if ac_fn_c_try_link "$LINENO"; then :
11646
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
11647
+$as_echo "yes" >&6; }
11648
+
11649
+$as_echo "#define HAVE_CRASHREPORTER_INFO 1" >>confdefs.h
11650
+
11651
+else
11652
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11653
+$as_echo "no" >&6; }
11654
+
11655
+$as_echo "#define HAVE_CRASHREPORTER_INFO 0" >>confdefs.h
11656
+
11657
+fi
11658
+rm -f core conftest.err conftest.$ac_objext \
11659
+    conftest$ac_exeext conftest.$ac_ext
11660
+
11634 11661
 
11635 11662
 
11636 11663
 
... ...
@@ -72,6 +72,9 @@
72 72
 /* Define to 1 if you have the <CrashReporterClient.h> header file. */
73 73
 #undef HAVE_CRASHREPORTERCLIENT_H
74 74
 
75
+/* Define if __crashreporter_info__ exists. */
76
+#undef HAVE_CRASHREPORTER_INFO
77
+
75 78
 /* Define to 1 if you have the <ctype.h> header file. */
76 79
 #undef HAVE_CTYPE_H
77 80
 
... ...
@@ -55,7 +55,7 @@ static void PrintCurStackTrace(raw_ostream &OS) {
55 55
 }
56 56
 
57 57
 // Integrate with crash reporter libraries.
58
-#if defined (__APPLE__) && defined (HAVE_CRASHREPORTERCLIENT_H)
58
+#if defined (__APPLE__) && HAVE_CRASHREPORTERCLIENT_H
59 59
 //  If any clients of llvm try to link to libCrashReporterClient.a themselves,
60 60
 //  only one crash info struct will be used.
61 61
 extern "C" {
... ...
@@ -64,7 +64,7 @@ struct crashreporter_annotations_t gCRAnnotations
64 64
         __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION))) 
65 65
         = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0 };
66 66
 }
67
-#elif defined (__APPLE__)
67
+#elif defined (__APPLE__) && HAVE_CRASHREPORTER_INFO
68 68
 static const char *__crashreporter_info__ = 0;
69 69
 asm(".desc ___crashreporter_info__, 0x10");
70 70
 #endif
... ...
@@ -86,11 +86,11 @@ static void CrashHandler(void *) {
86 86
   }
87 87
   
88 88
   if (!TmpStr.empty()) {
89
-#ifndef HAVE_CRASHREPORTERCLIENT_H
90
-    __crashreporter_info__ = strdup(std::string(TmpStr.str()).c_str());
91
-#else
89
+#ifdef HAVE_CRASHREPORTERCLIENT_H
92 90
     // Cast to void to avoid warning.
93 91
     (void)CRSetCrashLogMessage(std::string(TmpStr.str()).c_str());
92
+#elif HAVE_CRASHREPORTER_INFO 
93
+    __crashreporter_info__ = strdup(std::string(TmpStr.str()).c_str());
94 94
 #endif
95 95
     errs() << TmpStr.str();
96 96
   }