public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Fix libiberty link failure in LTO mode
@ 2021-05-03  7:10 Eric Botcazou
  2021-05-03  8:28 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Botcazou @ 2021-05-03  7:10 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 599 bytes --]

Hi,

the patch for libiberty itself I posted is not sufficient to link the library 
for MinGW platforms in LTO mode, as 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.

Tested on x86-64/Linux, x86-64/Windows and x86/Windows, OK for the mainline?


2021-05-03  Eric Botcazou  <ebotcazou@adacore.com>

	* builtins.c (builtin_with_linkage_p): Return true for stp[n]cpy.
	* symtab.c (symtab_node::output_to_lto_symbol_table_p): Tidy up.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1651 bytes --]

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 2d6bf4a65b4..b1d0f6a551f 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -14310,8 +14310,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)
@@ -14390,6 +14390,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;
     }
diff --git a/gcc/symtab.c b/gcc/symtab.c
index 2135b34ce27..8c4cb70b015 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] Fix libiberty link failure in LTO mode
  2021-05-03  7:10 [patch] Fix libiberty link failure in LTO mode Eric Botcazou
@ 2021-05-03  8:28 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2021-05-03  8:28 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: GCC Patches

On Mon, May 3, 2021 at 9:58 AM Eric Botcazou <botcazou@adacore.com> wrote:
>
> Hi,
>
> the patch for libiberty itself I posted is not sufficient to link the library
> for MinGW platforms in LTO mode, as 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.
>
> Tested on x86-64/Linux, x86-64/Windows and x86/Windows, OK for the mainline?

OK.

Richard.

>
> 2021-05-03  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * builtins.c (builtin_with_linkage_p): Return true for stp[n]cpy.
>         * symtab.c (symtab_node::output_to_lto_symbol_table_p): Tidy up.
>
> --
> Eric Botcazou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-03  8:28 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:10 [patch] Fix libiberty link failure in LTO mode Eric Botcazou
2021-05-03  8:28 ` 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).