Skip to content

Commit 53e81f2

Browse files
committed
interpreters/python: Avoid warninns that could be treated as errors
This commit disables some warnings when building CPython to avoid CI failing when `EXTRAFLAGS="-Wno-cpp -Werror"` is set.
1 parent 37acd5e commit 53e81f2

13 files changed

+99
-32
lines changed

interpreters/python/Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ TARGETLIBPYTHON=$(TARGETINSTALL)/libpython$(CPYTHON_VERSION_MINOR).a
4343
TARGETMODULESPACK=$(TARGETBUILD)/lib/python$(shell echo $(CPYTHON_VERSION_MINOR) | tr -d .).zip
4444
TARGETMODULES=$(TARGETINSTALL)/lib/
4545

46+
CFLAGS += ${INCDIR_PREFIX}$(CPYTHON_PATH)$(DELIM)Include
47+
CFLAGS += ${INCDIR_PREFIX}$(CPYTHON_PATH)$(DELIM)Test
48+
CFLAGS += ${INCDIR_PREFIX}$(CPYTHON_PATH)$(DELIM)Include$(DELIM)internal
49+
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)$(DELIM)system
50+
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)$(DELIM)system$(DELIM)zlib$(DELIM)zlib
51+
CFLAGS += ${INCDIR_PREFIX}$(TARGETBUILD)
52+
CFLAGS += -Wno-shadow -Wno-undef -Wno-format -Wno-builtin-macro-redefined
53+
CFLAGS += -Wno-type-limits -Wno-implicit-fallthrough -Wno-char-subscripts
54+
CFLAGS += -Wno-sign-compare -Wno-unused-const-variable -Wno-unused-function
55+
CFLAGS += -Wno-unused-variable -Wno-overflow -Wno-unused-but-set-variable
56+
CFLAGS += -Wno-strict-prototypes
57+
4658
DEPPATH += --dep-path $(CPYTHON_UNPACKNAME)$(DELIM)Programs
4759
VPATH += :$(CPYTHON_UNPACKNAME)$(DELIM)Programs
4860

@@ -123,13 +135,6 @@ $(TARGETLIBPYTHON): $(TARGETBUILD)/Makefile
123135
$(Q) ( cp $(TARGETBUILD)/libpython$(CPYTHON_VERSION_MINOR).a $(TARGETLIBPYTHON) )
124136
$(Q) $(UNPACK) $(TARGETMODULESPACK) -d $(TARGETMODULES)/python$(CPYTHON_VERSION_MINOR)
125137

126-
CFLAGS += ${INCDIR_PREFIX}$(CPYTHON_PATH)$(DELIM)Include
127-
CFLAGS += ${INCDIR_PREFIX}$(CPYTHON_PATH)$(DELIM)Test
128-
CFLAGS += ${INCDIR_PREFIX}$(CPYTHON_PATH)$(DELIM)Include$(DELIM)internal
129-
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)$(DELIM)system
130-
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)$(DELIM)system$(DELIM)zlib$(DELIM)zlib
131-
CFLAGS += ${INCDIR_PREFIX}$(TARGETBUILD)
132-
133138
MODULE = $(CONFIG_INTERPRETER_CPYTHON)
134139

135140
PROGNAME += $(CONFIG_INTERPRETER_CPYTHON_PROGNAME)

interpreters/python/config.site

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ export ac_cv_func_clock="yes"
1818
export ac_cv_func_fork="yes"
1919
export ac_cv_func_waitpid="yes"
2020
export ac_cv_func_pipe="yes"
21+
export ac_cv_enable_strict_prototypes_warning="no"
2122
export MODULE_BUILDTYPE="static"

interpreters/python/patch/0001-workaround-newlib-resource.h-limitations.patch

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
From b2ac42cefa3747c7f7a9066fceed834286e829af Mon Sep 17 00:00:00 2001
1+
From 3917fd37644948096c6bebf53e701b59fa527cf5 Mon Sep 17 00:00:00 2001
22
From: Ivan Grokhotkov <ivan@espressif.com>
33
Date: Tue, 22 Oct 2024 23:58:17 +0200
4-
Subject: [PATCH 01/10] workaround newlib resource.h limitations
4+
Subject: [PATCH 01/11] workaround newlib resource.h limitations
55

