annotate config/gcc-plugin.m4 @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 # gcc-plugin.m4 -*- Autoconf -*-
kono
parents:
diff changeset
2 # Check whether GCC is able to be built with plugin support.
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 dnl Copyright (C) 2014 Free Software Foundation, Inc.
kono
parents:
diff changeset
5 dnl This file is free software, distributed under the terms of the GNU
kono
parents:
diff changeset
6 dnl General Public License. As a special exception to the GNU General
kono
parents:
diff changeset
7 dnl Public License, this file may be distributed as part of a program
kono
parents:
diff changeset
8 dnl that contains a configuration script generated by Autoconf, under
kono
parents:
diff changeset
9 dnl the same distribution terms as the rest of that program.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 # Check for plugin support.
kono
parents:
diff changeset
12 # Respects --enable-plugin.
kono
parents:
diff changeset
13 # Sets the shell variables enable_plugin and pluginlibs.
kono
parents:
diff changeset
14 AC_DEFUN([GCC_ENABLE_PLUGINS],
kono
parents:
diff changeset
15 [# Check for plugin support
kono
parents:
diff changeset
16 AC_ARG_ENABLE(plugin,
kono
parents:
diff changeset
17 [AS_HELP_STRING([--enable-plugin], [enable plugin support])],
kono
parents:
diff changeset
18 enable_plugin=$enableval,
kono
parents:
diff changeset
19 enable_plugin=yes; default_plugin=yes)
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 pluginlibs=
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 case "${host}" in
kono
parents:
diff changeset
24 *-*-darwin*)
kono
parents:
diff changeset
25 if test x$build = x$host; then
kono
parents:
diff changeset
26 export_sym_check="nm${exeext} -g"
kono
parents:
diff changeset
27 elif test x$host = x$target; then
kono
parents:
diff changeset
28 export_sym_check="$gcc_cv_nm -g"
kono
parents:
diff changeset
29 else
kono
parents:
diff changeset
30 export_sym_check=
kono
parents:
diff changeset
31 fi
kono
parents:
diff changeset
32 ;;
kono
parents:
diff changeset
33 *)
kono
parents:
diff changeset
34 if test x$build = x$host; then
kono
parents:
diff changeset
35 export_sym_check="objdump${exeext} -T"
kono
parents:
diff changeset
36 elif test x$host = x$target; then
kono
parents:
diff changeset
37 export_sym_check="$gcc_cv_objdump -T"
kono
parents:
diff changeset
38 else
kono
parents:
diff changeset
39 export_sym_check=
kono
parents:
diff changeset
40 fi
kono
parents:
diff changeset
41 ;;
kono
parents:
diff changeset
42 esac
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 if test x"$enable_plugin" = x"yes"; then
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 AC_MSG_CHECKING([for exported symbols])
kono
parents:
diff changeset
47 if test "x$export_sym_check" != x; then
kono
parents:
diff changeset
48 echo "int main() {return 0;} int foobar() {return 0;}" > conftest.c
kono
parents:
diff changeset
49 ${CC} ${CFLAGS} ${LDFLAGS} conftest.c -o conftest$ac_exeext > /dev/null 2>&1
kono
parents:
diff changeset
50 if $export_sym_check conftest$ac_exeext | grep -q foobar > /dev/null; then
kono
parents:
diff changeset
51 : # No need to use a flag
kono
parents:
diff changeset
52 AC_MSG_RESULT([yes])
kono
parents:
diff changeset
53 else
kono
parents:
diff changeset
54 AC_MSG_RESULT([yes])
kono
parents:
diff changeset
55 AC_MSG_CHECKING([for -rdynamic])
kono
parents:
diff changeset
56 ${CC} ${CFLAGS} ${LDFLAGS} -rdynamic conftest.c -o conftest$ac_exeext > /dev/null 2>&1
kono
parents:
diff changeset
57 if $export_sym_check conftest$ac_exeext | grep -q foobar > /dev/null; then
kono
parents:
diff changeset
58 plugin_rdynamic=yes
kono
parents:
diff changeset
59 pluginlibs="-rdynamic"
kono
parents:
diff changeset
60 else
kono
parents:
diff changeset
61 plugin_rdynamic=no
kono
parents:
diff changeset
62 enable_plugin=no
kono
parents:
diff changeset
63 fi
kono
parents:
diff changeset
64 AC_MSG_RESULT([$plugin_rdynamic])
kono
parents:
diff changeset
65 fi
kono
parents:
diff changeset
66 else
kono
parents:
diff changeset
67 AC_MSG_RESULT([unable to check])
kono
parents:
diff changeset
68 fi
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 # Check -ldl
kono
parents:
diff changeset
71 saved_LIBS="$LIBS"
kono
parents:
diff changeset
72 AC_SEARCH_LIBS([dlopen], [dl])
kono
parents:
diff changeset
73 if test x"$ac_cv_search_dlopen" = x"-ldl"; then
kono
parents:
diff changeset
74 pluginlibs="$pluginlibs -ldl"
kono
parents:
diff changeset
75 fi
kono
parents:
diff changeset
76 LIBS="$saved_LIBS"
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 # Check that we can build shared objects with -fPIC -shared
kono
parents:
diff changeset
79 saved_LDFLAGS="$LDFLAGS"
kono
parents:
diff changeset
80 saved_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
81 case "${host}" in
kono
parents:
diff changeset
82 *-*-darwin*)
kono
parents:
diff changeset
83 CFLAGS=`echo $CFLAGS | sed s/-mdynamic-no-pic//g`
kono
parents:
diff changeset
84 CFLAGS="$CFLAGS -fPIC"
kono
parents:
diff changeset
85 LDFLAGS="$LDFLAGS -shared -undefined dynamic_lookup"
kono
parents:
diff changeset
86 ;;
kono
parents:
diff changeset
87 *)
kono
parents:
diff changeset
88 CFLAGS="$CFLAGS -fPIC"
kono
parents:
diff changeset
89 LDFLAGS="$LDFLAGS -fPIC -shared"
kono
parents:
diff changeset
90 ;;
kono
parents:
diff changeset
91 esac
kono
parents:
diff changeset
92 AC_MSG_CHECKING([for -fPIC -shared])
kono
parents:
diff changeset
93 AC_TRY_LINK(
kono
parents:
diff changeset
94 [extern int X;],[return X == 0;],
kono
parents:
diff changeset
95 [AC_MSG_RESULT([yes]); have_pic_shared=yes],
kono
parents:
diff changeset
96 [AC_MSG_RESULT([no]); have_pic_shared=no])
kono
parents:
diff changeset
97 if test x"$have_pic_shared" != x"yes" -o x"$ac_cv_search_dlopen" = x"no"; then
kono
parents:
diff changeset
98 pluginlibs=
kono
parents:
diff changeset
99 enable_plugin=no
kono
parents:
diff changeset
100 fi
kono
parents:
diff changeset
101 LDFLAGS="$saved_LDFLAGS"
kono
parents:
diff changeset
102 CFLAGS="$saved_CFLAGS"
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 # If plugin support had been requested but not available, fail.
kono
parents:
diff changeset
105 if test x"$enable_plugin" = x"no" ; then
kono
parents:
diff changeset
106 if test x"$default_plugin" != x"yes"; then
kono
parents:
diff changeset
107 AC_MSG_ERROR([
kono
parents:
diff changeset
108 Building GCC with plugin support requires a host that supports
kono
parents:
diff changeset
109 -fPIC, -shared, -ldl and -rdynamic.])
kono
parents:
diff changeset
110 fi
kono
parents:
diff changeset
111 fi
kono
parents:
diff changeset
112 fi
kono
parents:
diff changeset
113 ])