[PATCH] gdb: prefere python3 if it is installed

Christian Mauderer christian.mauderer at embedded-brains.de
Thu Aug 19 08:34:14 UTC 2021


More and more systems stop shipping python2. So we should start to
prefer python3 over python2. For building gdb it is not only necessary
to have a python binary installed, but also the matching python-devel
packet. On a lot of hosts that will now be more often python3-devel
and not python2-devel.
---

Note: Please see that patch more as an suggestion / base for
discussion. I'm open to better solutions.

My problem that triggered this patch was a build of a toolchain on a
github CI/CD system that has been originally set up by one of our
users (see [1] for the log). It seems that on the "macos-latest"
machines a python2 is installed but no python2 headers are found.
Homebrew - which could be used earlier on MacOS to install the
necessary headers - dropped the python at 2 packet. So it seems that on a
modern MacOS there is no possibility to get python2 headers. If
python2 is still installed on the machine (for whatever reason), it is
not possible to successfully use RTEMS source builder to build a gdb.
If python3 is preferred instead, that should solve the problem.

Note that at the moment I only tried it on my OpenSUSE-Linux machine.
For that I made sure that I have python2 and python3 installed but no
python-devel (which is python2 on OpenSUSE). Earlier I know that I
needed python-devel to build gdb. With this patch, I can build with
only python3-devel.

I'll try to add that patch to the CI too to see whether it works on
MacOS. But I'm a bit unsure what other problems this patch could
trigger and therefore I want to start a discussion early.

Best regards

Christian

[1] https://github.com/grisp/grisp2-rtems-toolchain/runs/3362717606
    Note: The "Get Errorinfo" step prints the rsb-report-*.txt


 source-builder/config/gdb-common-1.cfg | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/source-builder/config/gdb-common-1.cfg b/source-builder/config/gdb-common-1.cfg
index 397d44d..42fe263 100644
--- a/source-builder/config/gdb-common-1.cfg
+++ b/source-builder/config/gdb-common-1.cfg
@@ -42,7 +42,7 @@
 # 2. Does the version of gdb specify a version of python that must be
 #    used. Override with '%define gdb-python-version python2'.
 #
-# 3. Search for 'python2' and if not found search for 'python3'.
+# 3. Search for 'python3' and if not found search for 'python2'.
 #
 %if %{defined gdb-python2}
   %define gdb-enable-python %{gdb_python2}
@@ -53,9 +53,9 @@
     %if %{defined gdb-python-version}
       %define gdb-enable-python %(command -v %{gdb-python-version} || true)
     %else
-      %define gdb-enable-python %(command -v python2 || true)
+      %define gdb-enable-python %(command -v python3 || true)
       %if %{gdb-enable-python} == %{nil}
-        %define gdb-enable-python %(command -v python3 || true)
+        %define gdb-enable-python %(command -v python2 || true)
       %endif
       %if %{gdb-enable-python} == %{nil}
           %define gdb-enable-python %(command -v python || true})
-- 
2.31.1



More information about the devel mailing list