diff mbox series

lto: Don't check obj.found for offload section

Message ID 20240823123645.1564801-1-hjl.tools@gmail.com
State New
Headers show
Series lto: Don't check obj.found for offload section | expand

Commit Message

H.J. Lu Aug. 23, 2024, 12:36 p.m. UTC
obj.found is the number of LTO symbols.  We should include the offload
section when it is used by linker even if there are no LTO symbols.

	PR lto/116361
	* lto-plugin.c (claim_file_handler_v2): Don't check obj.found
	for the offload section.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 lto-plugin/lto-plugin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Richard Biener Aug. 23, 2024, 12:50 p.m. UTC | #1
On Fri, Aug 23, 2024 at 2:36 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> obj.found is the number of LTO symbols.  We should include the offload
> section when it is used by linker even if there are no LTO symbols.

OK.

>         PR lto/116361
>         * lto-plugin.c (claim_file_handler_v2): Don't check obj.found
>         for the offload section.
>
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  lto-plugin/lto-plugin.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
> index 61b0de62f52..c564b36eb92 100644
> --- a/lto-plugin/lto-plugin.c
> +++ b/lto-plugin/lto-plugin.c
> @@ -1320,7 +1320,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file,
>    if (*can_be_claimed && !obj.offload && offload_files_last_lto == NULL)
>      offload_files_last_lto = offload_files_last;
>
> -  if (obj.offload && known_used && obj.found > 0)
> +  if (obj.offload && known_used)
>      {
>        /* Add file to the list.  The order must be exactly the same as the final
>          order after recompilation and linking, otherwise host and target tables
> --
> 2.46.0
>
Prathamesh Kulkarni Aug. 23, 2024, 2:07 p.m. UTC | #2
> -----Original Message-----
> From: H.J. Lu <hjl.tools@gmail.com>
> Sent: Friday, August 23, 2024 6:07 PM
> To: gcc-patches@gcc.gnu.org
> Cc: Prathamesh Kulkarni <prathameshk@nvidia.com>;
> richard.guenther@gmail.com
> Subject: [PATCH] lto: Don't check obj.found for offload section
> 
> External email: Use caution opening links or attachments
> 
> 
> obj.found is the number of LTO symbols.  We should include the offload
> section when it is used by linker even if there are no LTO symbols.
> 
>         PR lto/116361
>         * lto-plugin.c (claim_file_handler_v2): Don't check obj.found
>         for the offload section.
Hi,
I applied your patch locally, and can confirm this fixes the issue with offloading, thanks!

Thanks,
Prathamesh
> 
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  lto-plugin/lto-plugin.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c index
> 61b0de62f52..c564b36eb92 100644
> --- a/lto-plugin/lto-plugin.c
> +++ b/lto-plugin/lto-plugin.c
> @@ -1320,7 +1320,7 @@ claim_file_handler_v2 (const struct
> ld_plugin_input_file *file,
>    if (*can_be_claimed && !obj.offload && offload_files_last_lto ==
> NULL)
>      offload_files_last_lto = offload_files_last;
> 
> -  if (obj.offload && known_used && obj.found > 0)
> +  if (obj.offload && known_used)
>      {
>        /* Add file to the list.  The order must be exactly the same as
> the final
>          order after recompilation and linking, otherwise host and
> target tables
> --
> 2.46.0
H.J. Lu Sept. 3, 2024, 3:44 p.m. UTC | #3
On Fri, Aug 23, 2024 at 5:50 AM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Fri, Aug 23, 2024 at 2:36 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > obj.found is the number of LTO symbols.  We should include the offload
> > section when it is used by linker even if there are no LTO symbols.
>
> OK.
>
> >         PR lto/116361
> >         * lto-plugin.c (claim_file_handler_v2): Don't check obj.found
> >         for the offload section.
> >
> > Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> > ---
> >  lto-plugin/lto-plugin.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
> > index 61b0de62f52..c564b36eb92 100644
> > --- a/lto-plugin/lto-plugin.c
> > +++ b/lto-plugin/lto-plugin.c
> > @@ -1320,7 +1320,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file,
> >    if (*can_be_claimed && !obj.offload && offload_files_last_lto == NULL)
> >      offload_files_last_lto = offload_files_last;
> >
> > -  if (obj.offload && known_used && obj.found > 0)
> > +  if (obj.offload && known_used)
> >      {
> >        /* Add file to the list.  The order must be exactly the same as the final
> >          order after recompilation and linking, otherwise host and target tables
> > --
> > 2.46.0
> >

OK to backport

https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a98dd536b1017c2b814a3465206c6c01b2890998

and this patch to release branches?

Thanks.
Richard Biener Sept. 4, 2024, 6:51 a.m. UTC | #4
On Tue, Sep 3, 2024 at 5:44 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Aug 23, 2024 at 5:50 AM Richard Biener
> <richard.guenther@gmail.com> wrote:
> >
> > On Fri, Aug 23, 2024 at 2:36 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > obj.found is the number of LTO symbols.  We should include the offload
> > > section when it is used by linker even if there are no LTO symbols.
> >
> > OK.
> >
> > >         PR lto/116361
> > >         * lto-plugin.c (claim_file_handler_v2): Don't check obj.found
> > >         for the offload section.
> > >
> > > Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> > > ---
> > >  lto-plugin/lto-plugin.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
> > > index 61b0de62f52..c564b36eb92 100644
> > > --- a/lto-plugin/lto-plugin.c
> > > +++ b/lto-plugin/lto-plugin.c
> > > @@ -1320,7 +1320,7 @@ claim_file_handler_v2 (const struct ld_plugin_input_file *file,
> > >    if (*can_be_claimed && !obj.offload && offload_files_last_lto == NULL)
> > >      offload_files_last_lto = offload_files_last;
> > >
> > > -  if (obj.offload && known_used && obj.found > 0)
> > > +  if (obj.offload && known_used)
> > >      {
> > >        /* Add file to the list.  The order must be exactly the same as the final
> > >          order after recompilation and linking, otherwise host and target tables
> > > --
> > > 2.46.0
> > >
>
> OK to backport
>
> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a98dd536b1017c2b814a3465206c6c01b2890998
>
> and this patch to release branches?

OK for the GCC 14 branch - the one the bug was reported against.
Please wait with further
backporting.

Richard.

> Thanks.
>
> --
> H.J.
diff mbox series

Patch

diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index 61b0de62f52..c564b36eb92 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -1320,7 +1320,7 @@  claim_file_handler_v2 (const struct ld_plugin_input_file *file,
   if (*can_be_claimed && !obj.offload && offload_files_last_lto == NULL)
     offload_files_last_lto = offload_files_last;
 
-  if (obj.offload && known_used && obj.found > 0)
+  if (obj.offload && known_used)
     {
       /* Add file to the list.  The order must be exactly the same as the final
 	 order after recompilation and linking, otherwise host and target tables