tools/lib: Use -std=gnu11

From: Sedat Dilek

Date: Sun Nov 02 2025 - 11:10:36 EST


Hi,

I am carrying these patches since Arnd made the switch-over to -std=gnu11.

Background was building perf with -std=gnu11.

Refreshed to fit Linux v6.17 and patch-series attached:

0001-tools-libapi-Use-std-gnu11.patch
4:Subject: [PATCH 1/3] tools: libapi: Use -std=gnu11

0002-tools-libbpf-Use-std-gnu11.patch
4:Subject: [PATCH 2/3] tools: libbpf: Use -std=gnu11

0003-tools-libsubcmd-Use-std-gnu11.patch
4:Subject: [PATCH 3/3] tools: libsubcmd: Use -std=gnu11

perf below changed to -std=gnu11 sometimes - that was my 4th patch in series.

OK, tools build-eco-system is different...

We have other places below tools/ directory not using -std=gnu11.

What do you think - comments?

Best thanks and regards,
-Sedat-

P.S.: It looks like there should be an agreement also for -std=gnu++X
(we have X=11 and X=17) in tools-dir.

$ git checkout Linux-v6.17.6

$ head -5 Makefile
# SPDX-License-Identifier: GPL-2.0
VERSION = 6
PATCHLEVEL = 17
SUBLEVEL = 6
EXTRAVERSION =

$ git grep std=gnu tools/ | grep -v 'std=gnu\+\+|std=gnu11' | grep -v
testing | grep -v usbip
tools/lib/api/Makefile:CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99
-U_FORTIFY_SOURCE -fPIC
tools/lib/bpf/Makefile:override CFLAGS += -std=gnu89
tools/lib/subcmd/Makefile:CFLAGS := -ggdb3 -Wall -Wextra -std=gnu99 -fPIC
From c30127be5dadd38d3b032c90efc35fda97e61ba9 Mon Sep 17 00:00:00 2001
From: Sedat Dilek <sedat.dilek@xxxxxxxxx>
Date: Tue, 15 Oct 2024 10:18:43 +0200
Subject: [PATCH 1/3] tools: libapi: Use -std=gnu11

Signed-off-by: Sedat Dilek <sedat.dilek@xxxxxxxxx>
---
tools/lib/api/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile
index 8665c799e0fa..1def673f6925 100644
--- a/tools/lib/api/Makefile
+++ b/tools/lib/api/Makefile
@@ -28,7 +28,7 @@ DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
LIBFILE = $(OUTPUT)libapi.a

CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
-CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -fPIC
+CFLAGS += -ggdb3 -Wall -Wextra -std=gnu11 -U_FORTIFY_SOURCE -fPIC

ifeq ($(DEBUG),0)
CFLAGS += -O3
--
2.51.2

From 1974c5ce403e6b271dba220b6327168e14e6fe2b Mon Sep 17 00:00:00 2001
From: Sedat Dilek <sedat.dilek@xxxxxxxxx>
Date: Fri, 4 Mar 2022 19:34:31 +0100
Subject: [PATCH 2/3] tools: libbpf: Use -std=gnu11

Signed-off-by: Sedat Dilek <sedat.dilek@xxxxxxxxx>
---
tools/lib/bpf/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index 168140f8e646..a68786799f02 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -78,7 +78,7 @@ else
endif

# Append required CFLAGS
-override CFLAGS += -std=gnu89
+override CFLAGS += -std=gnu11
override CFLAGS += $(EXTRA_WARNINGS) -Wno-switch-enum
override CFLAGS += -Werror -Wall
override CFLAGS += $(INCLUDES)
--
2.51.2

From f5eb492d9a4d7960a47375407910c995c6a09f65 Mon Sep 17 00:00:00 2001
From: Sedat Dilek <sedat.dilek@xxxxxxxxx>
Date: Sat, 5 Mar 2022 03:55:49 +0100
Subject: [PATCH 3/3] tools: libsubcmd: Use -std=gnu11

Signed-off-by: Sedat Dilek <sedat.dilek@xxxxxxxxx>
---
tools/lib/subcmd/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/subcmd/Makefile b/tools/lib/subcmd/Makefile
index 8703ab487b68..5a4a63693a29 100644
--- a/tools/lib/subcmd/Makefile
+++ b/tools/lib/subcmd/Makefile
@@ -28,7 +28,7 @@ DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'

LIBFILE = $(OUTPUT)libsubcmd.a

-CFLAGS := -ggdb3 -Wall -Wextra -std=gnu99 -fPIC
+CFLAGS := -ggdb3 -Wall -Wextra -std=gnu11 -fPIC

ifeq ($(DEBUG),0)
ifeq ($(feature-fortify-source), 1)
--
2.51.2