1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
# gcc-plugin.m4 -*- Autoconf -*-
# Check whether GCC is able to be built with plugin support.
dnl Copyright (C) 2014 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.
# Check for plugin support.
# Respects --enable-plugin.
# Sets the shell variables enable_plugin and pluginlibs.
AC_DEFUN([GCC_ENABLE_PLUGINS],
[# Check for plugin support
AC_ARG_ENABLE(plugin,
[AS_HELP_STRING([--enable-plugin], [enable plugin support])],
enable_plugin=$enableval,
enable_plugin=yes; default_plugin=yes)
pluginlibs=
plugin_check=yes
case "${host}" in
*-*-mingw*)
# Since plugin support under MinGW is not as straightforward as on
# other platforms (e.g., we have to link import library, etc), we
# only enable it if explicitly requested.
if test x"$default_plugin" = x"yes"; then
enable_plugin=no
elif test x"$enable_plugin" = x"yes"; then
# Use make's target variable to derive import library name.
pluginlibs='-Wl,--export-all-symbols -Wl,--out-implib=[$]@.a'
plugin_check=no
fi
;;
*-*-darwin*)
if test x$build = x$host; then
export_sym_check="nm${exeext} -g"
elif test x$host = x$target; then
export_sym_check="$gcc_cv_nm -g"
else
export_sym_check=
fi
;;
*)
if test x$build = x$host; then
export_sym_check="objdump${exeext} -T"
elif test x$host = x$target; then
export_sym_check="$gcc_cv_objdump -T"
else
export_sym_check=
fi
;;
esac
if test x"$enable_plugin" = x"yes" -a x"$plugin_check" = x"yes"; then
AC_MSG_CHECKING([for exported symbols])
if test "x$export_sym_check" != x; then
echo "int main() {return 0;} int foobar() {return 0;}" > conftest.c
${CC} ${CFLAGS} ${LDFLAGS} conftest.c -o conftest$ac_exeext > /dev/null 2>&1
if $export_sym_check conftest$ac_exeext | grep foobar > /dev/null; then
: # No need to use a flag
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([for -rdynamic])
${CC} ${CFLAGS} ${LDFLAGS} -rdynamic conftest.c -o conftest$ac_exeext > /dev/null 2>&1
if $export_sym_check conftest$ac_exeext | grep foobar > /dev/null; then
plugin_rdynamic=yes
pluginlibs="-rdynamic"
else
plugin_rdynamic=no
enable_plugin=no
fi
AC_MSG_RESULT([$plugin_rdynamic])
fi
else
AC_MSG_RESULT([unable to check])
fi
# Check -ldl
saved_LIBS="$LIBS"
AC_SEARCH_LIBS([dlopen], [dl])
if test x"$ac_cv_search_dlopen" = x"-ldl"; then
pluginlibs="$pluginlibs -ldl"
fi
LIBS="$saved_LIBS"
# Check that we can build shared objects with -fPIC -shared
saved_LDFLAGS="$LDFLAGS"
saved_CFLAGS="$CFLAGS"
case "${host}" in
*-*-darwin*)
CFLAGS=`echo $CFLAGS | sed s/-mdynamic-no-pic//g`
CFLAGS="$CFLAGS -fPIC"
LDFLAGS="$LDFLAGS -shared -undefined dynamic_lookup"
;;
*)
CFLAGS="$CFLAGS -fPIC"
LDFLAGS="$LDFLAGS -fPIC -shared"
;;
esac
AC_MSG_CHECKING([for -fPIC -shared])
AC_TRY_LINK(
[extern int X;],[return X == 0;],
[AC_MSG_RESULT([yes]); have_pic_shared=yes],
[AC_MSG_RESULT([no]); have_pic_shared=no])
if test x"$have_pic_shared" != x"yes" -o x"$ac_cv_search_dlopen" = x"no"; then
pluginlibs=
enable_plugin=no
fi
LDFLAGS="$saved_LDFLAGS"
CFLAGS="$saved_CFLAGS"
# If plugin support had been requested but not available, fail.
if test x"$enable_plugin" = x"no" ; then
if test x"$default_plugin" != x"yes"; then
AC_MSG_ERROR([
Building GCC with plugin support requires a host that supports
-fPIC, -shared, -ldl and -rdynamic.])
fi
fi
fi
])
dnl
dnl
dnl GCC_PLUGIN_OPTION
dnl (SHELL-CODE_HANDLER)
dnl
AC_DEFUN([GCC_PLUGIN_OPTION],[dnl
AC_MSG_CHECKING([for -plugin option])
plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
plugin_option=
for plugin in $plugin_names; do
plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
if test x$plugin_so = x$plugin; then
plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
fi
if test x$plugin_so != x$plugin; then
plugin_option="--plugin $plugin_so"
break
fi
done
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
touch conftest.c
${AR} $plugin_option rc conftest.a conftest.c
if test "$?" != 0; then
AC_MSG_WARN([Failed: $AR $plugin_option rc])
plugin_option=
fi
rm -f conftest.*
if test -n "$plugin_option"; then
$1="$plugin_option"
AC_MSG_RESULT($plugin_option)
else
AC_MSG_RESULT([no])
fi
])
|