66
configure script checks if resource.h is available but doesn't check
77
if it defines all the necessary functions.
88

99
Temporary workaround until these functions are added to IDF.
10+
11+
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
1012
---
1113
Modules/faulthandler.c | 2 +-
1214
1 file changed, 1 insertion(+), 1 deletion(-)

interpreters/python/patch/0002-fix-various-uint32_t-unsigned-int-type-mismatch-issu.patch

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
From 036b39478c2419af1e0a64763b9ac741cf886387 Mon Sep 17 00:00:00 2001
1+
From 562138b0486ad050b5ce601d434910973ff6f094 Mon Sep 17 00:00:00 2001
22
From: Ivan Grokhotkov <ivan@espressif.com>
33
Date: Wed, 23 Oct 2024 16:48:49 +0200
4-
Subject: [PATCH 02/10] fix various uint32_t/'unsigned int' type mismatch
4+
Subject: [PATCH 02/11] fix various uint32_t/'unsigned int' type mismatch
55
issues
66

77
In a few places existing code assumes that uint32_t == unsigned int.
88
Since in Xtensa and RISC-V bare metal toolchains uint32_t is instead
99
'unsigned long', the original code fails to build.
10+
11+
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
1012
---
1113
Modules/zlibmodule.c | 28 ++++++++++++++--------------
1214
Objects/typeobject.c | 2 +-

interpreters/python/patch/0003-reuse-wasm_assets.py-for-generating-an-archive-of-py.patch

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From 4af7a9b726ca2c8ac330b51f98acf0a103f6fa71 Mon Sep 17 00:00:00 2001
1+
From dcc6b2b6aa396f96e7c9efe3e793d96c7004ef4f Mon Sep 17 00:00:00 2001
22
From: Ivan Grokhotkov <ivan@espressif.com>
33
Date: Wed, 23 Oct 2024 16:54:39 +0200
4-
Subject: [PATCH 03/10] reuse wasm_assets.py for generating an archive of
4+
Subject: [PATCH 03/11] reuse wasm_assets.py for generating an archive of
55
python lib dir
66

77
wasm_assets.py is a useful script to prepare the smallest possible
@@ -12,6 +12,7 @@ This patch adds nuttx to the supported OS list in the script, as well
1212
as fixes what I think is a bug in path calculation.
1313

1414
Co-authored-by: Tiago Medicci Serrano <tiago.medicci@espressif.com>
15+
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
1516
---
1617
Tools/wasm/wasm_assets.py | 3 ++-
1718
1 file changed, 2 insertions(+), 1 deletion(-)

interpreters/python/patch/0004-recognize-nuttx-as-a-supported-OS.patch

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
From 1bb8d824a4b4e4b38c3541b7c26c5d71f0970266 Mon Sep 17 00:00:00 2001
1+
From ff067ccb26c91de352de362a25d87bcbabe924dc Mon Sep 17 00:00:00 2001
22
From: Ivan Grokhotkov <ivan@espressif.com>
33
Date: Wed, 23 Oct 2024 16:55:53 +0200
4-
Subject: [PATCH 04/10] recognize *-*-nuttx as a supported OS
4+
Subject: [PATCH 04/11] recognize *-*-nuttx as a supported OS
55

66
cpython's configure script bails out when cross-compiling for an
77
unknown OS, so we have to add "nuttx" to the list, even though it
88
is not used almost anywhere else.
99

1010
Co-authored-by: Tiago Medicci Serrano <tiago.medicci@espressif.com>
11+
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
1112
---
1213
config.sub | 2 +-
1314
configure | 3 +++

interpreters/python/patch/0005-gh-122907-Fix-Builds-Without-HAVE_DYNAMIC_LOADING-Se.patch

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
From cd8af3cbc9881e5a4a7c0644c8844478c8d0245d Mon Sep 17 00:00:00 2001
1+
From 7e646549488f2d3de4cf1e04ad975625342a9218 Mon Sep 17 00:00:00 2001
22
From: Eric Snow <ericsnowcurrently@gmail.com>
33
Date: Tue, 13 Aug 2024 14:44:57 -0600
4-
Subject: [PATCH 05/10] gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set
4+
Subject: [PATCH 05/11] gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set
55
(gh-122952)
66

