public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] jit: Ensure ssize_t is defined.
@ 2024-01-28 11:44 Iain Sandoe
  2024-01-28 21:25 ` Eric Gallager
  0 siblings, 1 reply; 5+ messages in thread
From: Iain Sandoe @ 2024-01-28 11:44 UTC (permalink / raw)
  To: gcc-patches; +Cc: dmalcolm

Tested on i686, x86_64 Darwin, x86_64 Linux,
OK for trunk?

--- 8< ---

On some targets it seems that ssize_t is not defined by any of the
headers transitively included by <stdio.h>.  This leads to a bootstrap
fail when jit is enabled.

The fix proposed here is to include sys/types.h when it is available
since that is where Posix specifies that ssize_t is defined.

gcc/jit/ChangeLog:

	* libgccjit.h: Conditionally include <sys/types.h> where it is
	available to ensure declaration of ssize_t.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
---
 gcc/jit/libgccjit.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
index 235cab053e0..db4f27a48bf 100644
--- a/gcc/jit/libgccjit.h
+++ b/gcc/jit/libgccjit.h
@@ -21,6 +21,9 @@ along with GCC; see the file COPYING3.  If not see
 #define LIBGCCJIT_H
 
 #include <stdio.h>
+#if __has_include(<sys/types.h>)
+# include <sys/types.h>  /* For ssize_t.  */
+#endif
 
 #ifdef __cplusplus
 extern "C" {
-- 
2.39.2 (Apple Git-143)


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

* Re: [PATCH] jit: Ensure ssize_t is defined.
  2024-01-28 11:44 [PATCH] jit: Ensure ssize_t is defined Iain Sandoe
@ 2024-01-28 21:25 ` Eric Gallager
  2024-01-28 23:13   ` Iain Sandoe
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Gallager @ 2024-01-28 21:25 UTC (permalink / raw)
  To: iain; +Cc: gcc-patches, dmalcolm

On Sun, Jan 28, 2024 at 6:45 AM Iain Sandoe <iains.gcc@gmail.com> wrote:
>
> Tested on i686, x86_64 Darwin, x86_64 Linux,
> OK for trunk?
>
> --- 8< ---
>
> On some targets it seems that ssize_t is not defined by any of the
> headers transitively included by <stdio.h>.  This leads to a bootstrap
> fail when jit is enabled.
>
> The fix proposed here is to include sys/types.h when it is available
> since that is where Posix specifies that ssize_t is defined.
>
> gcc/jit/ChangeLog:
>
>         * libgccjit.h: Conditionally include <sys/types.h> where it is
>         available to ensure declaration of ssize_t.
>
> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
> ---
>  gcc/jit/libgccjit.h | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
> index 235cab053e0..db4f27a48bf 100644
> --- a/gcc/jit/libgccjit.h
> +++ b/gcc/jit/libgccjit.h
> @@ -21,6 +21,9 @@ along with GCC; see the file COPYING3.  If not see
>  #define LIBGCCJIT_H
>
>  #include <stdio.h>
> +#if __has_include(<sys/types.h>)

Is __has_include() something that we can use unconditionally?

> +# include <sys/types.h>  /* For ssize_t.  */
> +#endif
>
>  #ifdef __cplusplus
>  extern "C" {
> --
> 2.39.2 (Apple Git-143)
>

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

* Re: [PATCH] jit: Ensure ssize_t is defined.
  2024-01-28 21:25 ` Eric Gallager
@ 2024-01-28 23:13   ` Iain Sandoe
  2024-01-29 11:26     ` Iain Sandoe
  0 siblings, 1 reply; 5+ messages in thread
From: Iain Sandoe @ 2024-01-28 23:13 UTC (permalink / raw)
  To: Eric Gallager, GCC Patches; +Cc: dmalcolm



> On 28 Jan 2024, at 21:25, Eric Gallager <egall@gwmail.gwu.edu> wrote:
> 
> On Sun, Jan 28, 2024 at 6:45 AM Iain Sandoe <iains.gcc@gmail.com> wrote:
>> 
>> Tested on i686, x86_64 Darwin, x86_64 Linux,
>> OK for trunk?
>> 
>> --- 8< ---
>> 
>> On some targets it seems that ssize_t is not defined by any of the
>> headers transitively included by <stdio.h>.  This leads to a bootstrap
>> fail when jit is enabled.
>> 
>> The fix proposed here is to include sys/types.h when it is available
>> since that is where Posix specifies that ssize_t is defined.
>> 
>> gcc/jit/ChangeLog:
>> 
>>        * libgccjit.h: Conditionally include <sys/types.h> where it is
>>        available to ensure declaration of ssize_t.
>> 
>> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
>> ---
>> gcc/jit/libgccjit.h | 3 +++
>> 1 file changed, 3 insertions(+)
>> 
>> diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
>> index 235cab053e0..db4f27a48bf 100644
>> --- a/gcc/jit/libgccjit.h
>> +++ b/gcc/jit/libgccjit.h
>> @@ -21,6 +21,9 @@ along with GCC; see the file COPYING3.  If not see
>> #define LIBGCCJIT_H
>> 
>> #include <stdio.h>
>> +#if __has_include(<sys/types.h>)
> 
> Is __has_include() something that we can use unconditionally?

