1 |
273 |
jeremybenn |
dnl ----------------------------------------------------------------------
|
2 |
|
|
dnl This whole bit snagged from libgfortran.
|
3 |
|
|
|
4 |
|
|
dnl Check whether the target supports __sync_*_compare_and_swap.
|
5 |
|
|
AC_DEFUN([LIBGOMP_CHECK_SYNC_BUILTINS], [
|
6 |
|
|
AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
|
7 |
|
|
libgomp_cv_have_sync_builtins, [
|
8 |
|
|
AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
|
9 |
|
|
libgomp_cv_have_sync_builtins=yes, libgomp_cv_have_sync_builtins=no)])
|
10 |
|
|
if test $libgomp_cv_have_sync_builtins = yes; then
|
11 |
|
|
AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
|
12 |
|
|
[Define to 1 if the target supports __sync_*_compare_and_swap])
|
13 |
|
|
fi])
|
14 |
|
|
|
15 |
|
|
dnl Check whether the target supports hidden visibility.
|
16 |
|
|
AC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_VISIBILITY], [
|
17 |
|
|
AC_CACHE_CHECK([whether the target supports hidden visibility],
|
18 |
|
|
libgomp_cv_have_attribute_visibility, [
|
19 |
|
|
save_CFLAGS="$CFLAGS"
|
20 |
|
|
CFLAGS="$CFLAGS -Werror"
|
21 |
|
|
AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
|
22 |
|
|
[], libgomp_cv_have_attribute_visibility=yes,
|
23 |
|
|
libgomp_cv_have_attribute_visibility=no)
|
24 |
|
|
CFLAGS="$save_CFLAGS"])
|
25 |
|
|
if test $libgomp_cv_have_attribute_visibility = yes; then
|
26 |
|
|
AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
|
27 |
|
|
[Define to 1 if the target supports __attribute__((visibility(...))).])
|
28 |
|
|
fi])
|
29 |
|
|
|
30 |
|
|
dnl Check whether the target supports dllexport
|
31 |
|
|
AC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_DLLEXPORT], [
|
32 |
|
|
AC_CACHE_CHECK([whether the target supports dllexport],
|
33 |
|
|
libgomp_cv_have_attribute_dllexport, [
|
34 |
|
|
save_CFLAGS="$CFLAGS"
|
35 |
|
|
CFLAGS="$CFLAGS -Werror"
|
36 |
|
|
AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }],
|
37 |
|
|
[], libgomp_cv_have_attribute_dllexport=yes,
|
38 |
|
|
libgomp_cv_have_attribute_dllexport=no)
|
39 |
|
|
CFLAGS="$save_CFLAGS"])
|
40 |
|
|
if test $libgomp_cv_have_attribute_dllexport = yes; then
|
41 |
|
|
AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1,
|
42 |
|
|
[Define to 1 if the target supports __attribute__((dllexport)).])
|
43 |
|
|
fi])
|
44 |
|
|
|
45 |
|
|
dnl Check whether the target supports symbol aliases.
|
46 |
|
|
AC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_ALIAS], [
|
47 |
|
|
AC_CACHE_CHECK([whether the target supports symbol aliases],
|
48 |
|
|
libgomp_cv_have_attribute_alias, [
|
49 |
|
|
AC_TRY_LINK([
|
50 |
|
|
void foo(void) { }
|
51 |
|
|
extern void bar(void) __attribute__((alias("foo")));],
|
52 |
|
|
[bar();], libgomp_cv_have_attribute_alias=yes, libgomp_cv_have_attribute_alias=no)])
|
53 |
|
|
if test $libgomp_cv_have_attribute_alias = yes; then
|
54 |
|
|
AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
|
55 |
|
|
[Define to 1 if the target supports __attribute__((alias(...))).])
|
56 |
|
|
fi])
|
57 |
|
|
|
58 |
|
|
sinclude(../libtool.m4)
|
59 |
|
|
dnl The lines below arrange for aclocal not to bring an installed
|
60 |
|
|
dnl libtool.m4 into aclocal.m4, while still arranging for automake to
|
61 |
|
|
dnl add a definition of LIBTOOL to Makefile.in.
|
62 |
|
|
ifelse(,,,[AC_SUBST(LIBTOOL)
|
63 |
|
|
AC_DEFUN([AM_PROG_LIBTOOL])
|
64 |
|
|
AC_DEFUN([AC_LIBTOOL_DLOPEN])
|
65 |
|
|
AC_DEFUN([AC_PROG_LD])
|
66 |
|
|
])
|
67 |
|
|
|
68 |
|
|
dnl ----------------------------------------------------------------------
|
69 |
|
|
dnl This whole bit snagged from libstdc++-v3.
|
70 |
|
|
|
71 |
|
|
dnl
|
72 |
|
|
dnl LIBGOMP_ENABLE
|
73 |
|
|
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
|
74 |
|
|
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
|
75 |
|
|
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
|
76 |
|
|
dnl
|
77 |
|
|
dnl See docs/html/17_intro/configury.html#enable for documentation.
|
78 |
|
|
dnl
|
79 |
|
|
m4_define([LIBGOMP_ENABLE],[dnl
|
80 |
|
|
m4_define([_g_switch],[--enable-$1])dnl
|
81 |
|
|
m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
|
82 |
|
|
AC_ARG_ENABLE($1,_g_help,
|
83 |
|
|
m4_bmatch([$5],
|
84 |
|
|
[^permit ],
|
85 |
|
|
[[
|
86 |
|
|
case "$enableval" in
|
87 |
|
|
m4_bpatsubst([$5],[permit ])) ;;
|
88 |
|
|
*) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
|
89 |
|
|
dnl Idea for future: generate a URL pointing to
|
90 |
|
|
dnl "onlinedocs/configopts.html#whatever"
|
91 |
|
|
esac
|
92 |
|
|
]],
|
93 |
|
|
[^$],
|
94 |
|
|
[[
|
95 |
|
|
case "$enableval" in
|
96 |
|
|
yes|no) ;;
|
97 |
|
|
*) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
|
98 |
|
|
esac
|
99 |
|
|
]],
|
100 |
|
|
[[$5]]),
|
101 |
|
|
[enable_]m4_bpatsubst([$1],-,_)[=][$2])
|
102 |
|
|
m4_undefine([_g_switch])dnl
|
103 |
|
|
m4_undefine([_g_help])dnl
|
104 |
|
|
])
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
dnl
|
108 |
|
|
dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
|
109 |
|
|
dnl the native linker is in use, all variables will be defined to something
|
110 |
|
|
dnl safe (like an empty string).
|
111 |
|
|
dnl
|
112 |
|
|
dnl Defines:
|
113 |
|
|
dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
|
114 |
|
|
dnl OPT_LDFLAGS='-Wl,-O1' if possible
|
115 |
|
|
dnl LD (as a side effect of testing)
|
116 |
|
|
dnl Sets:
|
117 |
|
|
dnl with_gnu_ld
|
118 |
|
|
dnl libgomp_ld_is_gold (possibly)
|
119 |
|
|
dnl libgomp_gnu_ld_version (possibly)
|
120 |
|
|
dnl
|
121 |
|
|
dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
|
122 |
|
|
dnl set libgomp_gnu_ld_version to 12345. Zeros cause problems.
|
123 |
|
|
dnl
|
124 |
|
|
AC_DEFUN([LIBGOMP_CHECK_LINKER_FEATURES], [
|
125 |
|
|
# If we're not using GNU ld, then there's no point in even trying these
|
126 |
|
|
# tests. Check for that first. We should have already tested for gld
|
127 |
|
|
# by now (in libtool), but require it now just to be safe...
|
128 |
|
|
test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
|
129 |
|
|
test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
|
130 |
|
|
AC_REQUIRE([AC_PROG_LD])
|
131 |
|
|
AC_REQUIRE([AC_PROG_AWK])
|
132 |
|
|
|
133 |
|
|
# The name set by libtool depends on the version of libtool. Shame on us
|
134 |
|
|
# for depending on an impl detail, but c'est la vie. Older versions used
|
135 |
|
|
# ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
|
136 |
|
|
# top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
|
137 |
|
|
# makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
|
138 |
|
|
# set (hence we're using an older libtool), then set it.
|
139 |
|
|
if test x${with_gnu_ld+set} != xset; then
|
140 |
|
|
if test x${ac_cv_prog_gnu_ld+set} != xset; then
|
141 |
|
|
# We got through "ac_require(ac_prog_ld)" and still not set? Huh?
|
142 |
|
|
with_gnu_ld=no
|
143 |
|
|
else
|
144 |
|
|
with_gnu_ld=$ac_cv_prog_gnu_ld
|
145 |
|
|
fi
|
146 |
|
|
fi
|
147 |
|
|
|
148 |
|
|
# Start by getting the version number. I think the libtool test already
|
149 |
|
|
# does some of this, but throws away the result.
|
150 |
|
|
libgomp_ld_is_gold=no
|
151 |
|
|
if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
|
152 |
|
|
libgomp_ld_is_gold=yes
|
153 |
|
|
fi
|
154 |
|
|
changequote(,)
|
155 |
|
|
ldver=`$LD --version 2>/dev/null |
|
156 |
|
|
sed -e 's/GNU gold /GNU ld /;s/GNU ld version /GNU ld /;s/GNU ld ([^)]*) /GNU ld /;s/GNU ld \([0-9.][0-9.]*\).*/\1/; q'`
|
157 |
|
|
changequote([,])
|
158 |
|
|
libgomp_gnu_ld_version=`echo $ldver | \
|
159 |
|
|
$AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
|
160 |
|
|
|
161 |
|
|
# Set --gc-sections.
|
162 |
|
|
if test "$with_gnu_ld" = "notbroken"; then
|
163 |
|
|
# GNU ld it is! Joy and bunny rabbits!
|
164 |
|
|
|
165 |
|
|
# All these tests are for C++; save the language and the compiler flags.
|
166 |
|
|
# Need to do this so that g++ won't try to link in libstdc++
|
167 |
|
|
ac_test_CFLAGS="${CFLAGS+set}"
|
168 |
|
|
ac_save_CFLAGS="$CFLAGS"
|
169 |
|
|
CFLAGS='-x c++ -Wl,--gc-sections'
|
170 |
|
|
|
171 |
|
|
# Check for -Wl,--gc-sections
|
172 |
|
|
# XXX This test is broken at the moment, as symbols required for linking
|
173 |
|
|
# are now in libsupc++ (not built yet). In addition, this test has
|
174 |
|
|
# cored on solaris in the past. In addition, --gc-sections doesn't
|
175 |
|
|
# really work at the moment (keeps on discarding used sections, first
|
176 |
|
|
# .eh_frame and now some of the glibc sections for iconv).
|
177 |
|
|
# Bzzzzt. Thanks for playing, maybe next time.
|
178 |
|
|
AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
|
179 |
|
|
AC_TRY_RUN([
|
180 |
|
|
int main(void)
|
181 |
|
|
{
|
182 |
|
|
try { throw 1; }
|
183 |
|
|
catch (...) { };
|
184 |
|
|
return 0;
|
185 |
|
|
}
|
186 |
|
|
], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
|
187 |
|
|
if test "$ac_test_CFLAGS" = set; then
|
188 |
|
|
CFLAGS="$ac_save_CFLAGS"
|
189 |
|
|
else
|
190 |
|
|
# this is the suspicious part
|
191 |
|
|
CFLAGS=''
|
192 |
|
|
fi
|
193 |
|
|
if test "$ac_sectionLDflags" = "yes"; then
|
194 |
|
|
SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
|
195 |
|
|
fi
|
196 |
|
|
AC_MSG_RESULT($ac_sectionLDflags)
|
197 |
|
|
fi
|
198 |
|
|
|
199 |
|
|
# Set linker optimization flags.
|
200 |
|
|
if test x"$with_gnu_ld" = x"yes"; then
|
201 |
|
|
OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
|
202 |
|
|
fi
|
203 |
|
|
|
204 |
|
|
AC_SUBST(SECTION_LDFLAGS)
|
205 |
|
|
AC_SUBST(OPT_LDFLAGS)
|
206 |
|
|
])
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
dnl
|
210 |
|
|
dnl Add version tags to symbols in shared library (or not), additionally
|
211 |
|
|
dnl marking other symbols as private/local (or not).
|
212 |
|
|
dnl
|
213 |
|
|
dnl --enable-symvers=style adds a version script to the linker call when
|
214 |
|
|
dnl creating the shared library. The choice of version script is
|
215 |
|
|
dnl controlled by 'style'.
|
216 |
|
|
dnl --disable-symvers does not.
|
217 |
|
|
dnl + Usage: LIBGOMP_ENABLE_SYMVERS[(DEFAULT)]
|
218 |
|
|
dnl Where DEFAULT is either 'yes' or 'no'. Passing `yes' tries to
|
219 |
|
|
dnl choose a default style based on linker characteristics. Passing
|
220 |
|
|
dnl 'no' disables versioning.
|
221 |
|
|
dnl
|
222 |
|
|
AC_DEFUN([LIBGOMP_ENABLE_SYMVERS], [
|
223 |
|
|
|
224 |
|
|
LIBGOMP_ENABLE(symvers,yes,[=STYLE],
|
225 |
|
|
[enables symbol versioning of the shared library],
|
226 |
|
|
[permit yes|no|gnu])
|
227 |
|
|
|
228 |
|
|
# If we never went through the LIBGOMP_CHECK_LINKER_FEATURES macro, then we
|
229 |
|
|
# don't know enough about $LD to do tricks...
|
230 |
|
|
AC_REQUIRE([LIBGOMP_CHECK_LINKER_FEATURES])
|
231 |
|
|
# FIXME The following test is too strict, in theory.
|
232 |
|
|
if test $enable_shared = no ||
|
233 |
|
|
test "x$LD" = x ||
|
234 |
|
|
test x$libgomp_gnu_ld_version = x; then
|
235 |
|
|
enable_symvers=no
|
236 |
|
|
fi
|
237 |
|
|
|
238 |
|
|
# Check to see if libgcc_s exists, indicating that shared libgcc is possible.
|
239 |
|
|
if test $enable_symvers != no; then
|
240 |
|
|
AC_MSG_CHECKING([for shared libgcc])
|
241 |
|
|
ac_save_CFLAGS="$CFLAGS"
|
242 |
|
|
CFLAGS=' -lgcc_s'
|
243 |
|
|
AC_TRY_LINK(, [return 0;], libgomp_shared_libgcc=yes, libgomp_shared_libgcc=no)
|
244 |
|
|
CFLAGS="$ac_save_CFLAGS"
|
245 |
|
|
if test $libgomp_shared_libgcc = no; then
|
246 |
|
|
cat > conftest.c <<EOF
|
247 |
|
|
int main (void) { return 0; }
|
248 |
|
|
EOF
|
249 |
|
|
changequote(,)dnl
|
250 |
|
|
libgomp_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
|
251 |
|
|
-shared -shared-libgcc -o conftest.so \
|
252 |
|
|
conftest.c -v 2>&1 >/dev/null \
|
253 |
|
|
| sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
|
254 |
|
|
changequote([,])dnl
|
255 |
|
|
rm -f conftest.c conftest.so
|
256 |
|
|
if test x${libgomp_libgcc_s_suffix+set} = xset; then
|
257 |
|
|
CFLAGS=" -lgcc_s$libgomp_libgcc_s_suffix"
|
258 |
|
|
AC_TRY_LINK(, [return 0;], libgomp_shared_libgcc=yes)
|
259 |
|
|
CFLAGS="$ac_save_CFLAGS"
|
260 |
|
|
fi
|
261 |
|
|
fi
|
262 |
|
|
AC_MSG_RESULT($libgomp_shared_libgcc)
|
263 |
|
|
fi
|
264 |
|
|
|
265 |
|
|
# For GNU ld, we need at least this version. The format is described in
|
266 |
|
|
# LIBGOMP_CHECK_LINKER_FEATURES above.
|
267 |
|
|
libgomp_min_gnu_ld_version=21400
|
268 |
|
|
# XXXXXXXXXXX libgomp_gnu_ld_version=21390
|
269 |
|
|
|
270 |
|
|
# Check to see if unspecified "yes" value can win, given results above.
|
271 |
|
|
# Change "yes" into either "no" or a style name.
|
272 |
|
|
if test $enable_symvers = yes; then
|
273 |
|
|
if test $with_gnu_ld = yes &&
|
274 |
|
|
test $libgomp_shared_libgcc = yes;
|
275 |
|
|
then
|
276 |
|
|
if test $libgomp_gnu_ld_version -ge $libgomp_min_gnu_ld_version ; then
|
277 |
|
|
enable_symvers=gnu
|
278 |
|
|
elif test $libgomp_ld_is_gold = yes ; then
|
279 |
|
|
enable_symvers=gnu
|
280 |
|
|
else
|
281 |
|
|
# The right tools, the right setup, but too old. Fallbacks?
|
282 |
|
|
AC_MSG_WARN(=== Linker version $libgomp_gnu_ld_version is too old for)
|
283 |
|
|
AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
|
284 |
|
|
AC_MSG_WARN(=== You would need to upgrade your binutils to version)
|
285 |
|
|
AC_MSG_WARN(=== $libgomp_min_gnu_ld_version or later and rebuild GCC.)
|
286 |
|
|
if test $libgomp_gnu_ld_version -ge 21200 ; then
|
287 |
|
|
# Globbing fix is present, proper block support is not.
|
288 |
|
|
dnl AC_MSG_WARN([=== Dude, you are soooo close. Maybe we can fake it.])
|
289 |
|
|
dnl enable_symvers=???
|
290 |
|
|
AC_MSG_WARN([=== Symbol versioning will be disabled.])
|
291 |
|
|
enable_symvers=no
|
292 |
|
|
else
|
293 |
|
|
# 2.11 or older.
|
294 |
|
|
AC_MSG_WARN([=== Symbol versioning will be disabled.])
|
295 |
|
|
enable_symvers=no
|
296 |
|
|
fi
|
297 |
|
|
fi
|
298 |
|
|
else
|
299 |
|
|
# just fail for now
|
300 |
|
|
AC_MSG_WARN([=== You have requested some kind of symbol versioning, but])
|
301 |
|
|
AC_MSG_WARN([=== either you are not using a supported linker, or you are])
|
302 |
|
|
AC_MSG_WARN([=== not building a shared libgcc_s (which is required).])
|
303 |
|
|
AC_MSG_WARN([=== Symbol versioning will be disabled.])
|
304 |
|
|
enable_symvers=no
|
305 |
|
|
fi
|
306 |
|
|
fi
|
307 |
|
|
|
308 |
|
|
AC_CACHE_CHECK([whether the target supports .symver directive],
|
309 |
|
|
libgomp_cv_have_as_symver_directive, [
|
310 |
|
|
AC_TRY_COMPILE([void foo (void); __asm (".symver foo, bar@SYMVER");],
|
311 |
|
|
[], libgomp_cv_have_as_symver_directive=yes,
|
312 |
|
|
libgomp_cv_have_as_symver_directive=no)])
|
313 |
|
|
if test $libgomp_cv_have_as_symver_directive = yes; then
|
314 |
|
|
AC_DEFINE(HAVE_AS_SYMVER_DIRECTIVE, 1,
|
315 |
|
|
[Define to 1 if the target assembler supports .symver directive.])
|
316 |
|
|
fi
|
317 |
|
|
|
318 |
|
|
AM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
|
319 |
|
|
AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
|
320 |
|
|
])
|