annotate config/gcc-plugin.m4 @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
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=
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
22 plugin_check=yes
111
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 case "${host}" in
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
25 *-*-mingw*)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
26 # Since plugin support under MinGW is not as straightforward as on
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
27 # other platforms (e.g., we have to link import library, etc), we
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
28 # only enable it if explicitly requested.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
29 if test x"$default_plugin" = x"yes"; then
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
30 enable_plugin=no
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
31 elif test x"$enable_plugin" = x"yes"; then
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
32 # Use make's target variable to derive import library name.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
33 pluginlibs='-Wl,--export-all-symbols -Wl,--out-implib=[$]@.a'
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
34 plugin_check=no
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
35 fi
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
36 ;;
111
kono
parents:
diff changeset
37 *-*-darwin*)
kono
parents:
diff changeset
38 if test x$build = x$host; then
kono
parents:
diff changeset
39 export_sym_check="nm${exeext} -g"
kono
parents:
diff changeset
40 elif test x$host = x$target; then
kono
parents:
diff changeset
41 export_sym_check="$gcc_cv_nm -g"
kono
parents:
diff changeset
42 else
kono
parents:
diff changeset
43 export_sym_check=
kono
parents:
diff changeset
44 fi
kono
parents:
diff changeset
45 ;;
kono
parents:
diff changeset
46 *)
kono
parents:
diff changeset
47 if test x$build = x$host; then
kono
parents:
diff changeset
48 export_sym_check="objdump${exeext} -T"
kono
parents:
diff changeset
49 elif test x$host = x$target; then
kono
parents:
diff changeset
50 export_sym_check="$gcc_cv_objdump -T"
kono
parents:
diff changeset
51 else
kono
parents:
diff changeset
52 export_sym_check=
kono
parents:
diff changeset
53 fi
kono
parents:
diff changeset
54 ;;
kono
parents:
diff changeset
55 esac
kono
parents:
diff changeset
56
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
57 if test x"$enable_plugin" = x"yes" -a x"$plugin_check" = x"yes"; then
111
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 AC_MSG_CHECKING([for exported symbols])
kono
parents:
diff changeset
60 if test "x$export_sym_check" != x; then
kono
parents:
diff changeset
61 echo "int main() {return 0;} int foobar() {return 0;}" > conftest.c
kono
parents:
diff changeset
62 ${CC} ${CFLAGS} ${LDFLAGS} conftest.c -o conftest$ac_exeext > /dev/null 2>&1
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
63 if $export_sym_check conftest$ac_exeext | grep foobar > /dev/null; then
111
kono
parents:
diff changeset
64 : # No need to use a flag
kono
parents:
diff changeset
65 AC_MSG_RESULT([yes])
kono
parents:
diff changeset
66 else
kono
parents:
diff changeset
67 AC_MSG_RESULT([yes])
kono
parents:
diff changeset
68 AC_MSG_CHECKING([for -rdynamic])
kono
parents:
diff changeset
69 ${CC} ${CFLAGS} ${LDFLAGS} -rdynamic conftest.c -o conftest$ac_exeext > /dev/null 2>&1
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
70 if $export_sym_check conftest$ac_exeext | grep foobar > /dev/null; then
111
kono
parents:
diff changeset
71 plugin_rdynamic=yes
kono
parents:
diff changeset
72 pluginlibs="-rdynamic"
kono
parents:
diff changeset
73 else
kono
parents:
diff changeset
74 plugin_rdynamic=no
kono
parents:
diff changeset
75 enable_plugin=no
kono
parents:
diff changeset
76 fi
kono
parents:
diff changeset
77 AC_MSG_RESULT([$plugin_rdynamic])
kono
parents:
diff changeset
78 fi
kono
parents:
diff changeset
79 else
kono
parents:
diff changeset
80 AC_MSG_RESULT([unable to check])
kono
parents:
diff changeset
81 fi
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 # Check -ldl
kono
parents:
diff changeset
84 saved_LIBS="$LIBS"
kono
parents:
diff changeset
85 AC_SEARCH_LIBS([dlopen], [dl])
kono
parents:
diff changeset
86 if test x"$ac_cv_search_dlopen" = x"-ldl"; then
kono
parents:
diff changeset
87 pluginlibs="$pluginlibs -ldl"
kono
parents:
diff changeset
88 fi
kono
parents:
diff changeset
89 LIBS="$saved_LIBS"
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 # Check that we can build shared objects with -fPIC -shared
kono
parents:
diff changeset
92 saved_LDFLAGS="$LDFLAGS"
kono
parents:
diff changeset
93 saved_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
94 case "${host}" in
kono
parents:
diff changeset
95 *-*-darwin*)
kono
parents:
diff changeset
96 CFLAGS=`echo $CFLAGS | sed s/-mdynamic-no-pic//g`
kono
parents:
diff changeset
97 CFLAGS="$CFLAGS -fPIC"
kono
parents:
diff changeset
98 LDFLAGS="$LDFLAGS -shared -undefined dynamic_lookup"
kono
parents:
diff changeset
99 ;;
kono
parents:
diff changeset
100 *)
kono
parents:
diff changeset
101 CFLAGS="$CFLAGS -fPIC"
kono
parents:
diff changeset
102 LDFLAGS="$LDFLAGS -fPIC -shared"
kono
parents:
diff changeset
103 ;;
kono
parents:
diff changeset
104 esac
kono
parents:
diff changeset
105 AC_MSG_CHECKING([for -fPIC -shared])
kono
parents:
diff changeset
106 AC_TRY_LINK(
kono
parents:
diff changeset
107 [extern int X;],[return X == 0;],
kono
parents:
diff changeset
108 [AC_MSG_RESULT([yes]); have_pic_shared=yes],
kono
parents:
diff changeset
109 [AC_MSG_RESULT([no]); have_pic_shared=no])
kono
parents:
diff changeset
110 if test x"$have_pic_shared" != x"yes" -o x"$ac_cv_search_dlopen" = x"no"; then
kono
parents:
diff changeset
111 pluginlibs=
kono
parents:
diff changeset
112 enable_plugin=no
kono
parents:
diff changeset
113 fi
kono
parents:
diff changeset
114 LDFLAGS="$saved_LDFLAGS"
kono
parents:
diff changeset
115 CFLAGS="$saved_CFLAGS"
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 # If plugin support had been requested but not available, fail.
kono
parents:
diff changeset
118 if test x"$enable_plugin" = x"no" ; then
kono
parents:
diff changeset
119 if test x"$default_plugin" != x"yes"; then
kono
parents:
diff changeset
120 AC_MSG_ERROR([
kono
parents:
diff changeset
121 Building GCC with plugin support requires a host that supports
kono
parents:
diff changeset
122 -fPIC, -shared, -ldl and -rdynamic.])
kono
parents:
diff changeset
123 fi
kono
parents:
diff changeset
124 fi
kono
parents:
diff changeset
125 fi
kono
parents:
diff changeset
126 ])