public inbox for gwml@vger.gnuweeb.org
 help / color / mirror / Atom feed
* [PATCH gwproxy v1 0/2] Fixes for older glibc version
@ 2025-07-31 22:05 Alviro Iskandar Setiawan
  2025-07-31 22:05 ` [PATCH gwproxy v1 1/2] log: Fix missing `gettid()` syscall on " Alviro Iskandar Setiawan
  2025-07-31 22:05 ` [PATCH gwproxy v1 2/2] configure: Append `-lanl` lib to fix missing `getaddrinfo_a()` Alviro Iskandar Setiawan
  0 siblings, 2 replies; 5+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-31 22:05 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: Alviro Iskandar Setiawan, GNU/Weeb Mailing List

Good morning!

Two patches to fix issues with older glibc version, specifically
glibc version 2.28 which is the default on AlmaLinux-8.

  GNU CC version 8.5.0 20210514 (Red Hat 8.5.0-26) with glibc version 2.28.

Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---

Alviro Iskandar Setiawan (2):
  log: Fix missing `gettid()` syscall on older glibc version
  configure: Append `-lanl` lib to fix missing `getaddrinfo_a()`

 Makefile          | 2 +-
 configure         | 6 +++---
 src/gwproxy/log.c | 8 +++++++-
 3 files changed, 11 insertions(+), 5 deletions(-)


base-commit: f897120d186dcf609d025c48be0be9f044b2b46b
-- 
Alviro Iskandar Setiawan


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

* [PATCH gwproxy v1 1/2] log: Fix missing `gettid()` syscall on older glibc version
  2025-07-31 22:05 [PATCH gwproxy v1 0/2] Fixes for older glibc version Alviro Iskandar Setiawan
@ 2025-07-31 22:05 ` Alviro Iskandar Setiawan
  2025-07-31 22:17   ` Ammar Faizi
  2025-07-31 22:05 ` [PATCH gwproxy v1 2/2] configure: Append `-lanl` lib to fix missing `getaddrinfo_a()` Alviro Iskandar Setiawan
  1 sibling, 1 reply; 5+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-31 22:05 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: Alviro Iskandar Setiawan, GNU/Weeb Mailing List

Compiling on GNU CC version 8.5.0 20210514 (Red Hat 8.5.0-26) with
glibc version 2.28 throws this error:

  src/gwproxy/log.c: In function ‘__pr_log’:
  src/gwproxy/log.c:51:56: warning: implicit declaration of function ‘gettid’; \
                                    did you mean ‘getgid’? [-Wimplicit-function-declaration]
    fprintf(handle, "[%s][%s][%08d]: %s\n", time_buf, ls, gettid(), pb);
                                                          ^~~~~~
                                                          getgid
  src/gwproxy/log.c:51: undefined reference to `gettid'
  collect2: error: ld returned 1 exit status

Fix it by defining our own `__sys_gettid()`.

Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
 src/gwproxy/log.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gwproxy/log.c b/src/gwproxy/log.c
index 95d1930..574c5e0 100644
--- a/src/gwproxy/log.c
+++ b/src/gwproxy/log.c
@@ -1,5 +1,6 @@
 #include <gwproxy/common.h>
 #include <gwproxy/log.h>
+#include <gwproxy/syscall.h>
 #include <time.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -7,6 +8,11 @@
 #include <unistd.h>
 #include <stdarg.h>
 
