| 1 | dnl Autoconf configure snippets for common. |
| 2 | dnl Copyright (C) 1995-2020 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/>. |
| 18 | |
| 19 | dnl Invoke configury needed by the files in 'common'. |
| 20 | AC_DEFUN([GDB_AC_COMMON], [ |
| 21 | AC_HEADER_STDC |
| 22 | AC_FUNC_ALLOCA |
| 23 | |
| 24 | WIN32APILIBS= |
| 25 | case ${host} in |
| 26 | *mingw32*) |
| 27 | AC_DEFINE(USE_WIN32API, 1, |
| 28 | [Define if we should use the Windows API, instead of the |
| 29 | POSIX API. On Windows, we use the Windows API when |
| 30 | building for MinGW, but the POSIX API when building |
| 31 | for Cygwin.]) |
| 32 | WIN32APILIBS="-lws2_32" |
| 33 | ;; |
| 34 | esac |
| 35 | |
| 36 | dnl Note that this requires codeset.m4, which is included |
| 37 | dnl by the users of common.m4. |
| 38 | AM_LANGINFO_CODESET |
| 39 | |
| 40 | AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl |
| 41 | sys/resource.h sys/socket.h dnl |
| 42 | sys/un.h sys/wait.h dnl |
| 43 | thread_db.h wait.h dnl |
| 44 | termios.h dnl |
| 45 | dlfcn.h dnl |
| 46 | linux/elf.h sys/procfs.h proc_service.h) |
| 47 | |
| 48 | AC_FUNC_MMAP |
| 49 | AC_FUNC_VFORK |
| 50 | AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair sigaction \ |
| 51 | ptrace64 sbrk setns sigaltstack sigprocmask \ |
| 52 | setpgid setpgrp getrusage getauxval]) |
| 53 | |
| 54 | dnl Check if we can disable the virtual address space randomization. |
| 55 | dnl The functionality of setarch -R. |
| 56 | AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>]) |
| 57 | define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [ |
| 58 | # if !HAVE_DECL_ADDR_NO_RANDOMIZE |
| 59 | # define ADDR_NO_RANDOMIZE 0x0040000 |
| 60 | # endif |
| 61 | /* Test the flag could be set and stays set. */ |
| 62 | personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE); |
| 63 | if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE)) |
| 64 | return 1])]) |
| 65 | AC_RUN_IFELSE([PERSONALITY_TEST], |
| 66 | [have_personality=true], |
| 67 | [have_personality=false], |
| 68 | [AC_LINK_IFELSE([PERSONALITY_TEST], |
| 69 | [have_personality=true], |
| 70 | [have_personality=false])]) |
| 71 | if $have_personality |
| 72 | then |
| 73 | AC_DEFINE([HAVE_PERSONALITY], 1, |
| 74 | [Define if you support the personality syscall.]) |
| 75 | fi |
| 76 | |
| 77 | AC_CHECK_DECLS([strstr]) |
| 78 | |
| 79 | # ----------------------- # |
| 80 | # Checks for structures. # |
| 81 | # ----------------------- # |
| 82 | |
| 83 | AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_blksize]) |
| 84 | |
| 85 | AC_SEARCH_LIBS(kinfo_getfile, util util-freebsd, |
| 86 | [AC_DEFINE(HAVE_KINFO_GETFILE, 1, |
| 87 | [Define to 1 if your system has the kinfo_getfile function. ])]) |
| 88 | |
| 89 | # Check for std::thread. This does not work on some platforms, like |
| 90 | # mingw and DJGPP. |
| 91 | AC_LANG_PUSH([C++]) |
| 92 | AX_PTHREAD([threads=yes], [threads=no]) |
| 93 | if test "$threads" = "yes"; then |
| 94 | save_LIBS="$LIBS" |
| 95 | LIBS="$PTHREAD_LIBS $LIBS" |
| 96 | save_CXXFLAGS="$CXXFLAGS" |
| 97 | CXXFLAGS="$PTHREAD_CFLAGS $save_CXXFLAGS" |
| 98 | AC_CACHE_CHECK([for std::thread], |
| 99 | gdb_cv_cxx_std_thread, |
| 100 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 101 | [[#include <thread> |
| 102 | void callback() { }]], |
| 103 | [[std::thread t(callback);]])], |
| 104 | gdb_cv_cxx_std_thread=yes, |
| 105 | gdb_cv_cxx_std_thread=no)]) |
| 106 | |
| 107 | # This check must be here, while LIBS includes any necessary |
| 108 | # threading library. |
| 109 | AC_CHECK_FUNCS([pthread_sigmask pthread_setname_np]) |
| 110 | |
| 111 | LIBS="$save_LIBS" |
| 112 | CXXFLAGS="$save_CXXFLAGS" |
| 113 | fi |
| 114 | if test "$gdb_cv_cxx_std_thread" = "yes"; then |
| 115 | AC_DEFINE(CXX_STD_THREAD, 1, |
| 116 | [Define to 1 if std::thread works.]) |
| 117 | fi |
| 118 | AC_LANG_POP |
| 119 | |
| 120 | dnl Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't |
| 121 | dnl do since sigsetjmp might only be defined as a macro. |
| 122 | AC_CACHE_CHECK([for sigsetjmp], gdb_cv_func_sigsetjmp, |
| 123 | [AC_TRY_COMPILE([ |
| 124 | #include <setjmp.h> |
| 125 | ], [sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);], |
| 126 | gdb_cv_func_sigsetjmp=yes, gdb_cv_func_sigsetjmp=no)]) |
| 127 | if test "$gdb_cv_func_sigsetjmp" = "yes"; then |
| 128 | AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ]) |
| 129 | fi |
| 130 | |
| 131 | AC_ARG_WITH(intel_pt, |
| 132 | AS_HELP_STRING([--with-intel-pt], [include Intel Processor Trace support (auto/yes/no)]), |
| 133 | [], [with_intel_pt=auto]) |
| 134 | AC_MSG_CHECKING([whether to use intel pt]) |
| 135 | AC_MSG_RESULT([$with_intel_pt]) |
| 136 | |
| 137 | if test "${with_intel_pt}" = no; then |
| 138 | AC_MSG_WARN([Intel Processor Trace support disabled; some features may be unavailable.]) |
| 139 | HAVE_LIBIPT=no |
| 140 | else |
| 141 | AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ |
| 142 | #include <linux/perf_event.h> |
| 143 | #ifndef PERF_ATTR_SIZE_VER5 |
| 144 | # error |
| 145 | #endif |
| 146 | ]])], [perf_event=yes], [perf_event=no]) |
| 147 | if test "$perf_event" != yes; then |
| 148 | if test "$with_intel_pt" = yes; then |
| 149 | AC_MSG_ERROR([linux/perf_event.h missing or too old]) |
| 150 | else |
| 151 | AC_MSG_WARN([linux/perf_event.h missing or too old; some features may be unavailable.]) |
| 152 | fi |
| 153 | fi |
| 154 | |
| 155 | AC_LIB_HAVE_LINKFLAGS([ipt], [], [#include "intel-pt.h"], [pt_insn_alloc_decoder (0);]) |
| 156 | if test "$HAVE_LIBIPT" != yes; then |
| 157 | if test "$with_intel_pt" = yes; then |
| 158 | AC_MSG_ERROR([libipt is missing or unusable]) |
| 159 | else |
| 160 | AC_MSG_WARN([libipt is missing or unusable; some features may be unavailable.]) |
| 161 | fi |
| 162 | else |
| 163 | save_LIBS=$LIBS |
| 164 | LIBS="$LIBS $LIBIPT" |
| 165 | AC_CHECK_FUNCS(pt_insn_event) |
| 166 | AC_CHECK_MEMBERS([struct pt_insn.enabled, struct pt_insn.resynced], [], [], |
| 167 | [#include <intel-pt.h>]) |
| 168 | LIBS=$save_LIBS |
| 169 | fi |
| 170 | fi |
| 171 | |
| 172 | if test "$ac_cv_header_sys_procfs_h" = yes; then |
| 173 | BFD_HAVE_SYS_PROCFS_TYPE(gregset_t) |
| 174 | BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t) |
| 175 | BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t) |
| 176 | BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t) |
| 177 | BFD_HAVE_SYS_PROCFS_TYPE(prgregset32_t) |
| 178 | BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t) |
| 179 | BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t) |
| 180 | BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t) |
| 181 | fi |
| 182 | ]) |