77
As of 529a160 (gh-118204), building with HAVE_DYNAMIC_LOADING stopped working. This is a minimal fix just to get builds working again. There are actually a number of long-standing deficiencies with HAVE_DYNAMIC_LOADING builds that need to be resolved separately.
88
(cherry picked from commit ee1b8ce26e700350e47a5f65201097121c41912e)
99

1010
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
11+
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
1112
---
1213
Include/internal/pycore_importdl.h | 4 ++++
1314
Lib/importlib/_bootstrap_external.py | 16 ++++++++--------

interpreters/python/patch/0006-change-var-name-to-avoid-conflict-with-nuttx-unused_.patch

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
From d424766bff74fb34a80a09c6e2ed8d9b40350bb8 Mon Sep 17 00:00:00 2001
1+
From 82a3c7c021324e4245289c565b2d379b83ed4be3 Mon Sep 17 00:00:00 2001
22
From: Tiago Medicci <tiago.medicci@espressif.com>
33
Date: Wed, 13 Nov 2024 14:20:36 -0300
4-
Subject: [PATCH 06/10] change var name to avoid conflict with nuttx
4+
Subject: [PATCH 06/11] change var name to avoid conflict with nuttx
55
unused_data macro
66

7+
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
78
---
89
Modules/zlibmodule.c | 42 +++++++++++++++++++++---------------------
910
1 file changed, 21 insertions(+), 21 deletions(-)

interpreters/python/patch/0007-undef-atexit_register.patch

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
From 1b802bfd159a6a9766ca5834af90f55d54285b4b Mon Sep 17 00:00:00 2001
1+
From 7eab2315d75d5e78e67e0b049ebb2fc71914b7ea Mon Sep 17 00:00:00 2001
22
From: Tiago Medicci <tiago.medicci@espressif.com>
33
Date: Wed, 13 Nov 2024 14:22:04 -0300
4-
Subject: [PATCH 07/10] undef atexit_register
4+
Subject: [PATCH 07/11] undef atexit_register
55

66
Even if not built, nuttx/include/nuttx/atexit.h defines it and this
77
causes conflicts.
8+
9+
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
810
---
911
Modules/atexitmodule.c | 4 ++++
1012
1 file changed, 4 insertions(+)

interpreters/python/patch/0008-declare-struct-timeval.patch

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
From b40e89c190ec7c6b3b0116a3f7025ab13854398f Mon Sep 17 00:00:00 2001
1+
From fc042cfa496f37f2a859495ad281583f79af0044 Mon Sep 17 00:00:00 2001
22
From: Tiago Medicci <tiago.medicci@espressif.com>
33
Date: Wed, 13 Nov 2024 14:23:34 -0300
4-
Subject: [PATCH 08/10] declare struct timeval
4+
Subject: [PATCH 08/11] declare struct timeval
55

66
Otherwise, build will fail due to redefinition of _PyTime_FromTimeval
7+
8+
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
79
---
810
Include/internal/pycore_time.h | 2 --
911
1 file changed, 2 deletions(-)

interpreters/python/patch/0009-include-nuttx-sys-select-header-to-define-FD_SETSIZE.patch

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
From 9a32a300c95e0061220d2608a014c7fa39dedab3 Mon Sep 17 00:00:00 2001
1+
From 3d140751ebec3aedd8ed3cdf2a7eff5009693112 Mon Sep 17 00:00:00 2001
22
From: Tiago Medicci <tiago.medicci@espressif.com>
33
Date: Thu, 14 Nov 2024 13:44:49 -0300
4-
Subject: [PATCH 09/10] include nuttx sys/select header to define FD_SETSIZE
4+
Subject: [PATCH 09/11] include nuttx sys/select header to define FD_SETSIZE
55

6+
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
67
---
78
Modules/selectmodule.c | 4 ++++
89
1 file changed, 4 insertions(+)