+static inline pid_t __sys_gettid(void)
+{
+	return (pid_t)__do_syscall0(__NR_gettid);
+}
+
 __attribute__((__format__(printf, 3, 4)))
 void __pr_log(FILE *handle, int level, const char *fmt, ...)
 {
@@ -48,7 +54,7 @@ void __pr_log(FILE *handle, int level, const char *fmt, ...)
 	else
 		time_buf[0] = '\0';
 
-	fprintf(handle, "[%s][%s][%08d]: %s\n", time_buf, ls, gettid(), pb);
+	fprintf(handle, "[%s][%s][%08d]: %s\n", time_buf, ls, __sys_gettid(), pb);
 	if (unlikely(pb != loc_buf))
 		free(pb);
 out:
-- 
Alviro Iskandar Setiawan


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

* [PATCH gwproxy v1 2/2] configure: Append `-lanl` lib to fix missing `getaddrinfo_a()`
  2025-07-31 22:05 [PATCH gwproxy v1 0/2] Fixes for older glibc version Alviro Iskandar Setiawan
  2025-07-31 22:05 ` [PATCH gwproxy v1 1/2] log: Fix missing `gettid()` syscall on " Alviro Iskandar Setiawan
@ 2025-07-31 22:05 ` Alviro Iskandar Setiawan
  1 sibling, 0 replies; 5+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-31 22:05 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: Alviro Iskandar Setiawan, GNU/Weeb Mailing List

Compiling on GNU CC version 8.5.0 20210514 (Red Hat 8.5.0-26) with
glibc version 2.28 throws this error:

  undefined reference to `getaddrinfo_a'

As such, `getaddrinfo_a()` is never used in that environment eventhough
it's available. Append `-lanl` if on `getaddrinfo_a()` check.

Also, fix the warning about `_GNU_SOURCE` being redefined in the
`configure` script.

Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
 Makefile  | 2 +-
 configure | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index d0d6d85..6c2e9be 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,6 @@ ifndef OPTIMIZE
 	OPTIMIZE = -O2
 endif
 INCLUDE_FLAGS = -I./src/
-LIBS = -lpthread
 DEPFLAGS = -MMD -MP -MF $@.d
 LDFLAGS_SHARED = $(LDFLAGS) -shared
 GWPROXY_DIR = ./src/gwproxy
@@ -80,6 +79,7 @@ config.make: configure
 endif
 endif
 -include config.make
+LIBS=$(LIB_LDFLAGS)
 
 ifeq ($(CONFIG_IO_URING),y)
 	GWPROXY_CC_SOURCES += $(GWPROXY_DIR)/ev/io_uring.c
diff --git a/configure b/configure
index 0b5815d..17bdf6f 100755
--- a/configure
+++ b/configure
@@ -356,20 +356,20 @@ fi;
 
 # ------ Check for getaddrinfo_a() ------
 cat > $tmp_c << EOF
-#define _GNU_SOURCE
 #include <netdb.h>
 int main(void)
 {
 	struct sigevent ev;
-	struct gaicb gc;
+	struct gaicb *gc = (void *)0;
 	getaddrinfo_a(GAI_NOWAIT, &gc, 1, &ev);
 	return 0;
 }
 EOF
 l="Do we have getaddrinfo_a()?";
-if compile_cc "" "" "getaddrinfo_a()"; then
+if compile_cc "" "-lanl" "getaddrinfo_a()"; then
 	add_config "CONFIG_HAVE_GETADDRINFO_A";
 	print_supp "yes" "${l}";
+	LIB_LDFLAGS="${LIB_LDFLAGS} -lanl";
 else
 	print_supp "no" "${l}";
 fi;
-- 
Alviro Iskandar Setiawan


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

* Re: [PATCH gwproxy v1 1/2] log: Fix missing `gettid()` syscall on older glibc version
  2025-07-31 22:05 ` [PATCH gwproxy v1 1/2] log: Fix missing `gettid()` syscall on " Alviro Iskandar Setiawan
@ 2025-07-31 22:17   ` Ammar Faizi
  2025-07-31 22:20     ` Alviro Iskandar Setiawan
  0 siblings, 1 reply; 5+ messages in thread
From: Ammar Faizi @ 2025-07-31 22:17 UTC (permalink / raw)
  To: Alviro Iskandar Setiawan; +Cc: GNU/Weeb Mailing List

On Fri, Aug 01, 2025 at 05:05:45AM +0700, Alviro Iskandar Setiawan wrote:
> diff --git a/src/gwproxy/log.c b/src/gwproxy/log.c
> index 95d1930..574c5e0 100644
> --- a/src/gwproxy/log.c
> +++ b/src/gwproxy/log.c
> @@ -1,5 +1,6 @@
>  #include <gwproxy/common.h>
>  #include <gwproxy/log.h>
> +#include <gwproxy/syscall.h>
>  #include <time.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> @@ -7,6 +8,11 @@
>  #include <unistd.h>
>  #include <stdarg.h>
>  
> +static inline pid_t __sys_gettid(void)
> +{
> +	return (pid_t)__do_syscall0(__NR_gettid);
> +}

You can't use __do_syscall0() macro because it's only defined on
x86-64. This breaks powerpc64 build and other architectures:

  src/gwproxy/log.c: In function ‘__sys_gettid’:
  src/gwproxy/log.c:13:23: warning: implicit declaration of function ‘__do_syscall0’ [-Wimplicit-function-declaration]
     13 |         return (pid_t)__do_syscall0(__NR_gettid);
        |                       ^~~~~~~~~~~~~

-- 
Ammar Faizi


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

* Re: [PATCH gwproxy v1 1/2] log: Fix missing `gettid()` syscall on older glibc version
  2025-07-31 22:17   ` Ammar Faizi
@ 2025-07-31 22:20     ` Alviro Iskandar Setiawan
  0 siblings, 0 replies; 5+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-31 22:20 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: GNU/Weeb Mailing List

On Fri, Aug 1, 2025 at 5:18 AM Ammar Faizi wrote:
> You can't use __do_syscall0() macro because it's only defined on
> x86-64. This breaks powerpc64 build and other architectures:
>
>   src/gwproxy/log.c: In function ‘__sys_gettid’:
>   src/gwproxy/log.c:13:23: warning: implicit declaration of function ‘__do_syscall0’ [-Wimplicit-function-declaration]
>      13 |         return (pid_t)__do_syscall0(__NR_gettid);
>         |                       ^~~~~~~~~~~~~

ic ic, I wasn't aware of that. I will define __sys_gettid() in syscall.h then.

-- Viro

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

end of thread, other threads:[~2025-07-31 22:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-31 22:05 [PATCH gwproxy v1 0/2] Fixes for older glibc version Alviro Iskandar Setiawan
2025-07-31 22:05 ` [PATCH gwproxy v1 1/2] log: Fix missing `gettid()` syscall on " Alviro Iskandar Setiawan
2025-07-31 22:17   ` Ammar Faizi
2025-07-31 22:20     ` Alviro Iskandar Setiawan
2025-07-31 22:05 ` [PATCH gwproxy v1 2/2] configure: Append `-lanl` lib to fix missing `getaddrinfo_a()` Alviro Iskandar Setiawan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox