public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] lto, Darwin: Fix offload section names.
@ 2024-01-16 15:00 Iain Sandoe
  2024-01-17  6:52 ` Richard Biener
  2024-02-29 14:37 ` Thomas Schwinge
  0 siblings, 2 replies; 5+ messages in thread
From: Iain Sandoe @ 2024-01-16 15:00 UTC (permalink / raw)
  To: hubicka, gcc-patches

Tested on x86_64 Darwin, x86_64 Linux.
OK for trunk?  When?
thanks
Iain

--- 8< ---

Currently, these section names have wrong syntax for Mach-O.
Although they were added some time ago; recently added tests are
now emitting them leading to new fails on Darwin.

This adds a Mach-O variant for each.

gcc/ChangeLog:

	* lto-section-names.h (OFFLOAD_SECTION_NAME_PREFIX,
	OFFLOAD_VAR_TABLE_SECTION_NAME, OFFLOAD_FUNC_TABLE_SECTION_NAME,
	OFFLOAD_IND_FUNC_TABLE_SECTION_NAME): Provide Mach-O syntax
	versions when the object format is Mach-O.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
---
 gcc/lto-section-names.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/lto-section-names.h b/gcc/lto-section-names.h
index a743deb4efb..1cdadf36ec0 100644
--- a/gcc/lto-section-names.h
+++ b/gcc/lto-section-names.h
@@ -25,7 +25,11 @@ along with GCC; see the file COPYING3.  If not see
    name for the functions and static_initializers.  For other types of
    sections a '.' and the section type are appended.  */
 #define LTO_SECTION_NAME_PREFIX ".gnu.lto_"
+#if OBJECT_FORMAT_MACHO
+#define OFFLOAD_SECTION_NAME_PREFIX "__GNU_OFFLD_LTO,"
+#else
 #define OFFLOAD_SECTION_NAME_PREFIX ".gnu.offload_lto_"
+#endif
 
 /* Can be either OFFLOAD_SECTION_NAME_PREFIX when we stream IR for offload
    compiler, or LTO_SECTION_NAME_PREFIX for LTO case.  */
@@ -35,8 +39,14 @@ extern const char *section_name_prefix;
 
 #define LTO_SEGMENT_NAME "__GNU_LTO"
 
+#if OBJECT_FORMAT_MACHO
+#define OFFLOAD_VAR_TABLE_SECTION_NAME "__GNU_OFFLOAD,__vars"
+#define OFFLOAD_FUNC_TABLE_SECTION_NAME "__GNU_OFFLOAD,__funcs"
+#define OFFLOAD_IND_FUNC_TABLE_SECTION_NAME "__GNU_OFFLOAD,__ind_fns"
+#else
 #define OFFLOAD_VAR_TABLE_SECTION_NAME ".gnu.offload_vars"
 #define OFFLOAD_FUNC_TABLE_SECTION_NAME ".gnu.offload_funcs"
 #define OFFLOAD_IND_FUNC_TABLE_SECTION_NAME ".gnu.offload_ind_funcs"
+#endif
 
 #endif /* GCC_LTO_SECTION_NAMES_H */
-- 
2.39.2 (Apple Git-143)


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

* Re: [PATCH] lto, Darwin: Fix offload section names.
  2024-01-16 15:00 [PATCH] lto, Darwin: Fix offload section names Iain Sandoe
@ 2024-01-17  6:52 ` Richard Biener
  2024-02-29 14:37 ` Thomas Schwinge
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Biener @ 2024-01-17  6:52 UTC (permalink / raw)
  To: iain; +Cc: hubicka, gcc-patches

On Tue, Jan 16, 2024 at 4:00 PM Iain Sandoe <iains.gcc@gmail.com> wrote:
>
> Tested on x86_64 Darwin, x86_64 Linux.
> OK for trunk?  When?

OK now.