interpreters/python/patch/0010-check-for-the-d_ino-member-of-the-structure-dirent.patch

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
1-
From 4f6a1db85c56df378dc3856ed95a0a7342f44d89 Mon Sep 17 00:00:00 2001
1+
From 4191bf1e4505776efa0780ebc4fc5195a6ce79d3 Mon Sep 17 00:00:00 2001
22
From: Tiago Medicci <tiago.medicci@espressif.com>
33
Date: Tue, 3 Dec 2024 17:18:50 -0300
4-
Subject: [PATCH 10/10] check for the d_ino member of the structure dirent
4+
Subject: [PATCH 10/11] check for the d_ino member of the structure dirent
55

6+
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
67
---
7-
Modules/posixmodule.c | 18 ++++++++++++++++--
8-
configure | 43 +++++++++++++++++++++++++++++++++++++++++++
9-
configure.ac | 5 +++++
10-
pyconfig.h.in | 3 +++
11-
4 files changed, 67 insertions(+), 2 deletions(-)
8+
Modules/clinic/posixmodule.c.h | 2 ++
9+
Modules/posixmodule.c | 18 ++++++++++++--
10+
configure | 43 ++++++++++++++++++++++++++++++++++
11+
configure.ac | 5 ++++
12+
pyconfig.h.in | 3 +++
13+
5 files changed, 69 insertions(+), 2 deletions(-)
1214

15+
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
16+
index 14a6efb9ac9..6e716f77db8 100644
17+
--- a/Modules/clinic/posixmodule.c.h
18+
+++ b/Modules/clinic/posixmodule.c.h
19+
@@ -11652,6 +11652,7 @@ PyDoc_STRVAR(os_DirEntry_inode__doc__,
20+
#define OS_DIRENTRY_INODE_METHODDEF \
21+
{"inode", (PyCFunction)os_DirEntry_inode, METH_NOARGS, os_DirEntry_inode__doc__},
22+
23+
+#ifdef HAVE_DIRENT_D_INO
24+
static PyObject *
25+
os_DirEntry_inode_impl(DirEntry *self);
26+
27+
@@ -11660,6 +11661,7 @@ os_DirEntry_inode(DirEntry *self, PyObject *Py_UNUSED(ignored))
28+
{
29+
return os_DirEntry_inode_impl(self);
30+
}
31+
+#endif
32+
33+
PyDoc_STRVAR(os_DirEntry___fspath____doc__,
34+
"__fspath__($self, /)\n"
1335
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
1436
index 51e34b5f4b7..2aa507aa942 100644
1537
--- a/Modules/posixmodule.c
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From b82ab44e498a9e9bcdcbbfa1d6161023d8ea8c5b Mon Sep 17 00:00:00 2001
2+
From: Tiago Medicci <tiago.medicci@espressif.com>
3+
Date: Tue, 10 Dec 2024 12:03:47 -0300
4+
Subject: [PATCH 11/11] avoid redefinition warning if UNUSED is already defined
5+
6+
---
7+
Parser/pegen.h | 2 ++
8+
1 file changed, 2 insertions(+)
9+
10+
diff --git a/Parser/pegen.h b/Parser/pegen.h
11+
index 32c64e7774b..42574456f23 100644
12+
--- a/Parser/pegen.h
13+
+++ b/Parser/pegen.h
14+
@@ -250,7 +250,9 @@ void * _PyPegen_seq_last_item(asdl_seq *seq);
15+
#define PyPegen_last_item(seq, type) ((type)_PyPegen_seq_last_item((asdl_seq*)seq))
16+
void * _PyPegen_seq_first_item(asdl_seq *seq);
17+
#define PyPegen_first_item(seq, type) ((type)_PyPegen_seq_first_item((asdl_seq*)seq))
18+
+#ifndef UNUSED
19+
#define UNUSED(expr) do { (void)(expr); } while (0)
20+
+#endif
21+
#define EXTRA_EXPR(head, tail) head->lineno, (head)->col_offset, (tail)->end_lineno, (tail)->end_col_offset, p->arena
22+
#define EXTRA _start_lineno, _start_col_offset, _end_lineno, _end_col_offset, p->arena
23+
PyObject *_PyPegen_new_type_comment(Parser *, const char *);
24+
--
25+
2.46.1
26+

0 commit comments

Comments
 (0)