Hmm.. maybe we cannot, it seems it was introduced in gcc-4.9 and we only ask
for 4.8, IIRC.

I guess HAVE_SYS_TYPES_H might be an alternative (I’ll have to retest)

Iain

> 
>> +# include <sys/types.h>  /* For ssize_t.  */
>> +#endif
>> 
>> #ifdef __cplusplus
>> extern "C" {
>> --
>> 2.39.2 (Apple Git-143)


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

* Re: [PATCH] jit: Ensure ssize_t is defined.
  2024-01-28 23:13   ` Iain Sandoe
@ 2024-01-29 11:26     ` Iain Sandoe
  2024-04-02 11:45       ` Ping: " Iain Sandoe
  0 siblings, 1 reply; 5+ messages in thread
From: Iain Sandoe @ 2024-01-29 11:26 UTC (permalink / raw)
  To: dmalcolm; +Cc: Eric Gallager, GCC Patches

Hi David,

I guess the solution here depends on the scope over which we expect
the header to be used.

> On 28 Jan 2024, at 23:13, Iain Sandoe <iain@sandoe.co.uk> wrote:
>> On 28 Jan 2024, at 21:25, Eric Gallager <egall@gwmail.gwu.edu> wrote:
>> On Sun, Jan 28, 2024 at 6:45 AM Iain Sandoe <iains.gcc@gmail.com> wrote:
>>> 
>>> Tested on i686, x86_64 Darwin, x86_64 Linux,
>>> OK for trunk?
>>> 
>>> --- 8< ---
>>> 
>>> On some targets it seems that ssize_t is not defined by any of the
>>> headers transitively included by <stdio.h>.  This leads to a bootstrap
>>> fail when jit is enabled.
>>> 
>>> The fix proposed here is to include sys/types.h when it is available
>>> since that is where Posix specifies that ssize_t is defined.
>>> 
>>> gcc/jit/ChangeLog:
>>> 
>>>       * libgccjit.h: Conditionally include <sys/types.h> where it is
>>>       available to ensure declaration of ssize_t.
>>> 
>>> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
>>> ---
>>> gcc/jit/libgccjit.h | 3 +++
>>> 1 file changed, 3 insertions(+)
>>> 
>>> diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
>>> index 235cab053e0..db4f27a48bf 100644
>>> --- a/gcc/jit/libgccjit.h
>>> +++ b/gcc/jit/libgccjit.h
>>> @@ -21,6 +21,9 @@ along with GCC; see the file COPYING3.  If not see
>>> #define LIBGCCJIT_H
>>> 
>>> #include <stdio.h>
>>> +#if __has_include(<sys/types.h>)
>> 
>> Is __has_include() something that we can use unconditionally?
> 
> Hmm.. maybe we cannot, it seems it was introduced in gcc-4.9 and we only ask
> for 4.8, IIRC.
> 
> I guess HAVE_SYS_TYPES_H might be an alternative (I’ll have to retest)

Answering my own question; no that is not going to work  either since the header is
installed and config.h is not.

I guess the question is “is this header ever [meaningfully] consumed by a compiler
other than the current GCC that it supports”?

e.g. if we expected we could build libgccjit with clang in a “—disable-bootstrap”
configuration and expect that to work?

The fallback is
#ifdef __APPLE__
# include <sys/types.h>  /* For ssize_t.  */
#endif

(which I will test on a number of platform versions).

since this breaks bootstrap at stage 2 on affected platform versions, so we need some
fix.

thanks
Iain



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

* Ping: [PATCH] jit: Ensure ssize_t is defined.
  2024-01-29 11:26     ` Iain Sandoe
@ 2024-04-02 11:45       ` Iain Sandoe
  0 siblings, 0 replies; 5+ messages in thread
From: Iain Sandoe @ 2024-04-02 11:45 UTC (permalink / raw)
  To: David Malcolm; +Cc: Eric Gallager, GCC Patches

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



> On 29 Jan 2024, at 11:26, Iain Sandoe <iain@sandoe.co.uk> wrote:

> I guess the solution here depends on the scope over which we expect
> the header to be used.
> 
>> On 28 Jan 2024, at 23:13, Iain Sandoe <iain@sandoe.co.uk> wrote:
>>> On 28 Jan 2024, at 21:25, Eric Gallager <egall@gwmail.gwu.edu> wrote:
>>> On Sun, Jan 28, 2024 at 6:45 AM Iain Sandoe <iains.gcc@gmail.com> wrote:
>>>> 
>>>> Tested on i686, x86_64 Darwin, x86_64 Linux,
>>>> OK for trunk?
>>>> 
>>>> --- 8< ---
>>>> 
>>>> On some targets it seems that ssize_t is not defined by any of the
>>>> headers transitively included by <stdio.h>.  This leads to a bootstrap
>>>> fail when jit is enabled.
>>>> 
>>>> The fix proposed here is to include sys/types.h when it is available
>>>> since that is where Posix specifies that ssize_t is defined.
>>>> 
>>>> gcc/jit/ChangeLog:
>>>> 
>>>>      * libgccjit.h: Conditionally include <sys/types.h> where it is
>>>>      available to ensure declaration of ssize_t.
>>>> 
>>>> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
>>>> ---
>>>> gcc/jit/libgccjit.h | 3 +++
>>>> 1 file changed, 3 insertions(+)
>>>> 
>>>> diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
>>>> index 235cab053e0..db4f27a48bf 100644
>>>> --- a/gcc/jit/libgccjit.h
>>>> +++ b/gcc/jit/libgccjit.h
>>>> @@ -21,6 +21,9 @@ along with GCC; see the file COPYING3.  If not see
>>>> #define LIBGCCJIT_H
>>>> 
>>>> #include <stdio.h>
>>>> +#if __has_include(<sys/types.h>)
>>> 
>>> Is __has_include() something that we can use unconditionally?
>> 
>> Hmm.. maybe we cannot, it seems it was introduced in gcc-4.9 and we only ask
>> for 4.8, IIRC.
>> 
>> I guess HAVE_SYS_TYPES_H might be an alternative (I’ll have to retest)
> 
> Answering my own question; no that is not going to work  either since the header is
> installed and config.h is not.
> 
> I guess the question is “is this header ever [meaningfully] consumed by a compiler
> other than the current GCC that it supports”?
> 
> e.g. if we expected we could build libgccjit with clang in a “—disable-bootstrap”
> configuration and expect that to work?
> 

this … (as attached)

> The fallback is
> #ifdef __APPLE__
> # include <sys/types.h>  /* For ssize_t.  */
> #endif


> 
> (which I will test on a number of platform versions).
> 
> since this breaks bootstrap at stage 2 on affected platform versions, so we need some
> fix.


[-- Attachment #2: 0001-jit-Ensure-ssize_t-is-defined.patch --]
[-- Type: application/octet-stream, Size: 1158 bytes --]

From d289211d30457683df38b44449dccdb41c556b33 Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Sun, 21 Jan 2024 10:44:49 +0000
Subject: [PATCH] jit: Ensure ssize_t is defined.

One some targets it seems that ssize_t is not defined by any of the
headers transitively included by <stdio.h>.  This leads to a bootstrap
fail when jit is enabled.

The fix proposed here is to include sys/types.h when it is available
since that is where Posiz specifies that ssize_t is defined.

gcc/jit/ChangeLog:

	* libgccjit.h: Conditionally include <sys/types.h> on Darwin
	to ensure declaration of ssize_t.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
---
 gcc/jit/libgccjit.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
index 74e847b2dec..58d282046e8 100644
--- a/gcc/jit/libgccjit.h
+++ b/gcc/jit/libgccjit.h
@@ -21,6 +21,9 @@ along with GCC; see the file COPYING3.  If not see
 #define LIBGCCJIT_H
 
 #include <stdio.h>
+#ifdef __APPLE__
+# include <sys/types.h>  /* For ssize_t.  */
+#endif
 
 #ifdef __cplusplus
 extern "C" {
-- 
2.39.2 (Apple Git-143)


[-- Attachment #3: Type: text/plain, Size: 2 bytes --]




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

end of thread, other threads:[~2024-04-02 11:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-28 11:44 [PATCH] jit: Ensure ssize_t is defined Iain Sandoe
2024-01-28 21:25 ` Eric Gallager
2024-01-28 23:13   ` Iain Sandoe
2024-01-29 11:26     ` Iain Sandoe
2024-04-02 11:45       ` Ping: " Iain Sandoe

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