Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,15 @@

.. versionadded:: 3.2

.. envvar:: PY_EXTRA_STDMODULE_CFLAGS

Equivalent flag to :envvar:`CFLAGS_NODIST` but it only applies to **all** builtin extension
modules built as part of the standard library.

Default: (empty).

.. versionadded:: next

.. envvar:: PY_BUILTIN_MODULE_CFLAGS

Compiler flags to build a standard library extension module as a built-in
Expand Down Expand Up @@ -1495,6 +1504,15 @@

.. versionadded:: 3.8

.. envvar:: PY_EXTRA_STDMODULE_LDFLAGS

Equivalent flag to :envvar:`LDLAGS_NODIST` but it only applies to **all** builtin extension

Check warning on line 1509 in Doc/using/configure.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'envvar' reference target not found: LDLAGS_NODIST [ref.envvar]
Copy link
Contributor

@erlend-aasland erlend-aasland Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Equivalent flag to :envvar:`LDLAGS_NODIST` but it only applies to **all** builtin extension
Equivalent flag to :envvar:`LDFLAGS_NODIST` but it only applies to **all** builtin extension

modules built as part of the standard library.

Default: (empty).

.. versionadded:: next


.. rubric:: Footnotes

Expand Down
7 changes: 7 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,13 @@
with :c:expr:`Py_NO_LINK_LIB`. (Contributed by Jean-Christophe
Fillion-Robin in :gh:`82909`.)

* Two new configure flags are added: :envvar:`CFLAGS_BUILTIN_MODULE` and

Check warning on line 1498 in Doc/whatsnew/3.14.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'envvar' reference target not found: CFLAGS_BUILTIN_MODULE [ref.envvar]

Check warning on line 1498 in Doc/whatsnew/3.14.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'envvar' reference target not found: LDFLAGS_BUILTIN_MODULE [ref.envvar]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Two new configure flags are added: :envvar:`CFLAGS_BUILTIN_MODULE` and
* Two new configure flags are added: :envvar:`PY_EXTRA_STDMODULE_CFLAGS` and

:envvar:`LDFLAGS_BUILTIN_MODULE`. These flags allows refistributors to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:envvar:`LDFLAGS_BUILTIN_MODULE`. These flags allows refistributors to
:envvar:`PY_EXTRA_STDMODULE_LDFLAGS`. These flags allows refistributors to

provide compile and linker flags that only apply to standard library extension
modules. This is particulary useful to provide options such as ``RUNPATH`` and
``RPATH`` that need to be applied specifically to standard library modules due to
its different relative location. (Contributed by Pablo Galindo in :gh:`131842`.)

.. _whatsnew314-pep761:

PEP 761: Discontinuation of PGP signatures
Expand Down
5 changes: 4 additions & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@ ARFLAGS= @ARFLAGS@
# Extra C flags added for building the interpreter object files.
CFLAGSFORSHARED=@CFLAGSFORSHARED@
# C flags used for building the interpreter object files
PY_EXTRA_STDMODULE_CFLAGS= @PY_EXTRA_STDMODULE_CFLAGS@
PY_EXTRA_STDMODULE_LDFLAGS= @PY_EXTRA_STDMODULE_LDFLAGS@
PY_STDMODULE_CFLAGS= $(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED)
PY_BUILTIN_MODULE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN
PY_BUILTIN_MODULE_CFLAGS= $(PY_EXTRA_STDMODULE_CFLAGS) $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN
PY_BUILTIN_MODULE_LDFLAGS= $(PY_EXTRA_STDMODULE_LDFLAGS)
PY_CORE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE
# Linker flags used for building the interpreter object files
PY_CORE_LDFLAGS=$(PY_LDFLAGS) $(PY_LDFLAGS_NODIST)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Allow to pass custom ``CFLAGS`` and ``LDFLAGS`` to the compilation of
builtin extension modules. Patch by Pablo Galindo
3 changes: 2 additions & 1 deletion Modules/makesetup
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
;;
esac
rule="$file: $objs"
rule="$rule; \$(BLDSHARED) $objs $libs \$(LIBPYTHON) -o $file"
ldd="\$(BLDSHARED) \$(PY_BUILTIN_MODULE_LDFLAGS)"
rule="$rule; $ldd $objs $libs \$(LIBPYTHON) -o $file"
echo "$rule" >>$rulesf
done
done
Expand Down
4 changes: 4 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,9 @@ AS_CASE([$enable_wasm_dynamic_linking],

AC_SUBST([BASECFLAGS])
AC_SUBST([CFLAGS_NODIST])
AC_SUBST([PY_EXTRA_STDMODULE_CFLAGS])
AC_SUBST([LDFLAGS_NODIST])
AC_SUBST([PY_EXTRA_STDMODULE_LDFLAGS])
AC_SUBST([LDFLAGS_NOLTO])
AC_SUBST([WASM_ASSETS_DIR])
AC_SUBST([WASM_STDLIB])
Expand Down
Loading