public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
@ 2022-04-24 10:17 soeren
  2022-05-07 11:18 ` Sören Tempel
  2022-05-09 23:33 ` [PATCH] " Ian Lance Taylor
  0 siblings, 2 replies; 17+ messages in thread
From: soeren @ 2022-04-24 10:17 UTC (permalink / raw)
  To: gofrontend-dev; +Cc: iant, gcc-patches

From: Sören Tempel <soeren+git@soeren-tempel.net>

The libgo code assumes both off64_t and loff_t to be present. For
example, for the splice(2) function prototype. Similar to glibc,
musl libc supports these types but defines them as macros, not as
typedefs. Unfortunately, -fdump-go-spec only recognizes types defined
using typedef. To workaround that, this commit adds explicit typedefs
for these types if off64_t or loff_t are defined as macros.

Furthermore, loff_t is only defined on musl with -D_GNU_SOURCE and
requires an include of fcntl.h (this is in accordance with the splice(2)
man page). Therefore, the configure script has also been adjusted
accordingly.
---
 libgo/configure    |  6 +++++-
 libgo/configure.ac |  6 +++++-
 libgo/sysinfo.c    | 14 ++++++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/libgo/configure b/libgo/configure
index ffe17c9b..b83ddfb3 100755
--- a/libgo/configure
+++ b/libgo/configure
@@ -15546,7 +15546,10 @@ _ACEOF
 
 fi
 
-ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "$ac_includes_default"
+CFLAGS_hold=$CFLAGS
+CFLAGS="$CFLAGS -D_GNU_SOURCE"
+ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "#include <fcntl.h>
+"
 if test "x$ac_cv_type_loff_t" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
@@ -15556,6 +15559,7 @@ _ACEOF
 
 fi
 
+CFLAGS=$CFLAGS_hold
 
 LIBS_hold="$LIBS"
 LIBS="$LIBS -lm"
diff --git a/libgo/configure.ac b/libgo/configure.ac
index 7e2b98ba..b8f7d1a0 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -601,7 +601,11 @@ AC_STRUCT_DIRENT_D_TYPE
 
 AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice syscall tee unlinkat unshare utimensat)
 AC_TYPE_OFF_T
