tools feature gettid: Undef _GNU_SOURCE before defining it
PATCH 1/1 tools feature gettid: Undef _GNU_SOURCE before defining it
Since most of tools/build/feature/test-*.c feature tests are included in tools/build/feature/test-all.c, we can't just define _GNU_SOURCE as it may already been defined and this will break the build with:
acme@alta:~$ cat /tmp/build/perf-tools-next/feature/test-all.make.output
In file included from test-all.c:26:
test-gettid.c:3:9: error: "_GNU_SOURCE" redefined [-Werror]
3 | #define _GNU_SOURCE
| ^~~~~~~~~~~
In file included from /usr/include/python3.13/pyconfig.h:9,
from /usr/include/python3.13/Python.h:14,
from test-python-module.c:2,
from test-all.c:14:
/usr/include/aarch64-linux-gnu/python3.13/pyconfig.h:1810:10: note: this is the location of the previous definition
1810 | # define _GNU_SOURCE 1
| ^~~~~~~~~~~
cc1: all warnings being treated as errors
acme@alta:~$I.e. pyconfig.h is included by the new test-python-module.c, that is at the start of test-all.c, defines _GNU_SOURCE, noticed on Debian 13 (/usr/include/aarch64-linux-gnu/python3.13/pyconfig.h, libpython 3.13.5-2+deb13u5), and then test-all.c includes test-gettid.c that was defining it as well, undef it first as does several other tests.
--- tools/build/feature/test-gettid.c | 1 + 1 file changed, 1 insertion(+)
tools/build/feature/test-gettid.c +1 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 // Copyright (C) 2019, Red Hat Inc, Arnaldo Carvalho de Melo <[email protected]> +#undef _GNU_SOURCE#define _GNU_SOURCE#include <unistd.h>
Signature · 1 line
2.55.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 25 lines
Since most of
tools/build/feature/test-*.cfeature tests are included intools/build/feature/test-all.c, we can't just define_GNU_SOURCEas it may already been defined and this will break the build with:acme@alta:~$ cat /tmp/build/perf-tools-next/feature/test-all.make.output In file included from test-all.c:26: test-gettid.c:3:9: error: "_GNU_SOURCE" redefined [-Werror] 3 | #define _GNU_SOURCE | ^~~~~~~~~~~ In file included from /usr/include/python3.13/pyconfig.h:9, from /usr/include/python3.13/Python.h:14, from test-python-module.c:2, from test-all.c:14: /usr/include/aarch64-linux-gnu/python3.13/pyconfig.h:1810:10: note: this is the location of the previous definition 1810 | # define _GNU_SOURCE 1 | ^~~~~~~~~~~ cc1: all warnings being treated as errors acme@alta:~$I.e.
pyconfig.his included by the newtest-python-module.c, that is at the start oftest-all.c, defines_GNU_SOURCE, noticed on Debian 13 (/usr/include/aarch64-linux-gnu/python3.13/pyconfig.h, libpython 3.13.5-2+deb13u5), and thentest-all.cincludestest-gettid.cthat was defining it as well, undef it first as does several other tests.
Quoted 3 lines
Fixes 1b7e0280e247b93d ("perf Makefile: Update Python script installation path")Cc Ian Rogers <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/arpXYeRUu3B-ouqB@x2?part=1
Quoted 19 lines · Arnaldo Carvalho de Melo
Since most of
tools/build/feature/test-*.cfeature tests are included intools/build/feature/test-all.c, we can't just define_GNU_SOURCEas it may already been defined and this will break the build with:acme@alta:~$ cat /tmp/build/perf-tools-next/feature/test-all.make.output In file included from test-all.c:26: test-gettid.c:3:9: error: "_GNU_SOURCE" redefined [-Werror] 3 | #define _GNU_SOURCE | ^~~~~~~~~~~ In file included from /usr/include/python3.13/pyconfig.h:9, from /usr/include/python3.13/Python.h:14, from test-python-module.c:2, from test-all.c:14: /usr/include/aarch64-linux-gnu/python3.13/pyconfig.h:1810:10: note: this is the location of the previous definition 1810 | # define _GNU_SOURCE 1 | ^~~~~~~~~~~ cc1: all warnings being treated as errors acme@alta:~$
Quoted 4 lines
I.e.
pyconfig.his included by the newtest-python-module.c, that is at the start oftest-all.c, defines_GNU_SOURCE, noticed on Debian 13 (/usr/include/aarch64-linux-gnu/python3.13/pyconfig.h, libpython 3.13.5-2+deb13u5), and thentest-all.cincludestest-gettid.cthat was
Noticed as well on fedora:
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
105: 'import perf' in python : Ok
=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
In file included from test-all.c:26:
test-gettid.c:3:9: error: ‘_GNU_SOURCE’ redefined [-Werror]
3 | #define _GNU_SOURCE
| ^~~~~~~~~~~
In file included from /usr/include/python3.14/pyconfig.h:6,
from /usr/include/python3.14/Python.h:14,
from test-python-module.c:2,
from test-all.c:14:
/usr/include/python3.14/pyconfig-64.h:1879:10: note: this is the location of the previous definition
1879 | # define _GNU_SOURCE 1
| ^~~~~~~~~~~cc1: all warnings being treated as errors
⬢ [acme@toolbx perf-tools-next]$ head /etc/os-release NAME="Fedora Linux"
VERSION="44 (Toolbx Container Image)" RELEASE_TYPE=stable
ID=fedora
VERSION_ID=44
VERSION_CODENAME=""
PRETTY_NAME="Fedora Linux 44 (Toolbx Container Image)" ANSI_COLOR="0;38;2;60;110;180" LOGO=fedora-logo-icon CPE_NAME="cpe:/o:fedoraproject:fedora:44"
⬢ [acme@toolbx perf-tools-next]$
Quoted 26 lines · Arnaldo Carvalho de Melo
Since most of
tools/build/feature/test-*.cfeature tests are included intools/build/feature/test-all.c, we can't just define_GNU_SOURCEas it may already been defined and this will break the build with:acme@alta:~$ cat /tmp/build/perf-tools-next/feature/test-all.make.output In file included from test-all.c:26: test-gettid.c:3:9: error: "_GNU_SOURCE" redefined [-Werror] 3 | #define _GNU_SOURCE | ^~~~~~~~~~~ In file included from /usr/include/python3.13/pyconfig.h:9, from /usr/include/python3.13/Python.h:14, from test-python-module.c:2, from test-all.c:14: /usr/include/aarch64-linux-gnu/python3.13/pyconfig.h:1810:10: note: this is the location of the previous definition 1810 | # define _GNU_SOURCE 1 | ^~~~~~~~~~~ cc1: all warnings being treated as errors acme@alta:~$I.e.
pyconfig.his included by the newtest-python-module.c, that is at the start oftest-all.c, defines_GNU_SOURCE, noticed on Debian 13 (/usr/include/aarch64-linux-gnu/python3.13/pyconfig.h, libpython 3.13.5-2+deb13u5), and thentest-all.cincludestest-gettid.cthat was defining it as well, undef it first as does several other tests.
Quoted 3 lines
Fixes 1b7e0280e247b93d ("perf Makefile: Update Python script installation path")Cc Ian Rogers <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
Thanks!
Ian
Quoted 18 lines
--- tools/build/feature/test-gettid.c | 1 + 1 file changed, 1 insertion(+)tools/build/feature/test-gettid.c +1
-1@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 // Copyright (C) 2019, Red Hat Inc, Arnaldo Carvalho de Melo <[email protected]> +#undef _GNU_SOURCE#define _GNU_SOURCE#include <unistd.h> --2.55.0
Arnaldo Carvalho de Melo
AppliedQuoted 28 lines · Ian Rogers
Quoted 26 lines · Arnaldo Carvalho de Melo
Since most of
tools/build/feature/test-*.cfeature tests are included intools/build/feature/test-all.c, we can't just define_GNU_SOURCEas it may already been defined and this will break the build with:acme@alta:~$ cat /tmp/build/perf-tools-next/feature/test-all.make.output In file included from test-all.c:26: test-gettid.c:3:9: error: "_GNU_SOURCE" redefined [-Werror] 3 | #define _GNU_SOURCE | ^~~~~~~~~~~ In file included from /usr/include/python3.13/pyconfig.h:9, from /usr/include/python3.13/Python.h:14, from test-python-module.c:2, from test-all.c:14: /usr/include/aarch64-linux-gnu/python3.13/pyconfig.h:1810:10: note: this is the location of the previous definition 1810 | # define _GNU_SOURCE 1 | ^~~~~~~~~~~ cc1: all warnings being treated as errors acme@alta:~$I.e.
pyconfig.his included by the newtest-python-module.c, that is at the start oftest-all.c, defines_GNU_SOURCE, noticed on Debian 13 (/usr/include/aarch64-linux-gnu/python3.13/pyconfig.h, libpython 3.13.5-2+deb13u5), and thentest-all.cincludestest-gettid.cthat was defining it as well, undef it first as does several other tests.
Quoted 5 lines
Quoted 3 lines
Fixes 1b7e0280e247b93d ("perf Makefile: Update Python script installation path")Cc Ian Rogers <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>Reviewed-by Ian Rogers <[email protected]>
Thanks, applied to perf-tools-next, for v7.4.
- Arnaldo