Mention support for AMD/znver5 in GAS
[binutils-gdb.git] / gdbsupport / common.m4
blob240ec008f2a4d5073716aca530ae7d516c4ef839
1 dnl Autoconf configure snippets for common.
2 dnl Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 dnl
4 dnl This file is part of GDB.
5 dnl 
6 dnl This program is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 3 of the License, or
9 dnl (at your option) any later version.
10 dnl
11 dnl This program is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 dnl GNU General Public License for more details.
15 dnl
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 dnl Invoke configury needed by the files in 'common'.
20 AC_DEFUN([GDB_AC_COMMON], [
21   # Set the 'development' global.
22   . $srcdir/../bfd/development.sh
24   AC_HEADER_STDC
25   AC_FUNC_ALLOCA
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
39   dnl Note that this requires codeset.m4, which is included
40   dnl by the users of common.m4.
41   AM_LANGINFO_CODESET
43   AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl
44                    sys/resource.h sys/socket.h dnl
45                    sys/un.h sys/wait.h dnl
46                    thread_db.h wait.h dnl
47                    termios.h dnl
48                    dlfcn.h dnl
49                    linux/elf.h proc_service.h dnl
50                    poll.h sys/poll.h sys/select.h)
52   AC_FUNC_MMAP
53   AC_FUNC_FORK
54   # Some systems (e.g. Solaris) have `socketpair' in libsocket.
55   AC_SEARCH_LIBS(socketpair, socket)
56   AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 poll socketpair sigaction \
57                   ptrace64 sbrk setns sigaltstack sigprocmask \
58                   setpgid setpgrp getrusage getauxval sigtimedwait])
60   # This is needed for RHEL 5 and uclibc-ng < 1.0.39.
61   # These did not define ADDR_NO_RANDOMIZE in sys/personality.h,
62   # only in linux/personality.h.
63   AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
65   AC_CHECK_DECLS([strstr])
67   # ----------------------- #
68   # Checks for structures.  #
69   # ----------------------- #
71   AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_blksize])
73   # On FreeBSD we need libutil for the kinfo_get* functions.  On
74   # GNU/kFreeBSD systems, FreeBSD libutil is renamed to libutil-freebsd.
75   # Figure out which one to use.
76   AC_SEARCH_LIBS(kinfo_getfile, util util-freebsd)
78   # Define HAVE_KINFO_GETFILE if kinfo_getfile is available.
79   AC_CHECK_FUNCS(kinfo_getfile)
81   # ----------------------- #
82   # Check for threading.    #
83   # ----------------------- #
85   AC_ARG_ENABLE(threading,
86     AS_HELP_STRING([--enable-threading], [include support for parallel processing of data (yes/no)]),
87     [case "$enableval" in
88     yes) want_threading=yes ;;
89     no) want_threading=no ;;
90     *) AC_MSG_ERROR([bad value $enableval for threading]) ;;
91     esac],
92     [want_threading=yes])
94   # Check for std::thread.  This does not work on some platforms, like
95   # mingw and DJGPP.
96   AC_LANG_PUSH([C++])
97   AX_PTHREAD([threads=yes], [threads=no])
98   save_LIBS="$LIBS"
99   LIBS="$PTHREAD_LIBS $LIBS"
100   save_CXXFLAGS="$CXXFLAGS"
101   CXXFLAGS="$PTHREAD_CFLAGS $save_CXXFLAGS"
102   AC_CACHE_CHECK([for std::thread],
103                  gdb_cv_cxx_std_thread,
104                  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
105   dnl NOTE: this must be kept in sync with common-defs.h.
106   [[#if defined (__MINGW32__) || defined (__CYGWIN__)
107     # ifdef _WIN32_WINNT
108     #  if _WIN32_WINNT < 0x0501
109     #   undef _WIN32_WINNT
110     #   define _WIN32_WINNT 0x0501
111     #  endif
112     # else
113     #  define _WIN32_WINNT 0x0501
114     # endif
115     #endif      /* __MINGW32__ || __CYGWIN__ */
116     #include <thread>
117     void callback() { }]],
118   [[std::thread t(callback);]])],
119                                 gdb_cv_cxx_std_thread=yes,
120                                 gdb_cv_cxx_std_thread=no)])
122   if test "$threads" = "yes"; then
123     # This check must be here, while LIBS includes any necessary
124     # threading library.
125     AC_CHECK_FUNCS([pthread_sigmask pthread_setname_np])
126   fi
127   LIBS="$save_LIBS"
128   CXXFLAGS="$save_CXXFLAGS"
130   if test "$want_threading" = "yes"; then
131     if test "$gdb_cv_cxx_std_thread" = "yes"; then
132       AC_DEFINE(CXX_STD_THREAD, 1,
133                 [Define to 1 if std::thread works.])
134     fi
135   fi
136   AC_LANG_POP
138   dnl Check if sigsetjmp is available.  Using AC_CHECK_FUNCS won't
139   dnl do since sigsetjmp might only be defined as a macro.
140   AC_CACHE_CHECK(
141     [for sigsetjmp],
142     [gdb_cv_func_sigsetjmp],
143     [AC_COMPILE_IFELSE(
144        [AC_LANG_PROGRAM(
145           [#include <setjmp.h>],
146           [sigjmp_buf env;
147            while (! sigsetjmp (env, 1))
148              siglongjmp (env, 1);]
149         )],
150        [gdb_cv_func_sigsetjmp=yes],
151        [gdb_cv_func_sigsetjmp=no]
152      )]
153   )
154   if test "$gdb_cv_func_sigsetjmp" = "yes"; then
155     AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
156   fi
158   AC_ARG_WITH(intel_pt,
159     AS_HELP_STRING([--with-intel-pt], [include Intel Processor Trace support (auto/yes/no)]),
160     [], [with_intel_pt=auto])
161   AC_MSG_CHECKING([whether to use intel pt])
162   AC_MSG_RESULT([$with_intel_pt])
164   if test "${with_intel_pt}" = no; then
165     AC_MSG_WARN([Intel Processor Trace support disabled; some features may be unavailable.])
166     HAVE_LIBIPT=no
167   else
168     AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
169   #include <linux/perf_event.h>
170   #ifndef PERF_ATTR_SIZE_VER5
171   # error
172   #endif
173     ]])], [perf_event=yes], [perf_event=no])
174     if test "$perf_event" != yes; then
175       if test "$with_intel_pt" = yes; then
176         AC_MSG_ERROR([linux/perf_event.h missing or too old])
177       else
178         AC_MSG_WARN([linux/perf_event.h missing or too old; some features may be unavailable.])
179       fi
180     fi
182     AC_LIB_HAVE_LINKFLAGS([ipt], [], [#include "intel-pt.h"], [pt_insn_alloc_decoder (0);])
183     if test "$HAVE_LIBIPT" != yes; then
184       if test "$with_intel_pt" = yes; then
185         AC_MSG_ERROR([libipt is missing or unusable])
186       else
187         AC_MSG_WARN([libipt is missing or unusable; some features may be unavailable.])
188       fi
189     else
190       save_LIBS=$LIBS
191       LIBS="$LIBS $LIBIPT"
192       AC_CHECK_FUNCS(pt_insn_event)
193       AC_CHECK_MEMBERS([struct pt_insn.enabled, struct pt_insn.resynced], [], [],
194                        [#include <intel-pt.h>])
195       LIBS=$save_LIBS
196     fi
197   fi
199   # Check if the compiler and runtime support printing long longs.
201   AC_CACHE_CHECK([for long long support in printf],
202                  gdb_cv_printf_has_long_long,
203                  [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
204   [[char buf[32];
205     long long l = 0;
206     l = (l << 16) + 0x0123;
207     l = (l << 16) + 0x4567;
208     l = (l << 16) + 0x89ab;
209     l = (l << 16) + 0xcdef;
210     sprintf (buf, "0x%016llx", l);
211     return (strcmp ("0x0123456789abcdef", buf));]])],
212                                 gdb_cv_printf_has_long_long=yes,
213                                 gdb_cv_printf_has_long_long=no,
214                                 gdb_cv_printf_has_long_long=no)])
215   if test "$gdb_cv_printf_has_long_long" = yes; then
216     AC_DEFINE(PRINTF_HAS_LONG_LONG, 1,
217               [Define to 1 if the "%ll" format works to print long longs.])
218   fi
220   BFD_SYS_PROCFS_H
221   if test "$ac_cv_header_sys_procfs_h" = yes; then
222     BFD_HAVE_SYS_PROCFS_TYPE(gregset_t)
223     BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t)
224     BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
225     BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t)
226     BFD_HAVE_SYS_PROCFS_TYPE(prgregset32_t)
227     BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
228     BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
229     BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
230   fi
232   dnl xxhash support
233   # Check for xxhash
234   AC_ARG_WITH(xxhash,
235     AS_HELP_STRING([--with-xxhash], [use libxxhash for hashing (faster) (auto/yes/no)]),
236     [], [with_xxhash=auto])
238   if test "x$with_xxhash" != "xno"; then
239     AC_LIB_HAVE_LINKFLAGS([xxhash], [],
240                           [#include <xxhash.h>],
241                           [XXH32("foo", 3, 0);
242                           ])
243     if test "$HAVE_LIBXXHASH" != yes; then
244       if test "$with_xxhash" = yes; then
245         AC_MSG_ERROR([xxhash is missing or unusable])
246       fi
247     fi
248     if test "x$with_xxhash" = "xauto"; then
249       with_xxhash="$HAVE_LIBXXHASH"
250     fi
251   fi
253   AC_MSG_CHECKING([whether to use xxhash])
254   AC_MSG_RESULT([$with_xxhash])
257 dnl Check that the provided value ($1) is either "yes" or "no".  If not,
258 dnl emit an error message mentionning the configure option $2, and abort
259 dnl the script.
260 AC_DEFUN([GDB_CHECK_YES_NO_VAL],
261          [
262            case $1 in
263              yes | no)
264                ;;
265              *)
266                AC_MSG_ERROR([bad value $1 for $2])
267                ;;
268            esac
269           ])
271 dnl Check that the provided value ($1) is either "yes", "no" or "auto".  If not,
272 dnl emit an error message mentionning the configure option $2, and abort
273 dnl the script.
274 AC_DEFUN([GDB_CHECK_YES_NO_AUTO_VAL],
275          [
276            case $1 in
277              yes | no | auto)
278                ;;
279              *)
280                AC_MSG_ERROR([bad value $1 for $2])
281                ;;
282            esac
283           ])