CPython records and propagates several compilation-related flags from the time CPython is built, which in turn are used by distutils and setuptools to pass them to extension modules.
Unfortunately after pypa/distutils#228, distutils now introduced a new LDCXXSHARED, and are using that in preference to LDSHARED when linking C++ code. We do set LDCXXSHARED but we don't propagate LDFLAGS to that variable if the user has set in the environment.
This is a problem because many distributions use the old variable LDFLAGS to propagate linker flags to extension modules (such as hardening and configuration flags) and now these are silently failing for C++ extension modules.
Linked PRs