> thanks
> Iain
>
> --- 8< ---
>
> Currently, these section names have wrong syntax for Mach-O.
> Although they were added some time ago; recently added tests are
> now emitting them leading to new fails on Darwin.
>
> This adds a Mach-O variant for each.
>
> gcc/ChangeLog:
>
>         * lto-section-names.h (OFFLOAD_SECTION_NAME_PREFIX,
>         OFFLOAD_VAR_TABLE_SECTION_NAME, OFFLOAD_FUNC_TABLE_SECTION_NAME,
>         OFFLOAD_IND_FUNC_TABLE_SECTION_NAME): Provide Mach-O syntax
>         versions when the object format is Mach-O.
>
> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
> ---
>  gcc/lto-section-names.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/gcc/lto-section-names.h b/gcc/lto-section-names.h
> index a743deb4efb..1cdadf36ec0 100644
> --- a/gcc/lto-section-names.h
> +++ b/gcc/lto-section-names.h
> @@ -25,7 +25,11 @@ along with GCC; see the file COPYING3.  If not see
>     name for the functions and static_initializers.  For other types of
>     sections a '.' and the section type are appended.  */
>  #define LTO_SECTION_NAME_PREFIX ".gnu.lto_"
> +#if OBJECT_FORMAT_MACHO
> +#define OFFLOAD_SECTION_NAME_PREFIX "__GNU_OFFLD_LTO,"
> +#else
>  #define OFFLOAD_SECTION_NAME_PREFIX ".gnu.offload_lto_"
> +#endif
>
>  /* Can be either OFFLOAD_SECTION_NAME_PREFIX when we stream IR for offload
>     compiler, or LTO_SECTION_NAME_PREFIX for LTO case.  */
> @@ -35,8 +39,14 @@ extern const char *section_name_prefix;
>
>  #define LTO_SEGMENT_NAME "__GNU_LTO"
>
> +#if OBJECT_FORMAT_MACHO
> +#define OFFLOAD_VAR_TABLE_SECTION_NAME "__GNU_OFFLOAD,__vars"
> +#define OFFLOAD_FUNC_TABLE_SECTION_NAME "__GNU_OFFLOAD,__funcs"
> +#define OFFLOAD_IND_FUNC_TABLE_SECTION_NAME "__GNU_OFFLOAD,__ind_fns"
> +#else
>  #define OFFLOAD_VAR_TABLE_SECTION_NAME ".gnu.offload_vars"
>  #define OFFLOAD_FUNC_TABLE_SECTION_NAME ".gnu.offload_funcs"
>  #define OFFLOAD_IND_FUNC_TABLE_SECTION_NAME ".gnu.offload_ind_funcs"
> +#endif
>
>  #endif /* GCC_LTO_SECTION_NAMES_H */
> --
> 2.39.2 (Apple Git-143)
>

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

* Re: [PATCH] lto, Darwin: Fix offload section names.
  2024-01-16 15:00 [PATCH] lto, Darwin: Fix offload section names Iain Sandoe
  2024-01-17  6:52 ` Richard Biener
@ 2024-02-29 14:37 ` Thomas Schwinge
  2024-02-29 15:55   ` Iain Sandoe
  2024-02-29 16:52   ` Tobias Burnus
  1 sibling, 2 replies; 5+ messages in thread
From: Thomas Schwinge @ 2024-02-29 14:37 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: hubicka, gcc-patches

Hi Iain!

On 2024-01-16T15:00:16+0000, Iain Sandoe <iains.gcc@gmail.com> wrote:
> Currently, these section names have wrong syntax for Mach-O.
> Although they were added some time ago; recently added tests are
> now emitting them leading to new fails on Darwin.
>
> This adds a Mach-O variant for each.

>  gcc/lto-section-names.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/gcc/lto-section-names.h b/gcc/lto-section-names.h
> index a743deb4efb..1cdadf36ec0 100644
> --- a/gcc/lto-section-names.h
> +++ b/gcc/lto-section-names.h
> @@ -25,7 +25,11 @@ along with GCC; see the file COPYING3.  If not see
>     name for the functions and static_initializers.  For other types of
>     sections a '.' and the section type are appended.  */
>  #define LTO_SECTION_NAME_PREFIX ".gnu.lto_"
> +#if OBJECT_FORMAT_MACHO
> +#define OFFLOAD_SECTION_NAME_PREFIX "__GNU_OFFLD_LTO,"
> +#else
>  #define OFFLOAD_SECTION_NAME_PREFIX ".gnu.offload_lto_"
> +#endif
>  
>  /* Can be either OFFLOAD_SECTION_NAME_PREFIX when we stream IR for offload
>     compiler, or LTO_SECTION_NAME_PREFIX for LTO case.  */
> @@ -35,8 +39,14 @@ extern const char *section_name_prefix;
>  
>  #define LTO_SEGMENT_NAME "__GNU_LTO"
>  
> +#if OBJECT_FORMAT_MACHO
> +#define OFFLOAD_VAR_TABLE_SECTION_NAME "__GNU_OFFLOAD,__vars"
> +#define OFFLOAD_FUNC_TABLE_SECTION_NAME "__GNU_OFFLOAD,__funcs"
> +#define OFFLOAD_IND_FUNC_TABLE_SECTION_NAME "__GNU_OFFLOAD,__ind_fns"
> +#else
>  #define OFFLOAD_VAR_TABLE_SECTION_NAME ".gnu.offload_vars"
>  #define OFFLOAD_FUNC_TABLE_SECTION_NAME ".gnu.offload_funcs"
>  #define OFFLOAD_IND_FUNC_TABLE_SECTION_NAME ".gnu.offload_ind_funcs"
> +#endif
>  
>  #endif /* GCC_LTO_SECTION_NAMES_H */

