pf2 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/README.md +11 -0
  4. data/Rakefile +9 -2
  5. data/doc/development.md +11 -0
  6. data/examples/mandelbrot.rb +69 -0
  7. data/examples/mandelbrot_ractor.rb +77 -0
  8. data/ext/pf2/build.rs +7 -0
  9. data/ext/pf2/src/ruby_c_api_helper.c +6 -0
  10. data/ext/pf2/src/serialization/profile.rs +1 -0
  11. data/ext/pf2/src/serialization/serializer.rs +4 -0
  12. data/ext/pf2/src/signal_scheduler.rs +1 -1
  13. data/ext/pf2/src/util.rs +2 -1
  14. data/ext/pf2c/backtrace_state.c +10 -0
  15. data/ext/pf2c/backtrace_state.h +10 -0
  16. data/ext/pf2c/configuration.c +90 -0
  17. data/ext/pf2c/configuration.h +23 -0
  18. data/ext/pf2c/extconf.rb +21 -0
  19. data/ext/pf2c/pf2.c +17 -0
  20. data/ext/pf2c/pf2.h +8 -0
  21. data/ext/pf2c/ringbuffer.c +74 -0
  22. data/ext/pf2c/ringbuffer.h +24 -0
  23. data/ext/pf2c/sample.c +70 -0
  24. data/ext/pf2c/sample.h +22 -0
  25. data/ext/pf2c/serializer.c +377 -0
  26. data/ext/pf2c/serializer.h +58 -0
  27. data/ext/pf2c/session.c +344 -0
  28. data/ext/pf2c/session.h +51 -0
  29. data/lib/pf2/cli.rb +33 -2
  30. data/lib/pf2/reporter/annotate.rb +101 -0
  31. data/lib/pf2/reporter/firefox_profiler.rb +1 -1
  32. data/lib/pf2/reporter/firefox_profiler_ser2.rb +308 -0
  33. data/lib/pf2/reporter.rb +2 -0
  34. data/lib/pf2/version.rb +1 -1
  35. data/vendor/libbacktrace/.gitignore +5 -0
  36. data/vendor/libbacktrace/Isaac.Newton-Opticks.txt +9286 -0
  37. data/vendor/libbacktrace/LICENSE +29 -0
  38. data/vendor/libbacktrace/Makefile.am +708 -0
  39. data/vendor/libbacktrace/Makefile.in +2820 -0
  40. data/vendor/libbacktrace/README.md +46 -0
  41. data/vendor/libbacktrace/aclocal.m4 +864 -0
  42. data/vendor/libbacktrace/alloc.c +167 -0
  43. data/vendor/libbacktrace/allocfail.c +136 -0
  44. data/vendor/libbacktrace/allocfail.sh +104 -0
  45. data/vendor/libbacktrace/atomic.c +113 -0
  46. data/vendor/libbacktrace/backtrace-supported.h.in +66 -0
  47. data/vendor/libbacktrace/backtrace.c +129 -0
  48. data/vendor/libbacktrace/backtrace.h +189 -0
  49. data/vendor/libbacktrace/btest.c +517 -0
  50. data/vendor/libbacktrace/compile +348 -0
  51. data/vendor/libbacktrace/config/enable.m4 +38 -0
  52. data/vendor/libbacktrace/config/lead-dot.m4 +31 -0
  53. data/vendor/libbacktrace/config/libtool.m4 +7545 -0
  54. data/vendor/libbacktrace/config/ltoptions.m4 +369 -0
  55. data/vendor/libbacktrace/config/ltsugar.m4 +123 -0
  56. data/vendor/libbacktrace/config/ltversion.m4 +23 -0
  57. data/vendor/libbacktrace/config/lt~obsolete.m4 +98 -0
  58. data/vendor/libbacktrace/config/multi.m4 +68 -0
  59. data/vendor/libbacktrace/config/override.m4 +117 -0
  60. data/vendor/libbacktrace/config/unwind_ipinfo.m4 +37 -0
  61. data/vendor/libbacktrace/config/warnings.m4 +227 -0
  62. data/vendor/libbacktrace/config.guess +1700 -0
  63. data/vendor/libbacktrace/config.h.in +185 -0
  64. data/vendor/libbacktrace/config.sub +1885 -0
  65. data/vendor/libbacktrace/configure +15952 -0
  66. data/vendor/libbacktrace/configure.ac +642 -0
  67. data/vendor/libbacktrace/dwarf.c +4593 -0
  68. data/vendor/libbacktrace/edtest.c +120 -0
  69. data/vendor/libbacktrace/edtest2.c +43 -0
  70. data/vendor/libbacktrace/elf.c +7471 -0
  71. data/vendor/libbacktrace/fileline.c +407 -0
  72. data/vendor/libbacktrace/filenames.h +52 -0
  73. data/vendor/libbacktrace/filetype.awk +13 -0
  74. data/vendor/libbacktrace/install-debuginfo-for-buildid.sh.in +65 -0
  75. data/vendor/libbacktrace/install-sh +501 -0
  76. data/vendor/libbacktrace/instrumented_alloc.c +114 -0
  77. data/vendor/libbacktrace/internal.h +428 -0
  78. data/vendor/libbacktrace/ltmain.sh +8636 -0
  79. data/vendor/libbacktrace/macho.c +1361 -0
  80. data/vendor/libbacktrace/missing +215 -0
  81. data/vendor/libbacktrace/mmap.c +331 -0
  82. data/vendor/libbacktrace/mmapio.c +110 -0
  83. data/vendor/libbacktrace/move-if-change +83 -0
  84. data/vendor/libbacktrace/mtest.c +410 -0
  85. data/vendor/libbacktrace/nounwind.c +66 -0
  86. data/vendor/libbacktrace/pecoff.c +1123 -0
  87. data/vendor/libbacktrace/posix.c +104 -0
  88. data/vendor/libbacktrace/print.c +117 -0
  89. data/vendor/libbacktrace/read.c +110 -0
  90. data/vendor/libbacktrace/simple.c +108 -0
  91. data/vendor/libbacktrace/sort.c +108 -0
  92. data/vendor/libbacktrace/state.c +72 -0
  93. data/vendor/libbacktrace/stest.c +137 -0
  94. data/vendor/libbacktrace/test-driver +148 -0
  95. data/vendor/libbacktrace/test_format.c +55 -0
  96. data/vendor/libbacktrace/testlib.c +234 -0
  97. data/vendor/libbacktrace/testlib.h +110 -0
  98. data/vendor/libbacktrace/ttest.c +161 -0
  99. data/vendor/libbacktrace/unittest.c +92 -0
  100. data/vendor/libbacktrace/unknown.c +65 -0
  101. data/vendor/libbacktrace/xcoff.c +1617 -0
  102. data/vendor/libbacktrace/xztest.c +508 -0
  103. data/vendor/libbacktrace/zstdtest.c +523 -0
  104. data/vendor/libbacktrace/ztest.c +541 -0
  105. metadata +122 -3
