Fix libiberty link failures in LTO mode for MinGW
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) 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. There is another link failures for stpcpy: the symbol is both referenced by libiberty's pex-win32.c and provided by libiberty's stpcpy.c, so it needs to have a linkage to be resolved in LTO mode. libiberty/ * configure.ac: Make test for variables more robust. * configure: Regenerate. gcc/ * builtins.c (builtin_with_linkage_p): Return true for stp[n]cpy. * symtab.c (symtab_node::output_to_lto_symbol_table_p): Tidy up.
This commit is contained in:
parent
1b0f570009
commit
f418bc3cd1
@ -14480,8 +14480,8 @@ target_char_cst_p (tree t, char *p)
|
||||
}
|
||||
|
||||
/* Return true if the builtin DECL is implemented in a standard library.
|
||||
Otherwise returns false which doesn't guarantee it is not (thus the list of
|
||||
handled builtins below may be incomplete). */
|
||||
Otherwise return false which doesn't guarantee it is not (thus the list
|
||||
of handled builtins below may be incomplete). */
|
||||
|
||||
bool
|
||||
builtin_with_linkage_p (tree decl)
|
||||
@ -14560,6 +14560,14 @@ builtin_with_linkage_p (tree decl)
|
||||
CASE_FLT_FN (BUILT_IN_TRUNC):
|
||||
CASE_FLT_FN_FLOATN_NX (BUILT_IN_TRUNC):
|
||||
return true;
|
||||
|
||||
case BUILT_IN_STPCPY:
|
||||
case BUILT_IN_STPNCPY:
|
||||
/* stpcpy is both referenced in libiberty's pex-win32.c and provided
|
||||
by libiberty's stpcpy.c for MinGW targets so we need to return true
|
||||
in order to be able to build libiberty in LTO mode for them. */
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -2526,10 +2526,7 @@ symtab_node::output_to_lto_symbol_table_p (void)
|
||||
in libraries so make sure to output references into the symbol table to
|
||||
make those libraries referenced. Note this is incomplete handling for
|
||||
now and only covers math functions. */
|
||||
if (builtin_with_linkage_p (decl))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return builtin_with_linkage_p (decl);
|
||||
}
|
||||
|
||||
/* We have real symbol that should be in symbol table. However try to trim
|
||||
|
4
libiberty/configure
vendored
4
libiberty/configure
vendored
@ -7049,11 +7049,11 @@ else
|
||||
fi
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
int *p;
|
||||
extern int $v [];
|
||||
int
|
||||
main ()
|
||||
{
|
||||
extern int $v []; p = $v;
|
||||
if ($v [0]) return 1;
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user