jjhelmus · GitHub

Bug report

Bug description:

When building a static python binary and statically linking the _curses extension there are two global COLORS symbols, one from curses and one from Python/optimization.c.

This can cause a build failure, for example in astral-sh/python-build-standalone#949 when building 3.15.0a5.

This only seems to occur when building with PGO+LTO, the variable is likely inlined in other cases.

One solution is to mark the COLORS symbol as static to limit the scope:

diff --git a/Python/optimizer.c b/Python/optimizer.c
index a2a1feb8b9e..c5f47d7f22c 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -2009,7 +2009,7 @@ find_line_number(PyCodeObject *code, _PyExecutorObject *executor)
 #define BLACK "#000000"
 #define LOOP "#00c000"
-const char *COLORS[10] = {
+static const char *COLORS[10] = {
     "9",
     "8",
     "7",

CPython versions tested on:

3.15

Operating systems tested on:

Linux

Linked PRs

Read the original on github.com ↗