C++ linking in 3.14.6? Is there a regression?

setuptools.Extension used to be able on Linux with GCC automatically distinguish whether the code is a pure C or C++ and link accordingly. It seems to me that with either Python 3.14.6 something broke and I had to add patches like fix build failure with Python 3.14 by linking libstdc++ by mcepl · Pull Request #85 · SethMMorton/fastnumbers · GitHub to have C++ linking working. Is it a regression or we did screw up something in openSUSE?

The setup.py that you linked to uses setuptools. Why do you think that the issue is in Python and not in setuptools?

1 Like

Poking around in setuptools a bit it seems that their vendored distutils has a comment about this in extension.py:

def read_setup_file ...

I’m not very familiar with distutils or setuptools, but it does seem that they may be deferring this responsibility to the compiler? Either way, this is definitely a good place to start the search.

1 Like

After longer session with ChatGPT we came to this minimal situation:

$ python3.14
Python 3.14.4 (main, Apr  8 2026, 08:54:12) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
... 
... print(sysconfig.get_config_var("CXX"))
... print(sysconfig.get_config_var("LDCXXSHARED"))
... 
g++
g++ -shared
>>> 
$ python3.14
Python 3.14.6 (main, Jun 19 2026, 18:12:49) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
... 
... print(sysconfig.get_config_var("CXX"))
... print(sysconfig.get_config_var("LDCXXSHARED"))
... 
gcc
gcc -shared
>>> 

I am very much willing to admit a possibility that I screwed up something in our build scripts (both of these Pythons are from our openSUSE/Tumblweed interpreters), but I really cannot see what: build parameters is something I really don’t touch unless I have to.

Any thoughts?

4 Likes

I believe the specific change you’re running into is [3.14] gh-148294: Make configure find g++ correctly (GH-148298) by miss-islington · Pull Request #150211 · python/cpython · GitHub

The old behavior caused g++ to always be detected at build time even if it’s not present. Now, I’m guessing, your CPython build is correctly picking up that there isn’t a g++ install, and it’s falling back to gcc, breaking your case.

Can you check if the OpenSUSE tumbleweed CPython package declares a build dependency on g++? It probably should if it doesn’t. If not, then my guess is wrong!

5 Likes

OK, it doesn’t declare any compileir dependency:

$ rpm -qR python313-devel
/bin/sh
/usr/bin/pkg-config
/usr/bin/python3
/usr/bin/python3.13
libc.so.6()(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libpython3.13.so.1.0()(64bit)
python(abi) = 3.13
python313-base = 3.13.13
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsZstd) <= 5.4.18-1
$

I didn’t think it should be a mandatory dependency. Interesting.

1 Like

That’s a really fun one, a bugfix that accidently resolves some issue that changed a return value (not found vs a literal path does not exist).

I wonder if at some point something was changed somewhere to handle that path access failure that now isn’t being triggered because it’s properly handling the g++ not found error.

1 Like

Note that there’s actually a notice about this that some of us (:waving_hand:) have been ignoring without much understanding for many years:

  By default, distutils will build C++ extension modules with "$CXX".
  If this is not intended, then set CXX on the configure command line.

It does seem like AC_CHECK_TOOLS([CXX], [$CCC c++ g++ gcc CC cxx cc++ cl], [notfound]) might be a less-than-ideal check after the compiler-specific checks; we should perhaps move that up into the default case of the compiler-specific switch.

1 Like

That is a dependency that packaging would add as it’s not a cpython dep it’s a dep of the OP’s build process.

1 Like

I confirm that the configure scripts switchs to gcc if g++ is missing. I suppose that gcc is picked by this command in configure.ac:

AC_CHECK_TOOLS([CXX], [$CCC c++ g++ gcc CC cxx cc++ cl], [notfound])

If you want to keep CXX=g++ even if g++ is not installed, you can use ./configure CXX=g++ (...).

2 Likes