Just to note that, per my understanding, this will require corresponding
changes elsewhere, once you attempt to actually enable offloading
compilation for Darwin (which -- ;-) I suspect -- is not on your agenda
right now):

    $ git grep --cached -F .gnu.offload_
    gcc/config/gcn/mkoffload.cc:      if (sscanf (buf, " .section .gnu.offload_vars%c", &dummy) > 0)
    gcc/config/gcn/mkoffload.cc:      else if (sscanf (buf, " .section .gnu.offload_funcs%c", &dummy) > 0)
    gcc/config/gcn/mkoffload.cc:      /* Likewise for .gnu.offload_vars; used for reverse offload. */
    gcc/config/gcn/mkoffload.cc:      else if (sscanf (buf, " .section .gnu.offload_ind_funcs%c", &dummy) > 0)
    ['gcc/lto-section-names.h' adjusted per above.]
    libgcc/offloadstuff.c:#define OFFLOAD_FUNC_TABLE_SECTION_NAME ".gnu.offload_funcs"
    libgcc/offloadstuff.c:#define OFFLOAD_IND_FUNC_TABLE_SECTION_NAME ".gnu.offload_ind_funcs"
    libgcc/offloadstuff.c:#define OFFLOAD_VAR_TABLE_SECTION_NAME ".gnu.offload_vars"
    lto-plugin/lto-plugin.c:  if (startswith (name, ".gnu.offload_lto_.opts"))


Grüße
 Thomas

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

* Re: [PATCH] lto, Darwin: Fix offload section names.
  2024-02-29 14:37 ` Thomas Schwinge
@ 2024-02-29 15:55   ` Iain Sandoe
  2024-02-29 16:52   ` Tobias Burnus
  1 sibling, 0 replies; 5+ messages in thread
From: Iain Sandoe @ 2024-02-29 15:55 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: hubicka, GCC Patches

Hi Thomas,

> On 29 Feb 2024, at 14:37, Thomas Schwinge <tschwinge@baylibre.com> wrote:

> On 2024-01-16T15:00:16+0000, Iain Sandoe <iains.gcc@gmail.com> wrote:
>> Currently, these section names have wrong syntax for Mach-O.
>> Although they were added some time ago; recently added tests are
>> now emitting them leading to new fails on Darwin.
>> 
>> This adds a Mach-O variant for each.
> 
>> gcc/lto-section-names.h | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>> 
>> diff --git a/gcc/lto-section-names.h b/gcc/lto-section-names.h
>> index a743deb4efb..1cdadf36ec0 100644
>> --- a/gcc/lto-section-names.h
>> +++ b/gcc/lto-section-names.h
>> @@ -25,7 +25,11 @@ along with GCC; see the file COPYING3.  If not see
>>    name for the functions and static_initializers.  For other types of
>>    sections a '.' and the section type are appended.  */
>> #define LTO_SECTION_NAME_PREFIX ".gnu.lto_"
>> +#if OBJECT_FORMAT_MACHO
>> +#define OFFLOAD_SECTION_NAME_PREFIX "__GNU_OFFLD_LTO,"
>> +#else
>> #define OFFLOAD_SECTION_NAME_PREFIX ".gnu.offload_lto_"
>> +#endif
>> 
>> /* Can be either OFFLOAD_SECTION_NAME_PREFIX when we stream IR for offload
>>    compiler, or LTO_SECTION_NAME_PREFIX for LTO case.  */
>> @@ -35,8 +39,14 @@ extern const char *section_name_prefix;
>> 
>> #define LTO_SEGMENT_NAME "__GNU_LTO"
>> 
>> +#if OBJECT_FORMAT_MACHO
>> +#define OFFLOAD_VAR_TABLE_SECTION_NAME "__GNU_OFFLOAD,__vars"
>> +#define OFFLOAD_FUNC_TABLE_SECTION_NAME "__GNU_OFFLOAD,__funcs"
>> +#define OFFLOAD_IND_FUNC_TABLE_SECTION_NAME "__GNU_OFFLOAD,__ind_fns"
>> +#else
>> #define OFFLOAD_VAR_TABLE_SECTION_NAME ".gnu.offload_vars"
>> #define OFFLOAD_FUNC_TABLE_SECTION_NAME ".gnu.offload_funcs"
>> #define OFFLOAD_IND_FUNC_TABLE_SECTION_NAME ".gnu.offload_ind_funcs"
>> +#endif
>> 
>> #endif /* GCC_LTO_SECTION_NAMES_H */
> 
> Just to note that, per my understanding, this will require corresponding
> changes elsewhere, once you attempt to actually enable offloading
> compilation for Darwin (which -- ;-) I suspect -- is not on your agenda
> right now):

It is disappointing, but adding offloading to Darwin seems to be out of reach at the moment.

AFAIK, we have no support for NVidia after macOS 10.13 and the AMD units fitted to new(ish)
boxes are high-end graphics cards (when last I discussed with Andrew, we could not conclude
whether they would be handled usefully).

Adding arbitrary extension cards is (technically) feasible to some of the 2019-era server-style
machines - but that would still need approved and signed kernel drivers.  I have not looked into
whether the “studio” Arm64 machine might support such additions (the constraints on kernel-
side addtions would surely be even more strict on the newer OS versions).

So, indeed (for now at least) sadly, this is not even on the distant horizon :-(

Iain

> 
>    $ git grep --cached -F .gnu.offload_
>    gcc/config/gcn/mkoffload.cc:      if (sscanf (buf, " .section .gnu.offload_vars%c", &dummy) > 0)
>    gcc/config/gcn/mkoffload.cc:      else if (sscanf (buf, " .section .gnu.offload_funcs%c", &dummy) > 0)
>    gcc/config/gcn/mkoffload.cc:      /* Likewise for .gnu.offload_vars; used for reverse offload. */
>    gcc/config/gcn/mkoffload.cc:      else if (sscanf (buf, " .section .gnu.offload_ind_funcs%c", &dummy) > 0)
>    ['gcc/lto-section-names.h' adjusted per above.]
>    libgcc/offloadstuff.c:#define OFFLOAD_FUNC_TABLE_SECTION_NAME ".gnu.offload_funcs"
>    libgcc/offloadstuff.c:#define OFFLOAD_IND_FUNC_TABLE_SECTION_NAME ".gnu.offload_ind_funcs"
>    libgcc/offloadstuff.c:#define OFFLOAD_VAR_TABLE_SECTION_NAME ".gnu.offload_vars"
>    lto-plugin/lto-plugin.c:  if (startswith (name, ".gnu.offload_lto_.opts"))
> 
> 
> Grüße
> Thomas


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

* Re: [PATCH] lto, Darwin: Fix offload section names.
  2024-02-29 14:37 ` Thomas Schwinge
  2024-02-29 15:55   ` Iain Sandoe
@ 2024-02-29 16:52   ` Tobias Burnus
  1 sibling, 0 replies; 5+ messages in thread
