* [libiberty] Make test for variables more robust
@ 2021-05-03 7:01 Eric Botcazou
2021-05-03 8:24 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Eric Botcazou @ 2021-05-03 7:01 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 994 bytes --]
Hi,
the test for the presence of variables (really symbols) does not work when you
add -Ox -flto to CFLAGS:
for v in $vars; do
AC_MSG_CHECKING([for $v])
AC_CACHE_VAL(libiberty_cv_var_$v,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[int *p;]],[[extern int $v []; p =
$v;]])],
[eval "libiberty_cv_var_$v=yes"],
[eval "libiberty_cv_var_$v=no"])])
if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
AC_MSG_RESULT(yes)
n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz'
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
AC_DEFINE_UNQUOTED($n)
else
AC_MSG_RESULT(no)
fi
done
because the assignment to 'p' is optimized away by LTO. This is visible on
MinGW platforms in the form of a link failure for sys_siglist.
Tested on x86-64/Linux, x86-64/Windows and x86/Windows, OK for the mainline?
2021-05-03 Eric Botcazou <ebotcazou@adacore.com>
* configure.ac: Make test for variables more robust.
* configure: Regenerate.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 628 bytes --]
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index ad952963971..3c03f24d368 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -665,7 +665,7 @@ if test -z "${setobjs}"; then
for v in $vars; do
AC_MSG_CHECKING([for $v])
AC_CACHE_VAL(libiberty_cv_var_$v,
- [AC_LINK_IFELSE([AC_LANG_PROGRAM([[int *p;]],[[extern int $v []; p = $v;]])],
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int $v [];]],[[if ($v [0]) return 1;]])],
[eval "libiberty_cv_var_$v=yes"],
[eval "libiberty_cv_var_$v=no"])])
if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [libiberty] Make test for variables more robust
2021-05-03 7:01 [libiberty] Make test for variables more robust Eric Botcazou
@ 2021-05-03 8:24 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2021-05-03 8:24 UTC (permalink / raw)
To: Eric Botcazou; +Cc: GCC Patches
On Mon, May 3, 2021 at 9:51 AM Eric Botcazou <botcazou@adacore.com> wrote:
>
> Hi,
>
> the test for the presence of variables (really symbols) does not work when you
> add -Ox -flto to CFLAGS:
>
> for v in $vars; do
> AC_MSG_CHECKING([for $v])
> AC_CACHE_VAL(libiberty_cv_var_$v,
> [AC_LINK_IFELSE([AC_LANG_PROGRAM([[int *p;]],[[extern int $v []; p =
> $v;]])],
> [eval "libiberty_cv_var_$v=yes"],
> [eval "libiberty_cv_var_$v=no"])])
> if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
> AC_MSG_RESULT(yes)
> n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz'
> 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
> AC_DEFINE_UNQUOTED($n)
> else
> AC_MSG_RESULT(no)
> fi
> done
>
> because the assignment to 'p' is optimized away by LTO. This is visible on
> MinGW platforms in the form of a link failure for sys_siglist.
>
> Tested on x86-64/Linux, x86-64/Windows and x86/Windows, OK for the mainline?
OK.
>
> 2021-05-03 Eric Botcazou <ebotcazou@adacore.com>
>
> * configure.ac: Make test for variables more robust.
> * configure: Regenerate.
>
> --
> Eric Botcazou
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-03 8:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-03 7:01 [libiberty] Make test for variables more robust Eric Botcazou
2021-05-03 8:24 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).