-AC_CHECK_TYPES([loff_t])
+
+CFLAGS_hold=$CFLAGS
+CFLAGS="$CFLAGS -D_GNU_SOURCE"
+AC_CHECK_TYPES([loff_t], [], [], [[#include <fcntl.h>]])
+CFLAGS=$CFLAGS_hold
 
 LIBS_hold="$LIBS"
 LIBS="$LIBS -lm"
diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index 8ce061e2..22f52e5b 100644
--- a/libgo/sysinfo.c
+++ b/libgo/sysinfo.c
@@ -343,6 +343,20 @@ enum {
 #endif
 };
 
+// musl libc has both off64_t and loff_t. However, both of these types
+// are defined as CPP macros, not as C typedefs. Unfortunately, the GCC
+// option -fdump-go-spec only recognizes types defined using typedefs.
+#if defined(HAVE_OFF64_T) && defined(off64_t)
+typedef off64_t __musl_off64_t;
+#undef off64_t
+typedef __musl_off64_t off64_t;
+#endif
+#if defined(HAVE_LOFF_T) && defined(loff_t)
+typedef loff_t __musl_loff_t;
+#undef loff_t
+typedef __musl_loff_t loff_t;
+#endif
+
 // SIOCGIFMTU can't be added in the above enum as it might
 // be signed in some OSes.
 #ifdef SIOCGIFMTU

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

* Re: libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-04-24 10:17 [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc soeren
@ 2022-05-07 11:18 ` Sören Tempel
  2022-05-09 23:33 ` [PATCH] " Ian Lance Taylor
  1 sibling, 0 replies; 17+ messages in thread
From: Sören Tempel @ 2022-05-07 11:18 UTC (permalink / raw)
  To: gofrontend-dev; +Cc: iant, gcc-patches

PING.

Summary: gcc-go currently assumes that both loff_t and off64_t are defined
as a typedef. However, musl defines them as a CPP macro causing gccgo to
not compile with musl libc.

See: https://gcc.gnu.org/pipermail/gcc-patches/2022-April/593527.html

If an alternative solution to the problem is preferred, please let me know.

Sören Tempel <soeren@soeren-tempel.net> wrote:
> The libgo code assumes both off64_t and loff_t to be present. For
> example, for the splice(2) function prototype. Similar to glibc,
> musl libc supports these types but defines them as macros, not as
> typedefs. Unfortunately, -fdump-go-spec only recognizes types defined
> using typedef. To workaround that, this commit adds explicit typedefs
> for these types if off64_t or loff_t are defined as macros.
> 
> Furthermore, loff_t is only defined on musl with -D_GNU_SOURCE and
> requires an include of fcntl.h (this is in accordance with the splice(2)
> man page). Therefore, the configure script has also been adjusted
> accordingly.
> ---
>  libgo/configure    |  6 +++++-
>  libgo/configure.ac |  6 +++++-
>  libgo/sysinfo.c    | 14 ++++++++++++++
>  3 files changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/libgo/configure b/libgo/configure
> index ffe17c9b..b83ddfb3 100755
> --- a/libgo/configure
> +++ b/libgo/configure
> @@ -15546,7 +15546,10 @@ _ACEOF
>  
>  fi
>  
> -ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "$ac_includes_default"
> +CFLAGS_hold=$CFLAGS
> +CFLAGS="$CFLAGS -D_GNU_SOURCE"
> +ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "#include <fcntl.h>
> +"
>  if test "x$ac_cv_type_loff_t" = xyes; then :
>  
>  cat >>confdefs.h <<_ACEOF
> @@ -15556,6 +15559,7 @@ _ACEOF
>  
>  fi
>  
> +CFLAGS=$CFLAGS_hold
>  
>  LIBS_hold="$LIBS"
>  LIBS="$LIBS -lm"
> diff --git a/libgo/configure.ac b/libgo/configure.ac
> index 7e2b98ba..b8f7d1a0 100644
> --- a/libgo/configure.ac
> +++ b/libgo/configure.ac
> @@ -601,7 +601,11 @@ AC_STRUCT_DIRENT_D_TYPE
>  
>  AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice syscall tee unlinkat unshare utimensat)
>  AC_TYPE_OFF_T
> -AC_CHECK_TYPES([loff_t])
> +
> +CFLAGS_hold=$CFLAGS
> +CFLAGS="$CFLAGS -D_GNU_SOURCE"
> +AC_CHECK_TYPES([loff_t], [], [], [[#include <fcntl.h>]])
> +CFLAGS=$CFLAGS_hold
>  
>  LIBS_hold="$LIBS"
>  LIBS="$LIBS -lm"
> diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
> index 8ce061e2..22f52e5b 100644
> --- a/libgo/sysinfo.c
> +++ b/libgo/sysinfo.c
> @@ -343,6 +343,20 @@ enum {
>  #endif
>  };
>  
> +// musl libc has both off64_t and loff_t. However, both of these types
> +// are defined as CPP macros, not as C typedefs. Unfortunately, the GCC
> +// option -fdump-go-spec only recognizes types defined using typedefs.
> +#if defined(HAVE_OFF64_T) && defined(off64_t)
> +typedef off64_t __musl_off64_t;
> +#undef off64_t
> +typedef __musl_off64_t off64_t;
> +#endif
> +#if defined(HAVE_LOFF_T) && defined(loff_t)
> +typedef loff_t __musl_loff_t;
> +#undef loff_t
> +typedef __musl_loff_t loff_t;
> +#endif
> +
>  // SIOCGIFMTU can't be added in the above enum as it might
>  // be signed in some OSes.

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-04-24 10:17 [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc soeren
  2022-05-07 11:18 ` Sören Tempel
@ 2022-05-09 23:33 ` Ian Lance Taylor
  2022-05-12 18:22   ` Sören Tempel
  1 sibling, 1 reply; 17+ messages in thread
From: Ian Lance Taylor @ 2022-05-09 23:33 UTC (permalink / raw)
  To: soeren; +Cc: gofrontend-dev, gcc-patches

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

On Sun, Apr 24, 2022 at 3:20 AM <soeren@soeren-tempel.net> wrote:
>
> From: Sören Tempel <soeren+git@soeren-tempel.net>
>
> The libgo code assumes both off64_t and loff_t to be present. For
> example, for the splice(2) function prototype. Similar to glibc,
> musl libc supports these types but defines them as macros, not as
> typedefs. Unfortunately, -fdump-go-spec only recognizes types defined
> using typedef. To workaround that, this commit adds explicit typedefs
> for these types if off64_t or loff_t are defined as macros.
>
> Furthermore, loff_t is only defined on musl with -D_GNU_SOURCE and
> requires an include of fcntl.h (this is in accordance with the splice(2)
> man page). Therefore, the configure script has also been adjusted
> accordingly.

I see uses of loff_t but I don't see any uses of off64_t.

We don't have to treat loff_t differently based on whether it is a
macro, we can just use a different name.

Does this patch work for you?

Ian

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 5944 bytes --]

diff --git a/libgo/config.h.in b/libgo/config.h.in
index 25b8ab8f9..2c3c74696 100644
--- a/libgo/config.h.in
+++ b/libgo/config.h.in
@@ -70,6 +70,9 @@
 /* Define to 1 if you have the `fchownat' function. */
 #undef HAVE_FCHOWNAT
 
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
 /* Define to 1 if you have the `futimesat' function. */
 #undef HAVE_FUTIMESAT
 
diff --git a/libgo/configure b/libgo/configure
index ffe17c9be..eaea892a6 100755
--- a/libgo/configure
+++ b/libgo/configure
@@ -15249,7 +15249,7 @@ $as_echo "#define HAVE_GETIPINFO 1" >>confdefs.h
   fi
 
 
-for ac_header in port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h
+for ac_header in fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -15546,6 +15546,9 @@ _ACEOF
 
 fi
 
+
+CFLAGS_hold="$CFLAGS"
+CFLAGS="$OSCFLAGS $CFLAGS"
 ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "$ac_includes_default"
 if test "x$ac_cv_type_loff_t" = xyes; then :
 
@@ -15556,6 +15559,7 @@ _ACEOF
 
 fi
 
+CFLAGS="$CFLAGS_hold"
 
 LIBS_hold="$LIBS"
 LIBS="$LIBS -lm"
diff --git a/libgo/configure.ac b/libgo/configure.ac
index 7e2b98ba6..487099a33 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -579,7 +579,7 @@ AC_C_BIGENDIAN
 
 GCC_CHECK_UNWIND_GETIPINFO
 
-AC_CHECK_HEADERS(port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h)
+AC_CHECK_HEADERS(fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h)
 
 AC_CHECK_HEADERS([netinet/icmp6.h], [], [],
 [#include <netinet/in.h>
@@ -601,7 +601,11 @@ AC_STRUCT_DIRENT_D_TYPE
 
 AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice syscall tee unlinkat unshare utimensat)
 AC_TYPE_OFF_T
+
+CFLAGS_hold="$CFLAGS"
+CFLAGS="$OSCFLAGS $CFLAGS"
 AC_CHECK_TYPES([loff_t])
+CFLAGS="$CFLAGS_hold"
 
 LIBS_hold="$LIBS"
 LIBS="$LIBS -lm"
diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go
index 96974bd32..d41af5e28 100644
--- a/libgo/go/syscall/libcall_linux.go
+++ b/libgo/go/syscall/libcall_linux.go
@@ -209,19 +209,19 @@ func Gettid() (tid int) {
 //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
 //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
 
-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
+//sys	splice(rfd int, roff *_libgo_loff_t_type, wfd int, woff *_libgo_loff_t_type, len int, flags int) (n int64, err error)
+//splice(rfd _C_int, roff *_libgo_loff_t_type, wfd _C_int, woff *_libgo_loff_t_type, len Size_t, flags _C_uint) Ssize_t
 func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
-	var lroff _loff_t
-	var plroff *_loff_t
+	var lroff _libgo_loff_t_type
+	var plroff *_libgo_loff_t_type
 	if roff != nil {
-		lroff = _loff_t(*roff)
+		lroff = _libgo_loff_t_type(*roff)
 		plroff = &lroff
 	}
-	var lwoff _loff_t
-	var plwoff *_loff_t
+	var lwoff _libgo_loff_t_type
+	var plwoff *_libgo_loff_t_type
 	if woff != nil {
-		lwoff = _loff_t(*woff)
+		lwoff = _libgo_loff_t_type(*woff)
 		plwoff = &lwoff
 	}
 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index 8ce061e2f..e47cf7235 100644
--- a/libgo/sysinfo.c
+++ b/libgo/sysinfo.c
@@ -357,6 +357,12 @@ enum {
 };
 #endif
 
+#if defined(HAVE_LOFF_T)
+// loff_t can be defined as a macro; for -fgo-dump-spec make sure we
+// see a typedef.
+typedef loff_t libgo_loff_t_type;
+#endif
+
 // The following section introduces explicit references to types and
 // constants of interest to support bootstrapping libgo using a
 // compiler that doesn't support -fdump-go-spec (e.g., clang), via
@@ -537,7 +543,7 @@ SREF(timex);
 // From sys/types.h
 TREF(pid_t);
 TREF(off_t);
-TREF(loff_t);
+TREF(libgo_loff_t_type);
 TREF(size_t);
 TREF(ssize_t);
 TREF(mode_t);

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-05-09 23:33 ` [PATCH] " Ian Lance Taylor
@ 2022-05-12 18:22   ` Sören Tempel
  2022-05-12 21:04     ` Ian Lance Taylor
  0 siblings, 1 reply; 17+ messages in thread
From: Sören Tempel @ 2022-05-12 18:22 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gofrontend-dev, gcc-patches

Hi Ian,

Thanks for following up on this, comments below.

Ian Lance Taylor <iant@golang.org> wrote:
> I see uses of loff_t but I don't see any uses of off64_t.

The off64_t type is used for defining Offset_t:

	https://github.com/golang/gofrontend/blob/4bdff733a0c2a9ddc3eff104b1be03df058a79c4/libgo/mksysinfo.sh#L406-L410

On musl, _HAVE_OFF64_T is defined since autoconf doesn't mind it
being defined as a macro but -fdump-go-spec does, hence you end up
with the following compilation error (even with your patch applied):

	sysinfo.go:7896:15: error: use of undefined type '_off64_t'
	 7896 | type Offset_t _off64_t

> We don't have to treat loff_t differently based on whether it is a
> macro, we can just use a different name.

Sounds good to me.

> Does this patch work for you?

Apart from off64_t stuff, there is only one minor issue (see below).

> index 7e2b98ba6..487099a33 100644
> --- a/libgo/configure.ac
> +++ b/libgo/configure.ac
> @@ -579,7 +579,7 @@ AC_C_BIGENDIAN
> +
> +CFLAGS_hold="$CFLAGS"
> +CFLAGS="$OSCFLAGS $CFLAGS"
>  AC_CHECK_TYPES([loff_t])
> +CFLAGS="$CFLAGS_hold"

The AC_CHECK_TYPES invocation is missing an include of fcntl.h (which
defines loff_t in musl) and as such fails and causes libgo compilation
to fail with "reference to undefined name '_libgo_loff_t_type'" as
HAVE_LOFF_T is not defined. The invocation needs to be changed to:

	AC_CHECK_TYPES([loff_t], [], [], [[#include <fcntl.h>]])

and this needs to be adjusted accordingly in configure as well.

Sincerely,
Sören

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-05-12 18:22   ` Sören Tempel
@ 2022-05-12 21:04     ` Ian Lance Taylor
  2022-05-18  7:22       ` Sören Tempel
  0 siblings, 1 reply; 17+ messages in thread
From: Ian Lance Taylor @ 2022-05-12 21:04 UTC (permalink / raw)
  To: Sören Tempel; +Cc: gcc-patches, gofrontend-dev

On Thu, May 12, 2022 at 11:23 AM Sören Tempel via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> The off64_t type is used for defining Offset_t:
>
>         https://github.com/golang/gofrontend/blob/4bdff733a0c2a9ddc3eff104b1be03df058a79c4/libgo/mksysinfo.sh#L406-L410
>
> On musl, _HAVE_OFF64_T is defined since autoconf doesn't mind it
> being defined as a macro but -fdump-go-spec does, hence you end up
> with the following compilation error (even with your patch applied):

Ah, thanks.


> Apart from off64_t stuff, there is only one minor issue (see below).
>
> > index 7e2b98ba6..487099a33 100644
> > --- a/libgo/configure.ac
> > +++ b/libgo/configure.ac
> > @@ -579,7 +579,7 @@ AC_C_BIGENDIAN
> > +
> > +CFLAGS_hold="$CFLAGS"
> > +CFLAGS="$OSCFLAGS $CFLAGS"
> >  AC_CHECK_TYPES([loff_t])
> > +CFLAGS="$CFLAGS_hold"
>
> The AC_CHECK_TYPES invocation is missing an include of fcntl.h (which
> defines loff_t in musl) and as such fails and causes libgo compilation
> to fail with "reference to undefined name '_libgo_loff_t_type'" as
> HAVE_LOFF_T is not defined. The invocation needs to be changed to:
>
>         AC_CHECK_TYPES([loff_t], [], [], [[#include <fcntl.h>]])
>
> and this needs to be adjusted accordingly in configure as well.

Hmmm, I added fcntl.h to AC_CHECK_HEADERS.  I thought that would be
enough to cause it to be included in future tests.  Perhaps not.

Ian

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-05-12 21:04     ` Ian Lance Taylor
@ 2022-05-18  7:22       ` Sören Tempel
  2022-05-31 19:41         ` Sören Tempel
  0 siblings, 1 reply; 17+ messages in thread
From: Sören Tempel @ 2022-05-18  7:22 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches, gofrontend-dev

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

I modified your patch to also define libgo_off_t_type (along to
libgo_loff_t_type) and used that to define Offset_t in mksysinfo.sh.
Furthermore, I fixed the include for the loff_t feature check.

With those two modifications your patch works for me (see attachment).

Greetings,
Sören

Ian Lance Taylor <iant@golang.org> wrote:
> On Thu, May 12, 2022 at 11:23 AM Sören Tempel via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > The off64_t type is used for defining Offset_t:
> >
> >         https://github.com/golang/gofrontend/blob/4bdff733a0c2a9ddc3eff104b1be03df058a79c4/libgo/mksysinfo.sh#L406-L410
> >
> > On musl, _HAVE_OFF64_T is defined since autoconf doesn't mind it
> > being defined as a macro but -fdump-go-spec does, hence you end up
> > with the following compilation error (even with your patch applied):
> 
> Ah, thanks.
> 
> 
> > Apart from off64_t stuff, there is only one minor issue (see below).
> >
> > > index 7e2b98ba6..487099a33 100644
> > > --- a/libgo/configure.ac
> > > +++ b/libgo/configure.ac
> > > @@ -579,7 +579,7 @@ AC_C_BIGENDIAN
> > > +
> > > +CFLAGS_hold="$CFLAGS"
> > > +CFLAGS="$OSCFLAGS $CFLAGS"
> > >  AC_CHECK_TYPES([loff_t])
> > > +CFLAGS="$CFLAGS_hold"
> >
> > The AC_CHECK_TYPES invocation is missing an include of fcntl.h (which
> > defines loff_t in musl) and as such fails and causes libgo compilation
> > to fail with "reference to undefined name '_libgo_loff_t_type'" as
> > HAVE_LOFF_T is not defined. The invocation needs to be changed to:
> >
> >         AC_CHECK_TYPES([loff_t], [], [], [[#include <fcntl.h>]])
> >
> > and this needs to be adjusted accordingly in configure as well.
> 
> Hmmm, I added fcntl.h to AC_CHECK_HEADERS.  I thought that would be
> enough to cause it to be included in future tests.  Perhaps not.
> 
> Ian


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 7013 bytes --]

diff --git a/libgo/config.h.in b/libgo/config.h.in
index 25b8ab8f9ee..2c3c7469675 100644
--- a/libgo/config.h.in
+++ b/libgo/config.h.in
@@ -70,6 +70,9 @@
 /* Define to 1 if you have the `fchownat' function. */
 #undef HAVE_FCHOWNAT
 
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
 /* Define to 1 if you have the `futimesat' function. */
 #undef HAVE_FUTIMESAT
 
diff --git a/libgo/configure b/libgo/configure
index ffe17c9be55..13e21d60c62 100755
--- a/libgo/configure
+++ b/libgo/configure
@@ -15249,7 +15249,7 @@ $as_echo "#define HAVE_GETIPINFO 1" >>confdefs.h
   fi
 
 
-for ac_header in port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h
+for ac_header in fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -15546,7 +15546,10 @@ _ACEOF
 
 fi
 
-ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "$ac_includes_default"
+
+CFLAGS_hold="$CFLAGS"
+CFLAGS="$OSCFLAGS $CFLAGS"
+ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "#include <fcntl.h>"
 if test "x$ac_cv_type_loff_t" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
@@ -15556,6 +15559,7 @@ _ACEOF
 
 fi
 
+CFLAGS="$CFLAGS_hold"
 
 LIBS_hold="$LIBS"
 LIBS="$LIBS -lm"
diff --git a/libgo/configure.ac b/libgo/configure.ac
index 7e2b98ba67c..bac58b07b41 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -579,7 +579,7 @@ AC_C_BIGENDIAN
 
 GCC_CHECK_UNWIND_GETIPINFO
 
-AC_CHECK_HEADERS(port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h)
+AC_CHECK_HEADERS(fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h)
 
 AC_CHECK_HEADERS([netinet/icmp6.h], [], [],
 [#include <netinet/in.h>
@@ -601,7 +601,11 @@ AC_STRUCT_DIRENT_D_TYPE
 
 AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice syscall tee unlinkat unshare utimensat)
 AC_TYPE_OFF_T
-AC_CHECK_TYPES([loff_t])
+
+CFLAGS_hold="$CFLAGS"
+CFLAGS="$OSCFLAGS $CFLAGS"
+AC_CHECK_TYPES([loff_t], [], [], [[#include <fcntl.h>]])
+CFLAGS="$CFLAGS_hold"
 
 LIBS_hold="$LIBS"
 LIBS="$LIBS -lm"
diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go
index 96974bd3269..d41af5e28b3 100644
--- a/libgo/go/syscall/libcall_linux.go
+++ b/libgo/go/syscall/libcall_linux.go
@@ -209,19 +209,19 @@ func Gettid() (tid int) {
 //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
 //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
 
-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
+//sys	splice(rfd int, roff *_libgo_loff_t_type, wfd int, woff *_libgo_loff_t_type, len int, flags int) (n int64, err error)
+//splice(rfd _C_int, roff *_libgo_loff_t_type, wfd _C_int, woff *_libgo_loff_t_type, len Size_t, flags _C_uint) Ssize_t
 func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
-	var lroff _loff_t
-	var plroff *_loff_t
+	var lroff _libgo_loff_t_type
+	var plroff *_libgo_loff_t_type
 	if roff != nil {
-		lroff = _loff_t(*roff)
+		lroff = _libgo_loff_t_type(*roff)
 		plroff = &lroff
 	}
-	var lwoff _loff_t
-	var plwoff *_loff_t
+	var lwoff _libgo_loff_t_type
+	var plwoff *_libgo_loff_t_type
 	if woff != nil {
-		lwoff = _loff_t(*woff)
+		lwoff = _libgo_loff_t_type(*woff)
 		plwoff = &lwoff
 	}
 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh
index 0c52ea5d71a..5aa309155c3 100755
--- a/libgo/mksysinfo.sh
+++ b/libgo/mksysinfo.sh
@@ -403,11 +403,7 @@ fi
 # Some basic types.
 echo 'type Size_t _size_t' >> ${OUT}
 echo "type Ssize_t _ssize_t" >> ${OUT}
-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
-  echo "type Offset_t _off64_t" >> ${OUT}
-else
-  echo "type Offset_t _off_t" >> ${OUT}
-fi
+echo "type Offset_t _libgo_off_t_type" >> ${OUT}
 echo "type Mode_t _mode_t" >> ${OUT}
 echo "type Pid_t _pid_t" >> ${OUT}
 echo "type Uid_t _uid_t" >> ${OUT}
diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index 8ce061e2f5f..a4259c02ded 100644
--- a/libgo/sysinfo.c
+++ b/libgo/sysinfo.c
@@ -357,6 +357,18 @@ enum {
 };
 #endif
 
+#if defined(HAVE_LOFF_T)
+// loff_t can be defined as a macro; for -fgo-dump-spec make sure we
+// see a typedef.
+typedef loff_t libgo_loff_t_type;
+#endif
+
+#if defined(HAVE_OFF64_T)
+typedef off64_t libgo_off_t_type;
+#else
+typedef off_t libgo_off_t_type;
+#endif
+
 // The following section introduces explicit references to types and
 // constants of interest to support bootstrapping libgo using a
 // compiler that doesn't support -fdump-go-spec (e.g., clang), via
@@ -537,7 +549,8 @@ SREF(timex);
 // From sys/types.h
 TREF(pid_t);
 TREF(off_t);
-TREF(loff_t);
+TREF(libgo_loff_t_type);
+TREF(libgo_off_t_type);
 TREF(size_t);
 TREF(ssize_t);
 TREF(mode_t);

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-05-18  7:22       ` Sören Tempel
@ 2022-05-31 19:41         ` Sören Tempel
  2022-06-17 21:27           ` Ian Lance Taylor
  0 siblings, 1 reply; 17+ messages in thread
From: Sören Tempel @ 2022-05-31 19:41 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches, gofrontend-dev

PING.

If there is anything else that needs to be addressed please let me know.

Sören Tempel <soeren@soeren-tempel.net> wrote:
> I modified your patch to also define libgo_off_t_type (along to
> libgo_loff_t_type) and used that to define Offset_t in mksysinfo.sh.
> Furthermore, I fixed the include for the loff_t feature check.
> 
> With those two modifications your patch works for me (see attachment).
> 
> Greetings,
> Sören
> 
> Ian Lance Taylor <iant@golang.org> wrote:
> > On Thu, May 12, 2022 at 11:23 AM Sören Tempel via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> > >
> > > The off64_t type is used for defining Offset_t:
> > >
> > >         https://github.com/golang/gofrontend/blob/4bdff733a0c2a9ddc3eff104b1be03df058a79c4/libgo/mksysinfo.sh#L406-L410
> > >
> > > On musl, _HAVE_OFF64_T is defined since autoconf doesn't mind it
> > > being defined as a macro but -fdump-go-spec does, hence you end up
> > > with the following compilation error (even with your patch applied):
> > 
> > Ah, thanks.
> > 
> > 
> > > Apart from off64_t stuff, there is only one minor issue (see below).
> > >
> > > > index 7e2b98ba6..487099a33 100644
> > > > --- a/libgo/configure.ac
> > > > +++ b/libgo/configure.ac
> > > > @@ -579,7 +579,7 @@ AC_C_BIGENDIAN
> > > > +
> > > > +CFLAGS_hold="$CFLAGS"
> > > > +CFLAGS="$OSCFLAGS $CFLAGS"
> > > >  AC_CHECK_TYPES([loff_t])
> > > > +CFLAGS="$CFLAGS_hold"
> > >
> > > The AC_CHECK_TYPES invocation is missing an include of fcntl.h (which
> > > defines loff_t in musl) and as such fails and causes libgo compilation
> > > to fail with "reference to undefined name '_libgo_loff_t_type'" as
> > > HAVE_LOFF_T is not defined. The invocation needs to be changed to:
> > >
> > >         AC_CHECK_TYPES([loff_t], [], [], [[#include <fcntl.h>]])
> > >
> > > and this needs to be adjusted accordingly in configure as well.
> > 
> > Hmmm, I added fcntl.h to AC_CHECK_HEADERS.  I thought that would be
> > enough to cause it to be included in future tests.  Perhaps not.
> > 
> > Ian
> 
> diff --git a/libgo/config.h.in b/libgo/config.h.in
> index 25b8ab8f9ee..2c3c7469675 100644
> --- a/libgo/config.h.in
> +++ b/libgo/config.h.in
> @@ -70,6 +70,9 @@
>  /* Define to 1 if you have the `fchownat' function. */
>  #undef HAVE_FCHOWNAT
>  
> +/* Define to 1 if you have the <fcntl.h> header file. */
> +#undef HAVE_FCNTL_H
> +
>  /* Define to 1 if you have the `futimesat' function. */
>  #undef HAVE_FUTIMESAT
>  
> diff --git a/libgo/configure b/libgo/configure
> index ffe17c9be55..13e21d60c62 100755
> --- a/libgo/configure
> +++ b/libgo/configure
> @@ -15249,7 +15249,7 @@ $as_echo "#define HAVE_GETIPINFO 1" >>confdefs.h
>    fi
>  
>  
> -for ac_header in port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h
> +for ac_header in fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h
>  do :
>    as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
>  ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
> @@ -15546,7 +15546,10 @@ _ACEOF
>  
>  fi
>  
> -ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "$ac_includes_default"
> +
> +CFLAGS_hold="$CFLAGS"
> +CFLAGS="$OSCFLAGS $CFLAGS"
> +ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "#include <fcntl.h>"
>  if test "x$ac_cv_type_loff_t" = xyes; then :
>  
>  cat >>confdefs.h <<_ACEOF
> @@ -15556,6 +15559,7 @@ _ACEOF
>  
>  fi
>  
> +CFLAGS="$CFLAGS_hold"
>  
>  LIBS_hold="$LIBS"
>  LIBS="$LIBS -lm"
> diff --git a/libgo/configure.ac b/libgo/configure.ac
> index 7e2b98ba67c..bac58b07b41 100644
> --- a/libgo/configure.ac
> +++ b/libgo/configure.ac
> @@ -579,7 +579,7 @@ AC_C_BIGENDIAN
>  
>  GCC_CHECK_UNWIND_GETIPINFO
>  
> -AC_CHECK_HEADERS(port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h)
> +AC_CHECK_HEADERS(fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h)
>  
>  AC_CHECK_HEADERS([netinet/icmp6.h], [], [],
>  [#include <netinet/in.h>
> @@ -601,7 +601,11 @@ AC_STRUCT_DIRENT_D_TYPE
>  
>  AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice syscall tee unlinkat unshare utimensat)
>  AC_TYPE_OFF_T
> -AC_CHECK_TYPES([loff_t])
> +
> +CFLAGS_hold="$CFLAGS"
> +CFLAGS="$OSCFLAGS $CFLAGS"
> +AC_CHECK_TYPES([loff_t], [], [], [[#include <fcntl.h>]])
> +CFLAGS="$CFLAGS_hold"
>  
>  LIBS_hold="$LIBS"
>  LIBS="$LIBS -lm"
> diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go
> index 96974bd3269..d41af5e28b3 100644
> --- a/libgo/go/syscall/libcall_linux.go
> +++ b/libgo/go/syscall/libcall_linux.go
> @@ -209,19 +209,19 @@ func Gettid() (tid int) {
>  //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
>  //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
>  
> -//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
> -//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
> +//sys	splice(rfd int, roff *_libgo_loff_t_type, wfd int, woff *_libgo_loff_t_type, len int, flags int) (n int64, err error)
> +//splice(rfd _C_int, roff *_libgo_loff_t_type, wfd _C_int, woff *_libgo_loff_t_type, len Size_t, flags _C_uint) Ssize_t
>  func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
> -	var lroff _loff_t
> -	var plroff *_loff_t
> +	var lroff _libgo_loff_t_type
> +	var plroff *_libgo_loff_t_type
>  	if roff != nil {
> -		lroff = _loff_t(*roff)
> +		lroff = _libgo_loff_t_type(*roff)
>  		plroff = &lroff
>  	}
> -	var lwoff _loff_t
> -	var plwoff *_loff_t
> +	var lwoff _libgo_loff_t_type
> +	var plwoff *_libgo_loff_t_type
>  	if woff != nil {
> -		lwoff = _loff_t(*woff)
> +		lwoff = _libgo_loff_t_type(*woff)
>  		plwoff = &lwoff
>  	}
>  	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
> diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh
> index 0c52ea5d71a..5aa309155c3 100755
> --- a/libgo/mksysinfo.sh
> +++ b/libgo/mksysinfo.sh
> @@ -403,11 +403,7 @@ fi
>  # Some basic types.
>  echo 'type Size_t _size_t' >> ${OUT}
>  echo "type Ssize_t _ssize_t" >> ${OUT}
> -if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
> -  echo "type Offset_t _off64_t" >> ${OUT}
> -else
> -  echo "type Offset_t _off_t" >> ${OUT}
> -fi
> +echo "type Offset_t _libgo_off_t_type" >> ${OUT}
>  echo "type Mode_t _mode_t" >> ${OUT}
>  echo "type Pid_t _pid_t" >> ${OUT}
>  echo "type Uid_t _uid_t" >> ${OUT}
> diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
> index 8ce061e2f5f..a4259c02ded 100644
> --- a/libgo/sysinfo.c
> +++ b/libgo/sysinfo.c
> @@ -357,6 +357,18 @@ enum {
>  };
>  #endif
>  
> +#if defined(HAVE_LOFF_T)
> +// loff_t can be defined as a macro; for -fgo-dump-spec make sure we
> +// see a typedef.
> +typedef loff_t libgo_loff_t_type;
> +#endif
> +
> +#if defined(HAVE_OFF64_T)
> +typedef off64_t libgo_off_t_type;
> +#else
> +typedef off_t libgo_off_t_type;
> +#endif
> +
>  // The following section introduces explicit references to types and
>  // constants of interest to support bootstrapping libgo using a
>  // compiler that doesn't support -fdump-go-spec (e.g., clang), via
> @@ -537,7 +549,8 @@ SREF(timex);
>  // From sys/types.h
>  TREF(pid_t);
>  TREF(off_t);
> -TREF(loff_t);
> +TREF(libgo_loff_t_type);
> +TREF(libgo_off_t_type);
>  TREF(size_t);
>  TREF(ssize_t);
>  TREF(mode_t);

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-05-31 19:41         ` Sören Tempel
@ 2022-06-17 21:27           ` Ian Lance Taylor
  2022-06-18  7:18             ` Andreas Schwab
  0 siblings, 1 reply; 17+ messages in thread
From: Ian Lance Taylor @ 2022-06-17 21:27 UTC (permalink / raw)
  To: Sören Tempel; +Cc: gcc-patches, gofrontend-dev

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

On Tue, May 31, 2022 at 12:41 PM Sören Tempel <soeren@soeren-tempel.net> wrote:
>
> PING.
>
> If there is anything else that needs to be addressed please let me know.

Thanks.  Committed as follows.  Sorry for the delay.

Ian

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 5105 bytes --]

e584afe7976a40df42eed4df6ce6852abab74030
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 0cda305c648..4b75dd37355 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-8db6b78110f84e22c409f334aeaefb80a8b39917
+a409e049737ec9a358a19233e017d957db3d6d2a
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/configure.ac b/libgo/configure.ac
index 7e2b98ba67c..bac58b07b41 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -579,7 +579,7 @@ AC_C_BIGENDIAN
 
 GCC_CHECK_UNWIND_GETIPINFO
 
-AC_CHECK_HEADERS(port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h)
+AC_CHECK_HEADERS(fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h)
 
 AC_CHECK_HEADERS([netinet/icmp6.h], [], [],
 [#include <netinet/in.h>
@@ -601,7 +601,11 @@ AC_STRUCT_DIRENT_D_TYPE
 
 AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice syscall tee unlinkat unshare utimensat)
 AC_TYPE_OFF_T
-AC_CHECK_TYPES([loff_t])
+
+CFLAGS_hold="$CFLAGS"
+CFLAGS="$OSCFLAGS $CFLAGS"
+AC_CHECK_TYPES([loff_t], [], [], [[#include <fcntl.h>]])
+CFLAGS="$CFLAGS_hold"
 
 LIBS_hold="$LIBS"
 LIBS="$LIBS -lm"
diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go
index 7bec2fbaeb5..19ae4393cf1 100644
--- a/libgo/go/syscall/libcall_linux.go
+++ b/libgo/go/syscall/libcall_linux.go
@@ -210,20 +210,20 @@ func Gettid() (tid int) {
 //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
 //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
 
-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
+//sys	splice(rfd int, roff *_libgo_loff_t_type, wfd int, woff *_libgo_loff_t_type, len int, flags int) (n int64, err error)
+//splice(rfd _C_int, roff *_libgo_loff_t_type, wfd _C_int, woff *_libgo_loff_t_type, len Size_t, flags _C_uint) Ssize_t
 
 func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
-	var lroff _loff_t
-	var plroff *_loff_t
+	var lroff _libgo_loff_t_type
+	var plroff *_libgo_loff_t_type
 	if roff != nil {
-		lroff = _loff_t(*roff)
+		lroff = _libgo_loff_t_type(*roff)
 		plroff = &lroff
 	}
-	var lwoff _loff_t
-	var plwoff *_loff_t
+	var lwoff _libgo_loff_t_type
+	var plwoff *_libgo_loff_t_type
 	if woff != nil {
-		lwoff = _loff_t(*woff)
+		lwoff = _libgo_loff_t_type(*woff)
 		plwoff = &lwoff
 	}
 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh
index 0c52ea5d71a..5aa309155c3 100755
--- a/libgo/mksysinfo.sh
+++ b/libgo/mksysinfo.sh
@@ -403,11 +403,7 @@ fi
 # Some basic types.
 echo 'type Size_t _size_t' >> ${OUT}
 echo "type Ssize_t _ssize_t" >> ${OUT}
-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
-  echo "type Offset_t _off64_t" >> ${OUT}
-else
-  echo "type Offset_t _off_t" >> ${OUT}
-fi
+echo "type Offset_t _libgo_off_t_type" >> ${OUT}
 echo "type Mode_t _mode_t" >> ${OUT}
 echo "type Pid_t _pid_t" >> ${OUT}
 echo "type Uid_t _uid_t" >> ${OUT}
diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index 8ce061e2f5f..a4259c02ded 100644
--- a/libgo/sysinfo.c
+++ b/libgo/sysinfo.c
@@ -357,6 +357,18 @@ enum {
 };
 #endif
 
+#if defined(HAVE_LOFF_T)
+// loff_t can be defined as a macro; for -fgo-dump-spec make sure we
+// see a typedef.
+typedef loff_t libgo_loff_t_type;
+#endif
+
+#if defined(HAVE_OFF64_T)
+typedef off64_t libgo_off_t_type;
+#else
+typedef off_t libgo_off_t_type;
+#endif
+
 // The following section introduces explicit references to types and
 // constants of interest to support bootstrapping libgo using a
 // compiler that doesn't support -fdump-go-spec (e.g., clang), via
@@ -537,7 +549,8 @@ SREF(timex);
 // From sys/types.h
 TREF(pid_t);
 TREF(off_t);
-TREF(loff_t);
+TREF(libgo_loff_t_type);
+TREF(libgo_off_t_type);
 TREF(size_t);
 TREF(ssize_t);
 TREF(mode_t);

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-06-17 21:27           ` Ian Lance Taylor
@ 2022-06-18  7:18             ` Andreas Schwab
  2022-06-18 15:28               ` Ian Lance Taylor
  0 siblings, 1 reply; 17+ messages in thread
From: Andreas Schwab @ 2022-06-18  7:18 UTC (permalink / raw)
  To: Ian Lance Taylor via Gcc-patches
  Cc: Sören Tempel, Ian Lance Taylor, gofrontend-dev

../../../libgo/go/syscall/libcall_linux.go:220:25: error: reference to undefined name '_libgo_loff_t_type'
  220 |                 lroff = _libgo_loff_t_type(*roff)
      |                         ^
../../../libgo/go/syscall/libcall_linux.go:226:25: error: reference to undefined name '_libgo_loff_t_type'
  226 |                 lwoff = _libgo_loff_t_type(*woff)
      |                         ^
../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
  217 |         var lroff _libgo_loff_t_type
      |                   ^
../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
make[4]: *** [Makefile:3038: syscall.lo] Error 1

From config.log:

configure:15552: checking for loff_t
configure:15552: /opt/gcc/gcc-20220618/Build/./gcc/xgcc -B/opt/gcc/gcc-20220618/Build/./gcc/ -B/usr/aarch64-suse-linux/bin/ -B/usr/aarch64-suse-linux/lib/ -isystem /usr/aarch64-suse-linux/include -isystem /usr/aarch64-suse-linux/sys-include    -c -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g  conftest.c >&5
conftest.c: In function 'main':
conftest.c:104:13: error: 'loff_t' undeclared (first use in this function); did you mean 'off_t'?
  104 | if (sizeof (loff_t))
      |             ^~~~~~
      |             off_t
conftest.c:104:13: note: each undeclared identifier is reported only once for each function it appears in
configure:15552: $? = 1

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-06-18  7:18             ` Andreas Schwab
@ 2022-06-18 15:28               ` Ian Lance Taylor
  2022-06-18 15:59                 ` Andreas Schwab
  0 siblings, 1 reply; 17+ messages in thread
From: Ian Lance Taylor @ 2022-06-18 15:28 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Ian Lance Taylor via Gcc-patches, gofrontend-dev, Sören Tempel

On Sat, Jun 18, 2022 at 12:19 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> ../../../libgo/go/syscall/libcall_linux.go:220:25: error: reference to undefined name '_libgo_loff_t_type'
>   220 |                 lroff = _libgo_loff_t_type(*roff)
>       |                         ^
> ../../../libgo/go/syscall/libcall_linux.go:226:25: error: reference to undefined name '_libgo_loff_t_type'
>   226 |                 lwoff = _libgo_loff_t_type(*woff)
>       |                         ^
> ../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
>   217 |         var lroff _libgo_loff_t_type
>       |                   ^
> ../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
> ../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
> ../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
> ../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
> ../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
> ../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
> ../../../libgo/go/syscall/libcall_linux.go:217:19: error: use of undefined type '_libgo_loff_t_type'
> make[4]: *** [Makefile:3038: syscall.lo] Error 1
>
> From config.log:
>
> configure:15552: checking for loff_t
> configure:15552: /opt/gcc/gcc-20220618/Build/./gcc/xgcc -B/opt/gcc/gcc-20220618/Build/./gcc/ -B/usr/aarch64-suse-linux/bin/ -B/usr/aarch64-suse-linux/lib/ -isystem /usr/aarch64-suse-linux/include -isystem /usr/aarch64-suse-linux/sys-include    -c -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g  conftest.c >&5
> conftest.c: In function 'main':
> conftest.c:104:13: error: 'loff_t' undeclared (first use in this function); did you mean 'off_t'?
>   104 | if (sizeof (loff_t))
>       |             ^~~~~~
>       |             off_t
> conftest.c:104:13: note: each undeclared identifier is reported only once for each function it appears in
> configure:15552: $? = 1


What target?

What is the output of

grep loff_t TARGET/libgo/gen-sysinfo.go

?

Thanks.

Ian

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-06-18 15:28               ` Ian Lance Taylor
@ 2022-06-18 15:59                 ` Andreas Schwab
  2022-06-20  7:39                   ` Eric Botcazou
  2022-06-21 15:03                   ` Ian Lance Taylor
  0 siblings, 2 replies; 17+ messages in thread
From: Andreas Schwab @ 2022-06-18 15:59 UTC (permalink / raw)
  To: Ian Lance Taylor
  Cc: Ian Lance Taylor via Gcc-patches, gofrontend-dev, Sören Tempel

On Jun 18 2022, Ian Lance Taylor wrote:

> What target?

aarch64-suse-linux, of course.

> What is the output of
>
> grep loff_t TARGET/libgo/gen-sysinfo.go

type ___loff_t int64
type _loff_t int64
type ___kernel_loff_t int64

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-06-18 15:59                 ` Andreas Schwab
@ 2022-06-20  7:39                   ` Eric Botcazou
  2022-06-21  7:34                     ` Sören Tempel
  2022-06-21 15:03                   ` Ian Lance Taylor
  1 sibling, 1 reply; 17+ messages in thread
From: Eric Botcazou @ 2022-06-20  7:39 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Ian Lance Taylor, gcc-patches, Sören Tempel, gofrontend-dev

> aarch64-suse-linux, of course.

Likewise on x86_64-suse-linux.

> > What is the output of
> > 
> > grep loff_t TARGET/libgo/gen-sysinfo.go
> 
> type ___loff_t int64
> type _loff_t int64
> type ___kernel_loff_t int64

Ditto.

-- 
Eric Botcazou



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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-06-20  7:39                   ` Eric Botcazou
@ 2022-06-21  7:34                     ` Sören Tempel
  2022-06-21 12:26                       ` Franz Sirl
  0 siblings, 1 reply; 17+ messages in thread
From: Sören Tempel @ 2022-06-21  7:34 UTC (permalink / raw)
  To: Eric Botcazou
  Cc: Andreas Schwab, Ian Lance Taylor, gcc-patches, gofrontend-dev

Hi,

The problem is: glibc defines loff_t in sys/types.h, not fcntl.h (where musl
defines it). I falsely assumed that the newly committed AC_CHECK_TYPES
invocation would include fcntl.h *in addition to* AC_INCLUDES_DEFAULT.
However, as it turns out specifying includes for AC_CHECK_TYPES overwrites the
default instead of appending to it.

The patch below should fix this by appending to AC_INCLUDES_DEFAULT explicitly.
Alternatively, we could try to add fcntl.h to AC_INCLUDES_DEFAULT, though my
autotools knowledge is severely limited and hence I am not sure how this would
be achieved.

diff --git a/libgo/configure b/libgo/configure
index b7ff9b3..273af1d 100755
--- a/libgo/configure
+++ b/libgo/configure
@@ -15549,8 +15549,10 @@ fi

 CFLAGS_hold="$CFLAGS"
 CFLAGS="$OSCFLAGS $CFLAGS"
-ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "#include <fcntl.h>
-"
+ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "
+$ac_includes_default
+#include <fcntl.h>
+ "
 if test "x$ac_cv_type_loff_t" = xyes; then :

 cat >>confdefs.h <<_ACEOF
diff --git a/libgo/configure.ac b/libgo/configure.ac
index bac58b0..b237392 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -604,7 +604,9 @@ AC_TYPE_OFF_T

 CFLAGS_hold="$CFLAGS"
 CFLAGS="$OSCFLAGS $CFLAGS"
-AC_CHECK_TYPES([loff_t], [], [], [[#include <fcntl.h>]])
+AC_CHECK_TYPES([loff_t], [], [], [
+AC_INCLUDES_DEFAULT
+#include <fcntl.h>])
 CFLAGS="$CFLAGS_hold"

 LIBS_hold="$LIBS"

Eric Botcazou <botcazou@adacore.com> wrote:
> > aarch64-suse-linux, of course.
> 
> Likewise on x86_64-suse-linux.
> 
> > > What is the output of
> > > 
> > > grep loff_t TARGET/libgo/gen-sysinfo.go
> > 
> > type ___loff_t int64
> > type _loff_t int64
> > type ___kernel_loff_t int64
> 
> Ditto.

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-06-21  7:34                     ` Sören Tempel
@ 2022-06-21 12:26                       ` Franz Sirl
  0 siblings, 0 replies; 17+ messages in thread
From: Franz Sirl @ 2022-06-21 12:26 UTC (permalink / raw)
  To: Sören Tempel, Eric Botcazou
  Cc: gcc-patches, Andreas Schwab, Ian Lance Taylor, gofrontend-dev

Am 2022-06-21 um 09:34 schrieb Sören Tempel via Gcc-patches:
> Hi,
> 
> The problem is: glibc defines loff_t in sys/types.h, not fcntl.h (where musl
> defines it). I falsely assumed that the newly committed AC_CHECK_TYPES
> invocation would include fcntl.h *in addition to* AC_INCLUDES_DEFAULT.
> However, as it turns out specifying includes for AC_CHECK_TYPES overwrites the
> default instead of appending to it.
> 
> The patch below should fix this by appending to AC_INCLUDES_DEFAULT explicitly.
> Alternatively, we could try to add fcntl.h to AC_INCLUDES_DEFAULT, though my
> autotools knowledge is severely limited and hence I am not sure how this would
> be achieved.
> 
> diff --git a/libgo/configure b/libgo/configure
> index b7ff9b3..273af1d 100755
> --- a/libgo/configure
> +++ b/libgo/configure
> @@ -15549,8 +15549,10 @@ fi
> 
>   CFLAGS_hold="$CFLAGS"
>   CFLAGS="$OSCFLAGS $CFLAGS"
> -ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "#include <fcntl.h>
> -"
> +ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "
> +$ac_includes_default
> +#include <fcntl.h>
> + "
>   if test "x$ac_cv_type_loff_t" = xyes; then :
> 
>   cat >>confdefs.h <<_ACEOF
> diff --git a/libgo/configure.ac b/libgo/configure.ac
> index bac58b0..b237392 100644
> --- a/libgo/configure.ac
> +++ b/libgo/configure.ac
> @@ -604,7 +604,9 @@ AC_TYPE_OFF_T
> 
>   CFLAGS_hold="$CFLAGS"
>   CFLAGS="$OSCFLAGS $CFLAGS"
> -AC_CHECK_TYPES([loff_t], [], [], [[#include <fcntl.h>]])
> +AC_CHECK_TYPES([loff_t], [], [], [
> +AC_INCLUDES_DEFAULT
> +#include <fcntl.h>])
>   CFLAGS="$CFLAGS_hold"
> 
>   LIBS_hold="$LIBS"
> 

Hi,

the patch restores bootstrap for me on x86_64-suse-linux.

Franz.


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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-06-18 15:59                 ` Andreas Schwab
  2022-06-20  7:39                   ` Eric Botcazou
@ 2022-06-21 15:03                   ` Ian Lance Taylor
  2022-06-21 15:16                     ` Andreas Schwab
  1 sibling, 1 reply; 17+ messages in thread
From: Ian Lance Taylor @ 2022-06-21 15:03 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Sören Tempel, Ian Lance Taylor via Gcc-patches, gofrontend-dev

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

On Sat, Jun 18, 2022 at 8:59 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Jun 18 2022, Ian Lance Taylor wrote:
>
> > What target?
>
> aarch64-suse-linux, of course.

Thanks.  Sorry for missing that.


> > What is the output of
> >
> > grep loff_t TARGET/libgo/gen-sysinfo.go
>
> type ___loff_t int64
> type _loff_t int64
> type ___kernel_loff_t int64

Hmmm, it does work as expected on gcc114 in the GCC compile farm,
which seems to be Linux 3.13 and glibc 4.8.4.  On that system I see

> grep loff_t aarch64-unknown-linux-gnu/libgo/gen-sysinfo.go
type ___loff_t int64
type _loff_t int64
type ___kernel_loff_t int64
type _libgo_loff_t_type int64

Still, I may see the problem.  I've committed this patch that should fix it.

Ian

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1283 bytes --]

7afe467c665bba27574a183dad5c00f2c0f676e1
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 4b75dd37355..737bc483274 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-a409e049737ec9a358a19233e017d957db3d6d2a
+77821de1a149c2e6ef9c154ae384c16292173039
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/configure b/libgo/configure
index b7ff9b32867..61a49947eb9 100755
--- a/libgo/configure
+++ b/libgo/configure
@@ -15549,7 +15549,10 @@ fi
 
 CFLAGS_hold="$CFLAGS"
 CFLAGS="$OSCFLAGS $CFLAGS"
-ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "#include <fcntl.h>
+ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "
+#include <sys/types.h>
+#include <fcntl.h>
+
 "
 if test "x$ac_cv_type_loff_t" = xyes; then :
 
diff --git a/libgo/configure.ac b/libgo/configure.ac
index bac58b07b41..274fcfc35c7 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -604,7 +604,10 @@ AC_TYPE_OFF_T
 
 CFLAGS_hold="$CFLAGS"
 CFLAGS="$OSCFLAGS $CFLAGS"
-AC_CHECK_TYPES([loff_t], [], [], [[#include <fcntl.h>]])
+AC_CHECK_TYPES([loff_t], [], [], [[
+#include <sys/types.h>
+#include <fcntl.h>
+]])
 CFLAGS="$CFLAGS_hold"
 
 LIBS_hold="$LIBS"

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-06-21 15:03                   ` Ian Lance Taylor
@ 2022-06-21 15:16                     ` Andreas Schwab
  2022-06-21 16:53                       ` Ian Lance Taylor
  0 siblings, 1 reply; 17+ messages in thread
From: Andreas Schwab @ 2022-06-21 15:16 UTC (permalink / raw)
  To: Ian Lance Taylor via Gcc-patches
  Cc: Ian Lance Taylor, gofrontend-dev, Sören Tempel

On Jun 21 2022, Ian Lance Taylor via Gcc-patches wrote:

> which seems to be Linux 3.13 and glibc 4.8.4.  On that system I see

That's stone age.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc
  2022-06-21 15:16                     ` Andreas Schwab
@ 2022-06-21 16:53                       ` Ian Lance Taylor
  0 siblings, 0 replies; 17+ messages in thread
From: Ian Lance Taylor @ 2022-06-21 16:53 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Ian Lance Taylor via Gcc-patches, Sören Tempel, gofrontend-dev

On Tue, Jun 21, 2022 at 8:16 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Jun 21 2022, Ian Lance Taylor via Gcc-patches wrote:
>
> > which seems to be Linux 3.13 and glibc 4.8.4.  On that system I see
>
> That's stone age.

I don't know who maintains these systems on the GCC compile farm.

Ian

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

end of thread, other threads:[~2022-06-21 16:53 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-24 10:17 [PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc soeren
2022-05-07 11:18 ` Sören Tempel
2022-05-09 23:33 ` [PATCH] " Ian Lance Taylor
2022-05-12 18:22   ` Sören Tempel
2022-05-12 21:04     ` Ian Lance Taylor
2022-05-18  7:22       ` Sören Tempel
2022-05-31 19:41         ` Sören Tempel
2022-06-17 21:27           ` Ian Lance Taylor
2022-06-18  7:18             ` Andreas Schwab
2022-06-18 15:28               ` Ian Lance Taylor
2022-06-18 15:59                 ` Andreas Schwab
2022-06-20  7:39                   ` Eric Botcazou
2022-06-21  7:34                     ` Sören Tempel
2022-06-21 12:26                       ` Franz Sirl
2022-06-21 15:03                   ` Ian Lance Taylor
2022-06-21 15:16                     ` Andreas Schwab
2022-06-21 16:53                       ` Ian Lance Taylor

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