# Rebuilding optimized CPython after minor changes

**URL:** <https://discuss.python.org/t/rebuilding-optimized-cpython-after-minor-changes/105001>\
**Category:** Core Workflow\
**Created:** [November 22, 2025, 8:27pm UTC](https://discuss.python.org/t/rebuilding-optimized-cpython-after-minor-changes/105001 "2025-11-22T20:27:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rosuav](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rosuav/32/3429_2.png) [@Rosuav](https://discuss.python.org/u/Rosuav)\
**Post date:** [November 22, 2025, 8:27pm UTC](https://discuss.python.org/t/rebuilding-optimized-cpython-after-minor-changes/105001/1 "2025-11-22T20:27:26Z")

</div>

I run a bleeding-edge Python as one of my main interpreters. Since it runs a decent amount of code, I `./configure --enable-optimizations` so it profiles and optimizes. After a minor change, I’d normally expect to be able to do an incremental build, but the profiling breaks this:

```python
   55 | _PyCriticalSection2_BeginSlow(PyThreadState *tstate, PyCriticalSection2 *c, PyMutex *m1, PyMutex *m2,
      | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Python/critical_section.c:55:1: error: source locations for function ‘_PyCriticalSection2_BeginSlow’ have changed, the profile data may be out of date [-Werror=coverage-mismatch]

```

I tried removing the profiling data for that one file, but then it just complained that there wasn’t any profile for it. My workflow therefore is `make clean; make -j` for any update at all.

Is there a better way? How do you folks manage small updates?

---

<div class="post-metadata">

**Author:** ![tim.one](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tim.one/32/282_2.png) [@tim.one](https://discuss.python.org/u/tim.one)\
**Post date:** [November 22, 2025, 8:43pm UTC](https://discuss.python.org/t/rebuilding-optimized-cpython-after-minor-changes/105001/2 "2025-11-22T20:43:19Z")

</div>

> [@Rosuav](#):
>
> How do you folks manage small updates?

On Windows, I just endure it. Almost every time I update from the main branch (3 or 4 times a week), it takes “a long time” to recompile, so I’m just used to firing it off and doing something else. I swear it goes even slower if I stare at it and wait for it to finish 😉.

---

<div class="post-metadata">

**Author:** ![gpshead](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/gpshead/32/54_2.png) [@gpshead](https://discuss.python.org/u/gpshead)\
**Post date:** [November 22, 2025, 8:50pm UTC](https://discuss.python.org/t/rebuilding-optimized-cpython-after-minor-changes/105001/3 "2025-11-22T20:50:41Z")

</div>

In general for PGO and LTO builds, the norm is to rebuild everything. There no focus on trying to make workflows involving that incremental - in any project - because they are only intended to be used for slow release-candidate style builds.

---

<div class="post-metadata">

**Author:** ![Rosuav](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rosuav/32/3429_2.png) [@Rosuav](https://discuss.python.org/u/Rosuav)\
**Post date:** [November 22, 2025, 9:34pm UTC](https://discuss.python.org/t/rebuilding-optimized-cpython-after-minor-changes/105001/4 "2025-11-22T21:34:29Z")

</div>

> [@gpshead](#):
>
> In general for PGO and LTO builds, the norm is to rebuild everything.

Cool, thanks. It seemed a little odd that the profile files are all separate (there’s a .gcda file for every .c/.o file) if there’s no way to just flag one of them as invalid, but if that’s the consequences, frankly, I’ll take long rebuild times over slower Python performance, it’s still worth using PGO.

Thanks for the perspective!

---

<div class="post-metadata">

**Author:** ![barry](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/barry/32/42_2.png) [@barry](https://discuss.python.org/u/barry)\
**Post date:** [November 22, 2025, 11:00pm UTC](https://discuss.python.org/t/rebuilding-optimized-cpython-after-minor-changes/105001/5 "2025-11-22T23:00:30Z")

</div>

> [@Rosuav](#):
>
> Is there a better way? How do you folks manage small updates?

I just build from `make clean` too. On my M4 Mac Studio it takes less than 2.5 minutes to build with optimization. That’s compared to ~50s for a non-optimized build (which is what I usually do for local development).

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [November 23, 2025, 4:50pm UTC](https://discuss.python.org/t/rebuilding-optimized-cpython-after-minor-changes/105001/6 "2025-11-23T16:50:35Z")

</div>

I would ask GCC or LLVM knowledgable folks for advice.

---

<div class="post-metadata">

**Author:** ![guido](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/guido/32/21_2.png) [@guido](https://discuss.python.org/u/guido)\
**Post date:** [November 23, 2025, 6:52pm UTC](https://discuss.python.org/t/rebuilding-optimized-cpython-after-minor-changes/105001/7 "2025-11-23T18:52:10Z")

</div>

Isn’t one of the reasons to start with “make clean” (maybe the main reason) that the Makefile doesn’t encode all of the dependencies?
