public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libgo: Explicitly define SYS_timer_settime for 32-bit musl targets
@ 2022-07-28 18:14 soeren
  2022-07-30 17:35 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: soeren @ 2022-07-28 18:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: gofrontend-dev, iant

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

On 32-bit systems, musl only defines SYS_timer_settime32 not
SYS_timer_settime. This causes the following compilation error:

            os_linux.go:251:30: error: reference to undefined name '_SYS_timer_settime'
              251 |         return int32(syscall(_SYS_timer_settime, uintptr(timerid), uintptr(flags), uintptr(unsafe.Pointer(new)), uintptr(unsafe.Pointer(old)), 0, 0))
                  |                              ^

This commit fixes this error by "aliasing" SYS_timer_settime to
SYS_timer_settime32 if the latter is defined. This is also what
musl does internally [1].

[1]: https://git.musl-libc.org/cgit/musl/tree/src/internal/syscall.h?h=v1.2.3#n212
---
 libgo/sysinfo.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index fc021099..6848fba5 100644
--- a/libgo/sysinfo.c
+++ b/libgo/sysinfo.c
@@ -354,6 +354,12 @@ enum {
 };
 #endif
 
+// musl libc does not have SYS_timer_settime on 32-bit platforms
+// but defines SYS_timer_settime32 instead, alias accordingly.
+#ifdef SYS_timer_settime32
+#define SYS_timer_settime SYS_timer_settime32
+#endif
+
 #if defined(HAVE_LOFF_T)
 // loff_t can be defined as a macro; for -fgo-dump-spec make sure we
 // see a typedef.

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

* Re: [PATCH] libgo: Explicitly define SYS_timer_settime for 32-bit musl targets
  2022-07-28 18:14 [PATCH] libgo: Explicitly define SYS_timer_settime for 32-bit musl targets soeren
@ 2022-07-30 17:35 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2022-07-30 17:35 UTC (permalink / raw)
  To: soeren; +Cc: gcc-patches, gofrontend-dev

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

On Thu, Jul 28, 2022 at 11:15 AM <soeren@soeren-tempel.net> wrote:
>
> From: Sören Tempel <soeren+git@soeren-tempel.net>
>
> On 32-bit systems, musl only defines SYS_timer_settime32 not
> SYS_timer_settime. This causes the following compilation error:
>
>             os_linux.go:251:30: error: reference to undefined name '_SYS_timer_settime'
>               251 |         return int32(syscall(_SYS_timer_settime, uintptr(timerid), uintptr(flags), uintptr(unsafe.Pointer(new)), uintptr(unsafe.Pointer(old)), 0, 0))
>                   |                              ^
>
> This commit fixes this error by "aliasing" SYS_timer_settime to
> SYS_timer_settime32 if the latter is defined. This is also what
> musl does internally [1].

Committed a slight variant of this, as appended.

Ian

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

f40686b01bdabba051e3b22165bb576e45ffca74
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 2f2fafde1f1..ca797045d66 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-a62f20ae78ddd41be682dde8cab075ca4f5dbb2a
+d53e8a0e94e34dc609e34dd5e404debda2640cfb
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index fc0210992fa..180f5c31d74 100644
--- a/libgo/sysinfo.c
+++ b/libgo/sysinfo.c
@@ -354,6 +354,11 @@ enum {
 };
 #endif
 
+#if !defined(SYS_timer_settime) && defined(SYS_timer_settime32)
+// musl defines SYS_timer_settim32 on 32-bit systems.
+#define SYS_timer_settime SYS_timer_settime32
+#endif
+
 #if defined(HAVE_LOFF_T)
 // loff_t can be defined as a macro; for -fgo-dump-spec make sure we
 // see a typedef.

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

end of thread, other threads:[~2022-07-30 17:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-28 18:14 [PATCH] libgo: Explicitly define SYS_timer_settime for 32-bit musl targets soeren
2022-07-30 17:35 ` 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).