aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/bfd64.m438
-rw-r--r--config/clang-plugin.m4114
-rw-r--r--config/dejagnu.m46
-rw-r--r--config/gcc-plugin.m443
4 files changed, 181 insertions, 20 deletions
diff --git a/config/bfd64.m4 b/config/bfd64.m4
index d134f1a..d816f7f 100644
--- a/config/bfd64.m4
+++ b/config/bfd64.m4
@@ -16,21 +16,25 @@ dnl along with this program; see the file COPYING3. If not see
dnl <http://www.gnu.org/licenses/>.
dnl
-dnl See whether 64-bit bfd lib has been enabled.
+dnl Make sure your module depends on `all-bfd' when invoking this macro.
AC_DEFUN([BFD_64_BIT], [dnl
-AC_ARG_ENABLE(64-bit-bfd,
- AS_HELP_STRING([--enable-64-bit-bfd],
- [64-bit support (on hosts with narrower word sizes)]),
- [AS_CASE([$enableval],
- [yes|no], [],
- [*], [AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option)])],
- [enable_64_bit_bfd=no])
-
-dnl If the host is 64-bit, then 64-bit bfd is enabled automatically.
-AS_IF([test "x$enable_64_bit_bfd" = "xno"], [dnl
- AC_CHECK_SIZEOF(void *)
- AS_IF([test "x$ac_cv_sizeof_void_p" = "x8"], [enable_64_bit_bfd=yes])
-])
-
-AM_CONDITIONAL([ENABLE_BFD_64_BIT], [test "x$enable_64_bit_bfd" = "xyes"])
-])
+# See whether 64-bit bfd lib has been enabled.
+OLD_CPPFLAGS=$CPPFLAGS
+# Put the old CPPFLAGS last, in case the user's CPPFLAGS point somewhere
+# with bfd, with -I/foo/include. We always want our bfd.
+CPPFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CPPFLAGS"
+# Note we cannot cache the result of this check because BFD64 may change
+# when a secondary target has been added or removed and we have no access
+# to this information here.
+AC_MSG_CHECKING([whether BFD is 64-bit])
+AC_EGREP_CPP([HAVE_BFD64],
+ AC_LANG_PROGRAM(
+ [#include "bfd.h"],
+ [dnl
+#ifdef BFD64
+HAVE_BFD64
+#endif]),
+ [have_64_bit_bfd=yes],
+ [have_64_bit_bfd=no])
+AC_MSG_RESULT([$have_64_bit_bfd])
+CPPFLAGS=$OLD_CPPFLAGS])
diff --git a/config/clang-plugin.m4 b/config/clang-plugin.m4
new file mode 100644
index 0000000..cc051fe
--- /dev/null
+++ b/config/clang-plugin.m4
@@ -0,0 +1,114 @@
+# clang-plugin.m4 -*- Autoconf -*-
+# Check clang plugin file.
+
+dnl Copyright (C) 2025 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License. As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl
+dnl
+dnl CLANG_PLUGIN_FILE
+dnl (SHELL-CODE_HANDLER)
+dnl
+AC_DEFUN([CLANG_PLUGIN_FILE],[dnl
+ AC_CACHE_CHECK([for clang], clang_cv_is_clang, [
+ AC_EGREP_CPP(yes, [
+#ifdef __clang__
+ yes
+#endif
+ ], clang_cv_is_clang=yes, clang_cv_is_clang=no)])
+ plugin_file=
+ if test $clang_cv_is_clang = yes; then
+ AC_MSG_CHECKING([for clang plugin file])
+ plugin_names="LLVMgold.so"
+ for plugin in $plugin_names; do
+ plugin_file=`${CC} ${CFLAGS} --print-file-name $plugin`
+ if test x$plugin_file = x$plugin; then
+ AC_CHECK_TOOL(LLVM_CONFIG, llvm-config)
+ if test "$?" != 0; then
+ AC_MSG_ERROR([Required tool 'llvm-config' not found on PATH.])
+ fi
+ clang_lib_dir=`$LLVM_CONFIG --libdir`
+ if test -f $clang_lib_dir/$plugin; then
+ plugin_file=$clang_lib_dir/$plugin
+ fi
+ if test x$plugin_file != x$plugin; then
+ break;
+ fi
+ fi
+ done
+ if test -z $plugin_file; then
+ AC_MSG_ERROR([Couldn't find clang plugin file for $CC.])
+ fi
+ dnl Check if ${AR} $plugin_option rc works.
+ AC_CHECK_TOOL(AR, ar)
+ if test "${AR}" = "" ; then
+ AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
+ fi
+ plugin_option="--plugin $plugin_file"
+ touch conftest.c
+ ${AR} $plugin_option rc conftest.a conftest.c
+ if test "$?" != 0; then
+ AC_MSG_WARN([Failed: $AR $plugin_option rc])
+ plugin_file=
+ fi
+ rm -f conftest.*
+ AC_MSG_RESULT($plugin_file)
+ fi
+ $1="$plugin_file"
+])
+
+dnl
+dnl
+dnl CLANG_PLUGIN_FILE_FOR_TARGET
+dnl (SHELL-CODE_HANDLER)
+dnl
+AC_DEFUN([CLANG_PLUGIN_FILE_FOR_TARGET],[dnl
+ COMPILER_FOR_TARGET="${CC_FOR_TARGET}"
+ if test x"${COMPILER_FOR_TARGET}" = x"\$(CC)"; then
+ COMPILER_FOR_TARGET="$CC"
+ fi
+ saved_CC="$CC"
+ CC="$COMPILER_FOR_TARGET"
+ AC_CACHE_CHECK([for clang for target], clang_target_cv_working, [
+ AC_TRY_COMPILE([
+#ifndef __clang__
+#error Not clang
+#endif
+ ],
+ [],
+ clang_target_cv_working=yes, clang_target_cv_working=no)])
+ CC="$saved_CC"
+ plugin_file=
+ if test $clang_target_cv_working = yes; then
+ AC_MSG_CHECKING([for clang plugin file for target])
+ plugin_names="LLVMgold.so"
+ dnl Check if the host compiler is used.
+ for plugin in $plugin_names; do
+ plugin_file=`${COMPILER_FOR_TARGET} ${CFLAGS_FOR_TARGET} --print-file-name $plugin`
+ if test x$plugin_file = x$plugin; then
+ GCC_TARGET_TOOL(llvm-config, LLVM_CONFIG_FOR_TARGET, LLVM_CONFIG)
+ if test "$?" != 0; then
+ AC_MSG_ERROR([Required target tool 'llvm-config' not found.])
+ fi
+ clang_lib_dir=`$LLVM_CONFIG_FOR_TARGET --libdir`
+ if test -f $clang_lib_dir/$plugin; then
+ plugin_file=$clang_lib_dir/$plugin
+ fi
+ fi
+ if test x$plugin_file != x$plugin; then
+ break;
+ fi
+ plugin_file=
+ done
+ if test -n $plugin_file; then
+ AC_MSG_RESULT($plugin_file)
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ $1="$plugin_file"
+])
diff --git a/config/dejagnu.m4 b/config/dejagnu.m4
index 0606e42..e0ed818 100644
--- a/config/dejagnu.m4
+++ b/config/dejagnu.m4
@@ -9,9 +9,9 @@ AC_DEFUN([DEJAGNU_CHECK_VERSION],
AC_MSG_CHECKING([for incompatibility between DejaGnu and GCC])
AC_MSG_RESULT([$ac_cv_dejagnu_compat])
- AC_TRY_LINK([#include <dejagnu.h>],
- [pass ("test foo");
- return 0;],
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <dejagnu.h>]],
+ [[pass ("test foo");
+ return 0;]])],
[ac_cv_dejagnu_compat=yes],
[ac_cv_dejagnu_compat=no])
AC_MSG_RESULT([$ac_cv_dejagnu_compat])
diff --git a/config/gcc-plugin.m4 b/config/gcc-plugin.m4
index c30cfdd..0382147 100644
--- a/config/gcc-plugin.m4
+++ b/config/gcc-plugin.m4
@@ -169,3 +169,46 @@ else
AC_MSG_RESULT([no])
fi
])
+
+dnl
+dnl
+dnl GCC_PLUGIN_OPTION_FOR_TARGET
+dnl (SHELL-CODE_HANDLER)
+dnl
+AC_DEFUN([GCC_PLUGIN_OPTION_FOR_TARGET],[dnl
+COMPILER_FOR_TARGET="${CC_FOR_TARGET}"
+dnl Check if the host compiler is used.
+if test x"${COMPILER_FOR_TARGET}" = x"\$(CC)"; then
+ COMPILER_FOR_TARGET="$CC"
+fi
+saved_CC="$CC"
+CC="$COMPILER_FOR_TARGET"
+AC_CACHE_CHECK([for gcc for target], gcc_target_cv_working, [
+ AC_TRY_COMPILE(
+ [],
+ [],
+ gcc_target_cv_working=yes,
+ gcc_target_cv_working=no)])
+CC="$saved_CC"
+AC_MSG_CHECKING([for -plugin option])
+plugin_option=
+if test $gcc_target_cv_working = yes; then
+ plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+ for plugin in $plugin_names; do
+ plugin_so=`${COMPILER_FOR_TARGET} ${CFLAGS_FOR_TARGET} --print-prog-name $plugin`
+ if test x$plugin_so = x$plugin; then
+ plugin_so=`${COMPILER_FOR_TARGET} ${CFLAGS_FOR_TARGET} --print-file-name $plugin`
+ fi
+ if test x$plugin_so != x$plugin; then
+ plugin_option="--plugin $plugin_so"
+ break
+ fi
+ done
+fi
+if test -n "$plugin_option"; then
+ $1="$plugin_option"
+ AC_MSG_RESULT($plugin_option)
+else
+ AC_MSG_RESULT([no])
+fi
+])