From: Tobias Burnus @ 2024-02-29 16:52 UTC (permalink / raw)
  To: Thomas Schwinge, Iain Sandoe; +Cc: hubicka, gcc-patches

Hi Iain, hello world,

Thomas Schwinge wrote:
> On 2024-01-16T15:00:16+0000, Iain Sandoe <iains.gcc@gmail.com> wrote:
...
>> diff --git a/gcc/lto-section-names.h b/gcc/lto-section-names.h
>> index a743deb4efb..1cdadf36ec0 100644
>> --- a/gcc/lto-section-names.h
>> +++ b/gcc/lto-section-names.h
...
>> @@ -35,8 +39,14 @@ extern const char *section_name_prefix;
>>   
>>   #define LTO_SEGMENT_NAME "__GNU_LTO"
>>   
>> +#if OBJECT_FORMAT_MACHO
>> +#define OFFLOAD_VAR_TABLE_SECTION_NAME "__GNU_OFFLOAD,__vars"
>> +#define OFFLOAD_FUNC_TABLE_SECTION_NAME "__GNU_OFFLOAD,__funcs"
>> +#define OFFLOAD_IND_FUNC_TABLE_SECTION_NAME "__GNU_OFFLOAD,__ind_fns"
>> +#else
>>   #define OFFLOAD_VAR_TABLE_SECTION_NAME ".gnu.offload_vars"
...
> Just to note that, per my understanding, this will require corresponding
> changes elsewhere, once you attempt to actually enable offloading
> compilation for Darwin (which -- ;-) I suspect -- is not on your agenda
> right now):

For instance also in MOLD:

https://github.com/rui314/mold/blob/50bdf39ba57e29386de28bd0c303035e626fa29c/elf/input-files.cc#L244

     if ((shdr.sh_flags & SHF_EXCLUDE) &&
         name.starts_with(".gnu.offload_lto_.symtab.")) {
       this->is_gcc_offload_obj = true;
       continue;
     }

Tobias

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

end of thread, other threads:[~2024-02-29 16:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 15:00 [PATCH] lto, Darwin: Fix offload section names Iain Sandoe
2024-01-17  6:52 ` Richard Biener
2024-02-29 14:37 ` Thomas Schwinge
2024-02-29 15:55   ` Iain Sandoe
2024-02-29 16:52   ` Tobias Burnus

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).