@@ -0,0 +1,642 @@
1
+ # configure.ac -- Backtrace configure script.
2
+ # Copyright (C) 2012-2024 Free Software Foundation, Inc.
3
+
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are
6
+ # met:
7
+
8
+ # (1) Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+
11
+ # (2) Redistributions in binary form must reproduce the above copyright
12
+ # notice, this list of conditions and the following disclaimer in
13
+ # the documentation and/or other materials provided with the
14
+ # distribution.
15
+
16
+ # (3) The name of the author may not be used to
17
+ # endorse or promote products derived from this software without
18
+ # specific prior written permission.
19
+
20
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ # POSSIBILITY OF SUCH DAMAGE.
31
+
32
+ AC_PREREQ(2.69)
33
+ AC_INIT(package-unused, version-unused,, libbacktrace)
34
+ AC_CONFIG_SRCDIR(backtrace.h)
35
+ AC_CONFIG_HEADER(config.h)
36
+ AC_CONFIG_MACRO_DIR(config)
37
+
38
+ # with_target_subdir is used when configured as part of a GCC tree.
39
+ if test -n "${with_target_subdir}"; then
40
+ AM_ENABLE_MULTILIB(, ..)
41
+ fi
42
+
43
+ AC_CANONICAL_SYSTEM
44
+ target_alias=${target_alias-$host_alias}
45
+
46
+ AC_USE_SYSTEM_EXTENSIONS
47
+
48
+ # Default to not building a shared library.
49
+ AC_DISABLE_SHARED
50
+
51
+ libtool_VERSION=1:0:0
52
+ AC_SUBST(libtool_VERSION)
53
+
54
+ # 1.11.1: Require that version of automake.
55
+ # foreign: Don't require README, INSTALL, NEWS, etc.
56
+ # no-define: Don't define PACKAGE and VERSION.
57
+ # no-dependencies: Don't generate automatic dependencies.
58
+ # (because it breaks when using bootstrap-lean, since some of the
59
+ # headers are gone at "make install" time).
60
+ # -Wall: Issue all automake warnings.
61
+ # -Wno-portability: Don't warn about constructs supported by GNU make.
62
+ # (because GCC requires GNU make anyhow).
63
+ AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies -Wall -Wno-portability])
64
+
65
+ AM_MAINTAINER_MODE
66
+
67
+ AC_ARG_WITH(target-subdir,
68
+ [ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
69
+
70
+ # We must force CC to /not/ be precious variables; otherwise
71
+ # the wrong, non-multilib-adjusted value will be used in multilibs.
72
+ # As a side effect, we have to subst CFLAGS ourselves.
73
+ m4_rename([_AC_ARG_VAR_PRECIOUS],[backtrace_PRECIOUS])
74
+ m4_define([_AC_ARG_VAR_PRECIOUS],[])
75
+ AC_PROG_CC
76
+ m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
77
+
78
+ AC_SUBST(CFLAGS)
79
+
80
+ AC_PROG_RANLIB
81
+
82
+ AC_PROG_AWK
83
+ case "$AWK" in
84
+ "") AC_MSG_ERROR([can't build without awk]) ;;
85
+ esac
86
+
87
+ AC_CHECK_PROG(DWZ, dwz, dwz)
88
+ AM_CONDITIONAL(HAVE_DWZ, test "$DWZ" != "")
89
+
90
+ LT_INIT
91
+ AM_PROG_LIBTOOL
92
+
93
+ AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
94
+
95
+ AC_SYS_LARGEFILE
96
+
97
+ backtrace_supported=yes
98
+
99
+ if test -n "${with_target_subdir}"; then
100
+ # We are compiling a GCC library. We can assume that the unwind
101
+ # library exists.
102
+ BACKTRACE_FILE="backtrace.lo simple.lo"
103
+ else
104
+ AC_CHECK_HEADER([unwind.h],
105
+ [AC_CHECK_FUNC([_Unwind_Backtrace],
106
+ [BACKTRACE_FILE="backtrace.lo simple.lo"],
107
+ [BACKTRACE_FILE="nounwind.lo"
108
+ backtrace_supported=no])],
109
+ [BACKTRACE_FILE="nounwind.lo"
110
+ backtrace_supported=no])
111
+ fi
112
+ AC_SUBST(BACKTRACE_FILE)
113
+
114
+ EXTRA_FLAGS=
115
+ if test -n "${with_target_subdir}"; then
116
+ EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@"
117
+ else
118
+ AC_CACHE_CHECK([for -funwind-tables option],
119
+ [libbacktrace_cv_c_unwind_tables],
120
+ [CFLAGS_hold="$CFLAGS"
121
+ CFLAGS="$CFLAGS -funwind-tables"
122
+ AC_COMPILE_IFELSE(
123
+ [AC_LANG_PROGRAM([static int f() { return 0; }], [return f();])],
124
+ [libbacktrace_cv_c_unwind_tables=yes],
125
+ [libbacktrace_cv_c_unwind_tables=no])
126
+ CFLAGS="$CFLAGS_hold"])
127
+ if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then
128
+ EXTRA_FLAGS=-funwind-tables
129
+ fi
130
+ AC_CACHE_CHECK([for -frandom-seed=string option],
131
+ [libbacktrace_cv_c_random_seed_string],
132
+ [CFLAGS_hold="$CFLAGS"
133
+ CFLAGS="$CFLAGS -frandom-seed=conftest.lo"
134
+ AC_COMPILE_IFELSE(
135
+ [AC_LANG_PROGRAM([], [return 0;])],
136
+ [libbacktrace_cv_c_random_seed_string=yes],
137
+ [libbacktrace_cv_c_random_seed_string=no])
138
+ CFLAGS="$CFLAGS_hold"])
139
+ if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then
140
+ EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@"
141
+ fi
142
+ fi
143
+ AC_SUBST(EXTRA_FLAGS)
144
+
145
+ ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
146
+ -Wmissing-prototypes -Wold-style-definition \
147
+ -Wmissing-format-attribute -Wcast-qual \
148
+ -Wno-attributes -Wno-unknown-attributes \
149
+ -Wpointer-arith],
150
+ [WARN_FLAGS])
151
+
152
+ AC_ARG_ENABLE([werror],
153
+ [AS_HELP_STRING([--disable-werror], [disable building with -Werror])])
154
+ AS_IF([test "x$enable_werror" != "xno" && test -n "${with_target_subdir}"],
155
+ [WARN_FLAGS="$WARN_FLAGS -Werror"])
156
+
157
+ AC_SUBST(WARN_FLAGS)
158
+
159
+ if test -n "${with_target_subdir}"; then
160
+ GCC_CHECK_UNWIND_GETIPINFO
161
+ else
162
+ ac_save_CFFLAGS="$CFLAGS"
163
+ CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
164
+ AC_MSG_CHECKING([for _Unwind_GetIPInfo])
165
+ AC_LINK_IFELSE(
166
+ [AC_LANG_PROGRAM(
167
+ [#include "unwind.h"
168
+ struct _Unwind_Context *context;
169
+ int ip_before_insn = 0;],
170
+ [return _Unwind_GetIPInfo (context, &ip_before_insn);])],
171
+ [have_unwind_getipinfo=yes], [have_unwind_getipinfo=no])
172
+ CFLAGS="$ac_save_CFLAGS"
173
+ AC_MSG_RESULT([$have_unwind_getipinfo])
174
+ if test "$have_unwind_getipinfo" = "yes"; then
175
+ AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.])
176
+ fi
177
+ fi
178
+
179
+ # Enable --enable-host-shared.
180
+ AC_ARG_ENABLE(host-shared,
181
+ [AS_HELP_STRING([--enable-host-shared],
182
+ [build host code as shared libraries])],
183
+ [PIC_FLAG=-fPIC], [PIC_FLAG=])
184
+ AC_SUBST(PIC_FLAG)
185
+
186
+ # Test for __sync support.
187
+ AC_CACHE_CHECK([__sync extensions],
188
+ [libbacktrace_cv_sys_sync],
189
+ [if test -n "${with_target_subdir}"; then
190
+ case "${host}" in
191
+ hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;;
192
+ arm*-*-eabi*)
193
+ # Older versions of the Arm architecture lack the necessary instructions
194
+ # for these constructs, so check whether we can use them.
195
+ AC_LINK_IFELSE(
196
+ [AC_LANG_PROGRAM([int i;],
197
+ [__sync_bool_compare_and_swap (&i, i, i);
198
+ __sync_lock_test_and_set (&i, 1);
199
+ __sync_lock_release (&i);])],
200
+ [libbacktrace_cv_sys_sync=yes],
201
+ [libbacktrace_cv_sys_sync=no]);;
202
+ *) libbacktrace_cv_sys_sync=yes ;;
203
+ esac
204
+ else
205
+ AC_LINK_IFELSE(
206
+ [AC_LANG_PROGRAM([int i;],
207
+ [__sync_bool_compare_and_swap (&i, i, i);
208
+ __sync_lock_test_and_set (&i, 1);
209
+ __sync_lock_release (&i);])],
210
+ [libbacktrace_cv_sys_sync=yes],
211
+ [libbacktrace_cv_sys_sync=no])
212
+ fi])
213
+ BACKTRACE_SUPPORTS_THREADS=0
214
+ if test "$libbacktrace_cv_sys_sync" = "yes"; then
215
+ BACKTRACE_SUPPORTS_THREADS=1
216
+ AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
217
+ [Define to 1 if you have the __sync functions])
218
+ fi
219
+ AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
220
+
221
+ # Test for __atomic support.
222
+ AC_CACHE_CHECK([__atomic extensions],
223
+ [libbacktrace_cv_sys_atomic],
224
+ [if test -n "${with_target_subdir}"; then
225
+ libbacktrace_cv_sys_atomic=yes
226
+ else
227
+ AC_LINK_IFELSE(
228
+ [AC_LANG_PROGRAM([int i;],
229
+ [__atomic_load_n (&i, __ATOMIC_ACQUIRE);
230
+ __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])],
231
+ [libbacktrace_cv_sys_atomic=yes],
232
+ [libbacktrace_cv_sys_atomic=no])
233
+ fi])
234
+ if test "$libbacktrace_cv_sys_atomic" = "yes"; then
235
+ AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1,
236
+ [Define to 1 if you have the __atomic functions])
237
+ fi
238
+
239
+ # The library needs to be able to read the executable itself. Compile
240
+ # a file to determine the executable format. The awk script
241
+ # filetype.awk prints out the file type.
242
+ AC_CACHE_CHECK([output filetype],
243
+ [libbacktrace_cv_sys_filetype],
244
+ [filetype=
245
+ AC_COMPILE_IFELSE(
246
+ [AC_LANG_PROGRAM([int i;], [int j;])],
247
+ [filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext`],
248
+ [AC_MSG_FAILURE([compiler failed])])
249
+ libbacktrace_cv_sys_filetype=$filetype])
250
+
251
+ # Match the file type to decide what files to compile.
252
+ FORMAT_FILE=
253
+ backtrace_supports_data=yes
254
+ case "$libbacktrace_cv_sys_filetype" in
255
+ elf*) FORMAT_FILE="elf.lo" ;;
256
+ macho) FORMAT_FILE="macho.lo" ;;
257
+ pecoff) FORMAT_FILE="pecoff.lo"
258
+ backtrace_supports_data=no
259
+ ;;
260
+ xcoff*) FORMAT_FILE="xcoff.lo"
261
+ backtrace_supports_data=no
262
+ ;;
263
+ *) AC_MSG_WARN([could not determine output file type])
264
+ FORMAT_FILE="unknown.lo"
265
+ backtrace_supported=no
266
+ ;;
267
+ esac
268
+ AC_SUBST(FORMAT_FILE)
269
+
270
+ # ELF defines.
271
+ elfsize=
272
+ case "$libbacktrace_cv_sys_filetype" in
273
+ elf32) elfsize=32 ;;
274
+ elf64) elfsize=64 ;;
275
+ *) elfsize=unused
276
+ esac
277
+ AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
278
+ AM_CONDITIONAL(HAVE_ELF, test "$FORMAT_FILE" = "elf.lo")
279
+
280
+ # XCOFF defines.
281
+ xcoffsize=
282
+ case "$libbacktrace_cv_sys_filetype" in
283
+ xcoff32) xcoffsize=32 ;;
284
+ xcoff64) xcoffsize=64 ;;
285
+ *) xcoffsize=unused
286
+ esac
287
+ AC_DEFINE_UNQUOTED([BACKTRACE_XCOFF_SIZE], [$xcoffsize], [XCOFF size: 32 or 64])
288
+
289
+ BACKTRACE_SUPPORTED=0
290
+ if test "$backtrace_supported" = "yes"; then
291
+ BACKTRACE_SUPPORTED=1
292
+ fi
293
+ AC_SUBST(BACKTRACE_SUPPORTED)
294
+
295
+ BACKTRACE_SUPPORTS_DATA=0
296
+ if test "$backtrace_supports_data" = "yes"; then
297
+ BACKTRACE_SUPPORTS_DATA=1
298
+ fi
299
+ AC_SUBST(BACKTRACE_SUPPORTS_DATA)
300
+
301
+ AC_CHECK_HEADERS(sys/mman.h)
302
+ if test "$ac_cv_header_sys_mman_h" = "no"; then
303
+ have_mmap=no
304
+ else
305
+ if test -n "${with_target_subdir}"; then
306
+ # When built as a GCC target library, we can't do a link test. We
307
+ # simply assume that if we have mman.h, we have mmap.
308
+ have_mmap=yes
309
+ case "${host}" in
310
+ spu-*-*|*-*-msdosdjgpp)
311
+ # The SPU does not have mmap, but it has a sys/mman.h header file
312
+ # containing "mmap_eaddr" and the mmap flags, confusing the test.
313
+ # DJGPP also has sys/man.h, but no mmap
314
+ have_mmap=no ;;
315
+ esac
316
+ else
317
+ AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
318
+ fi
319
+ fi
320
+ if test "$have_mmap" = "no"; then
321
+ VIEW_FILE=read.lo
322
+ ALLOC_FILE=alloc.lo
323
+ else
324
+ VIEW_FILE=mmapio.lo
325
+ AC_PREPROC_IFELSE([AC_LANG_SOURCE([
326
+ #include <sys/mman.h>
327
+ #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
328
+ #error no MAP_ANONYMOUS
329
+ #endif
330
+ ])], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
331
+ fi
332
+ AC_SUBST(VIEW_FILE)
333
+ AC_SUBST(ALLOC_FILE)
334
+
335
+ BACKTRACE_USES_MALLOC=0
336
+ if test "$ALLOC_FILE" = "alloc.lo"; then
337
+ BACKTRACE_USES_MALLOC=1
338
+ fi
339
+ AC_SUBST(BACKTRACE_USES_MALLOC)
340
+
341
+ # Check for dl_iterate_phdr.
342
+ AC_CHECK_HEADERS(link.h sys/link.h)
343
+ if test "$ac_cv_header_link_h" = "no" -a "$ac_cv_header_sys_link_h" = "no"; then
344
+ have_dl_iterate_phdr=no
345
+ else
346
+ if test -n "${with_target_subdir}"; then
347
+ link_h=link.h
348
+ if test "$ac_cv_header_link_h" = "no"; then
349
+ link_h=sys/link.h
350
+ fi
351
+ # When built as a GCC target library, we can't do a link test.
352
+ AC_EGREP_HEADER([dl_iterate_phdr], [$link_h], [have_dl_iterate_phdr=yes],
353
+ [have_dl_iterate_phdr=no])
354
+ case "${host}" in
355
+ *-*-solaris2.10*)
356
+ # Avoid dl_iterate_phdr on Solaris 10, where it is in the
357
+ # header file but is only in -ldl.
358
+ have_dl_iterate_phdr=no ;;
359
+ esac
360
+ else
361
+ AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes],
362
+ [have_dl_iterate_phdr=no])
363
+ fi
364
+ fi
365
+ if test "$have_dl_iterate_phdr" = "yes"; then
366
+ AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
367
+ fi
368
+
369
+ # Check for header file for Mach-O image functions.
370
+ AC_CHECK_HEADERS(mach-o/dyld.h)
371
+
372
+ # Check for loadquery.
373
+ AC_CHECK_HEADERS(sys/ldr.h)
374
+ if test "$ac_cv_header_sys_ldr_h" = "no"; then
375
+ have_loadquery=no
376
+ else
377
+ if test -n "${with_target_subdir}"; then
378
+ # When built as a GCC target library, we can't do a link test.
379
+ AC_EGREP_HEADER([loadquery], [sys/ldr.h], [have_loadquery=yes],
380
+ [have_loadquery=no])
381
+ else
382
+ AC_CHECK_FUNC([loadquery], [have_loadquery=yes],
383
+ [have_loadquery=no])
384
+ fi
385
+ fi
386
+ if test "$have_loadquery" = "yes"; then
387
+ AC_DEFINE(HAVE_LOADQUERY, 1, [Define if AIX loadquery is available.])
388
+ fi
389
+
390
+ AC_CHECK_HEADERS(windows.h)
391
+ AC_CHECK_HEADERS(tlhelp32.h, [], [],
392
+ [#ifdef HAVE_WINDOWS_H
393
+ # include <windows.h>
394
+ #endif])
395
+
396
+ # Check for the fcntl function.
397
+ if test -n "${with_target_subdir}"; then
398
+ case "${host}" in
399
+ *-*-mingw*) have_fcntl=no ;;
400
+ spu-*-*) have_fcntl=no ;;
401
+ *) have_fcntl=yes ;;
402
+ esac
403
+ else
404
+ AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
405
+ fi
406
+ if test "$have_fcntl" = "yes"; then
407
+ AC_DEFINE([HAVE_FCNTL], 1,
408
+ [Define to 1 if you have the fcntl function])
409
+ fi
410
+
411
+ AC_CHECK_DECLS([strnlen, getpagesize])
412
+ AC_CHECK_FUNCS(lstat readlink)
413
+
414
+ # Check for getexecname function.
415
+ if test -n "${with_target_subdir}"; then
416
+ case "${host}" in
417
+ *-*-solaris2*) have_getexecname=yes ;;
418
+ *) have_getexecname=no ;;
419
+ esac
420
+ else
421
+ AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
422
+ fi
423
+ if test "$have_getexecname" = "yes"; then
424
+ AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
425
+ fi
426
+
427
+ # Check for _pgmptr variable, contains the executable filename on windows
428
+ AC_CHECK_DECLS([_pgmptr])
429
+
430
+ # Check for sysctl definitions.
431
+
432
+ AC_CACHE_CHECK([for KERN_PROC],
433
+ [libbacktrace_cv_proc],
434
+ [AC_COMPILE_IFELSE(
435
+ [AC_LANG_PROGRAM([
436
+ #include <sys/types.h>
437
+ #include <sys/sysctl.h>
438
+ ], [int mib0 = CTL_KERN; int mib1 = KERN_PROC; int mib2 = KERN_PROC_PATHNAME;])],
439
+ [libbacktrace_cv_proc=yes],
440
+ [libbacktrace_cv_proc=no])])
441
+ if test "$libbacktrace_cv_proc" = "yes"; then
442
+ AC_DEFINE([HAVE_KERN_PROC], 1,
443
+ [Define to 1 if you have KERN_PROC and KERN_PROC_PATHNAME in <sys/sysctl.h>.])
444
+ fi
445
+
446
+ AC_CACHE_CHECK([for KERN_PROG_ARGS],
447
+ [libbacktrace_cv_procargs],
448
+ [AC_COMPILE_IFELSE(
449
+ [AC_LANG_PROGRAM([
450
+ #include <sys/types.h>
451
+ #include <sys/sysctl.h>
452
+ ], [int mib0 = CTL_KERN; int mib1 = KERN_PROC_ARGS; int mib2 = KERN_PROC_PATHNAME;])],
453
+ [libbacktrace_cv_procargs=yes],
454
+ [libbacktrace_cv_procargs=no])])
455
+ if test "$libbacktrace_cv_procargs" = "yes"; then
456
+ AC_DEFINE([HAVE_KERN_PROC_ARGS], 1,
457
+ [Define to 1 if you have KERN_PROCARGS and KERN_PROC_PATHNAME in <sys/sysctl.h>.])
458
+ fi
459
+
460
+ # Check for the clock_gettime function.
461
+ AC_CHECK_FUNCS(clock_gettime)
462
+ clock_gettime_link=
463
+ # At least for glibc, clock_gettime is in librt. But don't
464
+ # pull that in if it still doesn't give us the function we want. This
465
+ # test is copied from libgomp, and modified to not link in -lrt as
466
+ # we're using this for test timing only.
467
+ if test "$ac_cv_func_clock_gettime" = no; then
468
+ AC_CHECK_LIB(rt, clock_gettime,
469
+ [CLOCK_GETTIME_LINK=-lrt
470
+ AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
471
+ [Define to 1 if you have the `clock_gettime' function.])])
472
+ fi
473
+ AC_SUBST(CLOCK_GETTIME_LINK)
474
+
475
+ dnl Test whether the compiler supports the -pthread option.
476
+ AC_CACHE_CHECK([whether -pthread is supported],
477
+ [libgo_cv_lib_pthread],
478
+ [CFLAGS_hold=$CFLAGS
479
+ CFLAGS="$CFLAGS -pthread"
480
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
481
+ [libgo_cv_lib_pthread=yes],
482
+ [libgo_cv_lib_pthread=no])
483
+ CFLAGS=$CFLAGS_hold])
484
+ PTHREAD_CFLAGS=
485
+ if test "$libgo_cv_lib_pthread" = yes; then
486
+ PTHREAD_CFLAGS=-pthread
487
+ fi
488
+ AC_SUBST(PTHREAD_CFLAGS)
489
+
490
+ AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes)
491
+
492
+ dnl Test whether the compiler and the linker support the -gdwarf-5 option.
493
+ AC_CACHE_CHECK([whether -gdwarf-5 is supported],
494
+ [libbacktrace_cv_lib_dwarf5],
495
+ [CFLAGS_hold=$CFLAGS
496
+ CFLAGS="$CFLAGS -gdwarf-5"
497
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;], [return 0;])],
498
+ [libbacktrace_cv_lib_dwarf5=yes],
499
+ [libbacktrace_cv_lib_dwarf5=no])
500
+ CFLAGS=$CFLAGS_hold])
501
+ AM_CONDITIONAL(HAVE_DWARF5, test "$libbacktrace_cv_lib_dwarf5" = yes)
502
+
503
+ AC_CHECK_LIB([z], [compress],
504
+ [AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])])
505
+ AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes)
506
+
507
+ dnl Test whether the linker supports the --build-id option.
508
+ AC_CACHE_CHECK([whether --build-id is supported],
509
+ [libbacktrace_cv_ld_buildid],
510
+ [LDFLAGS_hold=$LDFLAGS
511
+ LDFLAGS="$LDFLAGS -Wl,--build-id"
512
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
513
+ [libbacktrace_cv_ld_buildid=yes],
514
+ [libbacktrace_cv_ld_buildid=no])
515
+ LDFLAGS=$LDFLAGS_hold])
516
+ AM_CONDITIONAL(HAVE_BUILDID, test "$libbacktrace_cv_ld_buildid" = yes)
517
+
518
+ dnl Test whether the linker supports the --compress-debug-sections=zlib-gnu
519
+ dnl option.
520
+ AC_CACHE_CHECK([whether --compress-debug-sections=zlib-gnu is supported],
521
+ [libgo_cv_ld_compress_zlib_gnu],
522
+ [LDFLAGS_hold=$LDFLAGS
523
+ LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gnu"
524
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
525
+ [libgo_cv_ld_compress_zlib_gnu=yes],
526
+ [libgo_cv_ld_compress_zlib_gnu=no])
527
+ LDFLAGS=$LDFLAGS_hold])
528
+ AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG_ZLIB_GNU, test "$libgo_cv_ld_compress_zlib_gnu" = yes)
529
+
530
+ AC_CACHE_CHECK([whether --compress-debug-sections=zlib-gabi is supported],
531
+ [libgo_cv_ld_compress_zlib_gabi],
532
+ [LDFLAGS_hold=$LDFLAGS
533
+ LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gabi"
534
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
535
+ [libgo_cv_ld_compress_zlib_gabi=yes],
536
+ [libgo_cv_ld_compress_zlib_gabi=no])
537
+ LDFLAGS=$LDFLAGS_hold])
538
+ AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG_ZLIB_GABI, test "$libgo_cv_ld_compress_zlib_gabi" = yes)
539
+
540
+ AC_CHECK_LIB([zstd], [ZSTD_compress],
541
+ [AC_DEFINE(HAVE_ZSTD, 1, [Define if -lzstd is available.])])
542
+ AM_CONDITIONAL(HAVE_ZSTD, test "$ac_cv_lib_zstd_ZSTD_compress" = yes)
543
+
544
+ dnl Test whether the linker supports --compress-debug-sections=zstd option.
545
+ AC_CACHE_CHECK([whether --compress-debug-sections=zstd is supported],
546
+ [libgo_cv_ld_compress_zstd],
547
+ [LDFLAGS_hold=$LDFLAGS
548
+ LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zstd"
549
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
550
+ [libgo_cv_ld_compress_zstd=yes],
551
+ [libgo_cv_ld_compress_zstd=no])
552
+ LDFLAGS=$LDFLAGS_hold])
553
+ AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG_ZSTD, test "$libgo_cv_ld_compress_zstd" = yes)
554
+
555
+ AC_ARG_VAR(OBJCOPY, [location of objcopy])
556
+ AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,)
557
+ AC_CHECK_PROG(READELF, readelf, readelf)
558
+ AC_CACHE_CHECK([whether objcopy supports debuglink],
559
+ [libbacktrace_cv_objcopy_debuglink],
560
+ [if test -n "${with_target_subdir}"; then
561
+ libbacktrace_cv_objcopy_debuglink=no
562
+ elif ! test -n "${OBJCOPY}"; then
563
+ libbacktrace_cv_objcopy_debuglink=no
564
+ elif ${OBJCOPY} --help | grep add-gnu-debuglink >/dev/null 2>&1; then
565
+ libbacktrace_cv_objcopy_debuglink=yes
566
+ else
567
+ libbacktrace_cv_objcopy_debuglink=no
568
+ fi])
569
+ AM_CONDITIONAL(HAVE_OBJCOPY_DEBUGLINK, test "$libbacktrace_cv_objcopy_debuglink" = yes)
570
+
571
+ AC_ARG_VAR(DSYMUTIL, [location of dsymutil])
572
+ AC_CHECK_PROG(DSYMUTIL, dsymutil, dsymutil)
573
+ AM_CONDITIONAL(USE_DSYMUTIL, test -n "${DSYMUTIL}" -a "$FORMAT_FILE" = "macho.lo")
574
+
575
+ AC_ARG_VAR(NM, [location of nm])
576
+ AC_CHECK_PROG(NM, nm, nm)
577
+
578
+ AC_CHECK_PROG(XZ, xz, xz)
579
+ AM_CONDITIONAL(HAVE_XZ, test "$XZ" != "")
580
+ AC_CHECK_PROG(COMM, comm, comm)
581
+ AM_CONDITIONAL(HAVE_COMM, test "$COMM" != "")
582
+
583
+ AM_CONDITIONAL(HAVE_MINIDEBUG,
584
+ test "${with_target_subdir}" = "" -a "$FORMAT_FILE" = "elf.lo" -a "${OBJCOPY}" != "" -a "${NM}" != "" -a "${XZ}" != "" -a "${COMM}" != "")
585
+
586
+ AC_CHECK_LIB([lzma], [lzma_auto_decoder],
587
+ [AC_DEFINE(HAVE_LIBLZMA, 1, [Define if -llzma is available.])])
588
+ AM_CONDITIONAL(HAVE_LIBLZMA, test "$ac_cv_lib_lzma_lzma_auto_decoder" = yes)
589
+
590
+ AC_CACHE_CHECK([whether tests can run],
591
+ [libbacktrace_cv_sys_native],
592
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
593
+ [libbacktrace_cv_sys_native=yes],
594
+ [libbacktrace_cv_sys_native=no],
595
+ [libbacktrace_cv_sys_native=no])])
596
+ AM_CONDITIONAL(NATIVE, test "$libbacktrace_cv_sys_native" = "yes")
597
+
598
+ if test "${multilib}" = "yes"; then
599
+ multilib_arg="--enable-multilib"
600
+ else
601
+ multilib_arg=
602
+ fi
603
+
604
+ AC_CONFIG_FILES(Makefile backtrace-supported.h)
605
+ AC_CONFIG_FILES(install-debuginfo-for-buildid.sh, chmod +x install-debuginfo-for-buildid.sh)
606
+
607
+ # We need multilib support, but only if configuring for the target.
608
+ AC_CONFIG_COMMANDS([default],
609
+ [if test -n "$CONFIG_FILES"; then
610
+ if test -n "${with_target_subdir}"; then
611
+ # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
612
+ # that multilib installs will end up installed in the correct place.
613
+ # The testsuite needs it for multilib-aware ABI baseline files.
614
+ # To work around this not being passed down from config-ml.in ->
615
+ # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
616
+ # append it here. Only modify Makefiles that have just been created.
617
+ #
618
+ # Also, get rid of this simulated-VPATH thing that automake does.
619
+ cat > vpsed << \_EOF
620
+ s!`test -f '$<' || echo '$(srcdir)/'`!!
621
+ _EOF
622
+ for i in $SUBDIRS; do
623
+ case $CONFIG_FILES in
624
+ *${i}/Makefile*)
625
+ #echo "Adding MULTISUBDIR to $i/Makefile"
626
+ sed -f vpsed $i/Makefile > tmp
627
+ grep '^MULTISUBDIR =' Makefile >> tmp
628
+ mv tmp $i/Makefile
629
+ ;;
630
+ esac
631
+ done
632
+ rm vpsed
633
+ fi
634
+ fi
635
+ ],
636
+ [
637
+ # Variables needed in config.status (file generation) which aren't already
638
+ # passed by autoconf.
639
+ SUBDIRS="$SUBDIRS"
640
+ ])
641
+
642
+ AC_OUTPUT