[Lldb-commits] [lldb] [NFCI][lldb][test] Enable GNU POSIX extensions where necessary (PR #166768)

Raul Tambre via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 6 05:11:46 PST 2025


https://github.com/tambry created https://github.com/llvm/llvm-project/pull/166768

Otherwise these tests are reliant on the compiler defaulting to having the extensions on. Rest of LLVM's codebase doesn't seem to make such assumptions.

Tested by building with `-std=c2y` in Clang's C frotend's config file.

>From 8f553e79f33c84aad0c177b88620b6b7f2a296f4 Mon Sep 17 00:00:00 2001
From: Raul Tambre <raul at tambre.ee>
Date: Thu, 6 Nov 2025 15:06:44 +0200
Subject: [PATCH] [NFCI][lldb][test] Enable GNU POSIX extensions where
 necessary

Otherwise these tests are reliant on the compiler defaulting to having the extensions on.
Rest of LLVM's codebase doesn't seem to make such assumptions.

Tested by building with `-std=c2y` in Clang's C frotend's config file.
---
 .../API/commands/expression/call-restarts/lotta-signals.c | 8 ++++++--
 lldb/test/API/driver/quit_speed/main.c                    | 4 ++++
 lldb/test/API/functionalities/process_group/main.c        | 4 ++++
 lldb/test/API/lang/c/tls_globals/a.c                      | 4 ++++
 lldb/test/API/lang/c/tls_globals/main.c                   | 5 ++++-
 lldb/test/Shell/Commands/Inputs/sigchld.c                 | 4 ++++
 .../Commands/command-list-reach-beginning-of-file.test    | 4 ++--
 7 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/lldb/test/API/commands/expression/call-restarts/lotta-signals.c b/lldb/test/API/commands/expression/call-restarts/lotta-signals.c
index f5c15b41e2de3..149ceb787f707 100644
--- a/lldb/test/API/commands/expression/call-restarts/lotta-signals.c
+++ b/lldb/test/API/commands/expression/call-restarts/lotta-signals.c
@@ -1,3 +1,7 @@
+#if defined(__linux__)
+#define _DEFAULT_SOURCE /* for kill(), usleep() and GNU's signal() */
+#endif
+
 #include <unistd.h>
 #include <stdio.h>
 #include <signal.h>
@@ -46,12 +50,12 @@ call_me_nosig (int some_value)
   return some_value;
 }
 
-int 
+int
 main ()
 {
   int ret_val;
   signal (SIGCHLD, sigchld_handler);
-  
+
   ret_val = call_me (2);  // Stop here in main.
 
   ret_val = call_me_nosig (10);
diff --git a/lldb/test/API/driver/quit_speed/main.c b/lldb/test/API/driver/quit_speed/main.c
index 3d6d45ce5e806..95e4de911ccfa 100644
--- a/lldb/test/API/driver/quit_speed/main.c
+++ b/lldb/test/API/driver/quit_speed/main.c
@@ -1,3 +1,7 @@
+#if defined(__linux__)
+#define _XOPEN_SOURCE 500 /* for usleep() */
+#endif
+
 #include <unistd.h>
 
 int main (int argc, char **argv) {
diff --git a/lldb/test/API/functionalities/process_group/main.c b/lldb/test/API/functionalities/process_group/main.c
index b4d5abc58169c..75c2b41351c3e 100644
--- a/lldb/test/API/functionalities/process_group/main.c
+++ b/lldb/test/API/functionalities/process_group/main.c
@@ -1,3 +1,7 @@
+#if defined(__linux__)
+#define _XOPEN_SOURCE 500 /* for getpgid() */
+#endif
+
 #include "attach.h"
 #include <stdio.h>
 #include <sys/wait.h>
diff --git a/lldb/test/API/lang/c/tls_globals/a.c b/lldb/test/API/lang/c/tls_globals/a.c
index f63108d8cceb1..16bfeaeca0a78 100644
--- a/lldb/test/API/lang/c/tls_globals/a.c
+++ b/lldb/test/API/lang/c/tls_globals/a.c
@@ -1,3 +1,7 @@
+#if defined(__linux__)
+#define _XOPEN_SOURCE 500 /* for usleep() */
+#endif
+
 #include <unistd.h>
 
 __thread int var_shared = 33;
diff --git a/lldb/test/API/lang/c/tls_globals/main.c b/lldb/test/API/lang/c/tls_globals/main.c
index fac760b350ab2..e6a6d3c868462 100644
--- a/lldb/test/API/lang/c/tls_globals/main.c
+++ b/lldb/test/API/lang/c/tls_globals/main.c
@@ -1,4 +1,7 @@
-#include <stdio.h>
+#if defined(__linux__)
+#define _XOPEN_SOURCE 500 /* for usleep() */
+#endif
+
 #include <pthread.h>
 #include <unistd.h>
 
diff --git a/lldb/test/Shell/Commands/Inputs/sigchld.c b/lldb/test/Shell/Commands/Inputs/sigchld.c
index ba8c5ef45365b..0121e70c1bdd0 100644
--- a/lldb/test/Shell/Commands/Inputs/sigchld.c
+++ b/lldb/test/Shell/Commands/Inputs/sigchld.c
@@ -1,3 +1,7 @@
+#if defined(__linux__)
+#define _XOPEN_SOURCE 500 /* for CLD_EXITED */
+#endif
+
 #include <assert.h>
 #include <signal.h>
 #include <stdio.h>
diff --git a/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
index fa4a93e5904aa..9987efedd8020 100644
--- a/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
+++ b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
@@ -4,7 +4,7 @@
 # RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
 
 list
-# CHECK: note: No source available 
+# CHECK: note: No source available
 
 b main
 # CHECK: Breakpoint 1:
@@ -18,7 +18,7 @@ list
 list -
 # CHECK: int main()
 
-list -10
+list -13
 # CHECK: #include <assert.h>
 
 list -



More information about the lldb-commits mailing list