Include <alloca.h> conditionally
[deliverable/binutils-gdb.git] / gdbsupport / common.m4
CommitLineData
3266f10b 1dnl Autoconf configure snippets for common.
b811d2c2 2dnl Copyright (C) 1995-2020 Free Software Foundation, Inc.
3266f10b
TT
3dnl
4dnl This file is part of GDB.
5dnl
6dnl This program is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
8dnl the Free Software Foundation; either version 3 of the License, or
9dnl (at your option) any later version.
10dnl
11dnl This program is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
17dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19dnl Invoke configury needed by the files in 'common'.
20AC_DEFUN([GDB_AC_COMMON], [
db6878ac
SM
21 # Set the 'development' global.
22 . $srcdir/../bfd/development.sh
23
3266f10b 24 AC_HEADER_STDC
3266f10b
TT
25 AC_FUNC_ALLOCA
26
b2ceabe8
TT
27 WIN32APILIBS=
28 case ${host} in
29 *mingw32*)
30 AC_DEFINE(USE_WIN32API, 1,
31 [Define if we should use the Windows API, instead of the
32 POSIX API. On Windows, we use the Windows API when
33 building for MinGW, but the POSIX API when building
34 for Cygwin.])
35 WIN32APILIBS="-lws2_32"
36 ;;
37 esac
38
3266f10b
TT
39 dnl Note that this requires codeset.m4, which is included
40 dnl by the users of common.m4.
41 AM_LANGINFO_CODESET
42
43 AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl
44122162 44 sys/resource.h sys/socket.h dnl
3266f10b 45 sys/un.h sys/wait.h dnl
be628ab8 46 thread_db.h wait.h dnl
2d41fa11 47 termios.h dnl
05ea2a05
TT
48 dlfcn.h dnl
49 linux/elf.h sys/procfs.h proc_service.h)
3266f10b 50
05ea2a05
TT
51 AC_FUNC_MMAP
52 AC_FUNC_VFORK
c12d372d 53 AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair sigaction \
05ea2a05
TT
54 ptrace64 sbrk setns sigaltstack sigprocmask \
55 setpgid setpgrp getrusage getauxval])
56
57 dnl Check if we can disable the virtual address space randomization.
58 dnl The functionality of setarch -R.
59 AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
60 define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
61 # if !HAVE_DECL_ADDR_NO_RANDOMIZE
62 # define ADDR_NO_RANDOMIZE 0x0040000
63 # endif
64 /* Test the flag could be set and stays set. */
65 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
66 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
67 return 1])])
68 AC_RUN_IFELSE([PERSONALITY_TEST],
69 [have_personality=true],
70 [have_personality=false],
71 [AC_LINK_IFELSE([PERSONALITY_TEST],
72 [have_personality=true],
73 [have_personality=false])])
74 if $have_personality
75 then
76 AC_DEFINE([HAVE_PERSONALITY], 1,
77 [Define if you support the personality syscall.])
78 fi
3266f10b 79
ab7d13f0 80 AC_CHECK_DECLS([strstr])
e9bcb658 81
05ea2a05
TT
82 # ----------------------- #
83 # Checks for structures. #
84 # ----------------------- #
85
86 AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_blksize])
87
88 AC_SEARCH_LIBS(kinfo_getfile, util util-freebsd,
89 [AC_DEFINE(HAVE_KINFO_GETFILE, 1,
90 [Define to 1 if your system has the kinfo_getfile function. ])])
91
5e030278
TT
92 # Check for std::thread. This does not work on some platforms, like
93 # mingw and DJGPP.
94 AC_LANG_PUSH([C++])
95 AX_PTHREAD([threads=yes], [threads=no])
96 if test "$threads" = "yes"; then
97 save_LIBS="$LIBS"
98 LIBS="$PTHREAD_LIBS $LIBS"
99 save_CXXFLAGS="$CXXFLAGS"
100 CXXFLAGS="$PTHREAD_CFLAGS $save_CXXFLAGS"
101 AC_CACHE_CHECK([for std::thread],
102 gdb_cv_cxx_std_thread,
103 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
104 [[#include <thread>
105 void callback() { }]],
106 [[std::thread t(callback);]])],
107 gdb_cv_cxx_std_thread=yes,
108 gdb_cv_cxx_std_thread=no)])
21987b9c
TT
109
110 # This check must be here, while LIBS includes any necessary
111 # threading library.
4da8c3a8 112 AC_CHECK_FUNCS([pthread_sigmask pthread_setname_np])
21987b9c 113
5e030278
TT
114 LIBS="$save_LIBS"
115 CXXFLAGS="$save_CXXFLAGS"
116 fi
0ad6b8ee 117 if test "$gdb_cv_cxx_std_thread" = "yes"; then
5e030278
TT
118 AC_DEFINE(CXX_STD_THREAD, 1,
119 [Define to 1 if std::thread works.])
120 fi
121 AC_LANG_POP
122
e9bcb658
GB
123 dnl Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't
124 dnl do since sigsetjmp might only be defined as a macro.
25c51f71
TT
125 AC_CACHE_CHECK([for sigsetjmp], gdb_cv_func_sigsetjmp,
126 [AC_TRY_COMPILE([
127 #include <setjmp.h>
128 ], [sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);],
129 gdb_cv_func_sigsetjmp=yes, gdb_cv_func_sigsetjmp=no)])
130 if test "$gdb_cv_func_sigsetjmp" = "yes"; then
131 AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
132 fi
05ea2a05
TT
133
134 AC_ARG_WITH(intel_pt,
135 AS_HELP_STRING([--with-intel-pt], [include Intel Processor Trace support (auto/yes/no)]),
136 [], [with_intel_pt=auto])
137 AC_MSG_CHECKING([whether to use intel pt])
138 AC_MSG_RESULT([$with_intel_pt])
139
140 if test "${with_intel_pt}" = no; then
141 AC_MSG_WARN([Intel Processor Trace support disabled; some features may be unavailable.])
142 HAVE_LIBIPT=no
143 else
144 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
145 #include <linux/perf_event.h>
146 #ifndef PERF_ATTR_SIZE_VER5
147 # error
148 #endif
149 ]])], [perf_event=yes], [perf_event=no])
150 if test "$perf_event" != yes; then
151 if test "$with_intel_pt" = yes; then
152 AC_MSG_ERROR([linux/perf_event.h missing or too old])
153 else
154 AC_MSG_WARN([linux/perf_event.h missing or too old; some features may be unavailable.])
155 fi
156 fi
157
158 AC_LIB_HAVE_LINKFLAGS([ipt], [], [#include "intel-pt.h"], [pt_insn_alloc_decoder (0);])
159 if test "$HAVE_LIBIPT" != yes; then
160 if test "$with_intel_pt" = yes; then
161 AC_MSG_ERROR([libipt is missing or unusable])
162 else
163 AC_MSG_WARN([libipt is missing or unusable; some features may be unavailable.])
164 fi
165 else
166 save_LIBS=$LIBS
167 LIBS="$LIBS $LIBIPT"
168 AC_CHECK_FUNCS(pt_insn_event)
169 AC_CHECK_MEMBERS([struct pt_insn.enabled, struct pt_insn.resynced], [], [],
170 [#include <intel-pt.h>])
171 LIBS=$save_LIBS
172 fi
173 fi
174
175 if test "$ac_cv_header_sys_procfs_h" = yes; then
176 BFD_HAVE_SYS_PROCFS_TYPE(gregset_t)
177 BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t)
178 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
179 BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t)
180 BFD_HAVE_SYS_PROCFS_TYPE(prgregset32_t)
181 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
182 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
183 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
184 fi
3266f10b 185])
This page took 0.46018 seconds and 4 git commands to generate.