New GitHub issue #93045 from barracuda156:<br>

<hr>

<pre>
<!--
  If you're new to Python and you're not sure whether what you're experiencing is a bug, the CPython issue tracker is not
  the right place to seek help. Consider the following options instead:

  - reading the Python tutorial: https://docs.python.org/3/tutorial/
  - posting in the "Users" category on discuss.python.org: https://discuss.python.org/c/users/7
  - emailing the Python-list mailing list: https://mail.python.org/mailman/listinfo/python-list
  - searching our issue tracker (https://github.com/python/cpython/issues) to see if
    your problem has already been reported
-->

**Bug report**

A clear and concise description of what the bug is.
Include a minimal, reproducible example (https://stackoverflow.com/help/minimal-reproducible-example), if possible.

Pythons presently do not build with `+lto` on older macOS. The problem is that `configure` applies flags that compiler does not understand. Patching out those fixes the build: https://github.com/macports/macports-ports/pull/14816/files#diff-77fb5d41c051fffdedeba53d495bf1a00818b75e81ecd2c28c59dfb87018f8a8
In particular, `LTOFLAGS="-flto -Wl,-export_dynamic"` should be changed to `LTOFLAGS="-flto"` for macOS < 10.10.

I submitted the fix to Macports, but the port maintainer advised me to try fixing it in the upstream first.
I have confirmed that with my patch `python39` and `python310` build with `+lto` on 10.5.8, 10A190 and 10.6.8 for `ppc`, on 10.5.8 for `ppc64` and on 10.6.8 for `x86_64` (using `gcc11` across the board, since `gcc-4.2` does not understand `-flto`).

**Your environment**

<!-- Include as many relevant details as possible about the environment you experienced the bug in -->

- CPython versions tested on: `python39`, `python310`
- Operating system and architecture: macOS 10.5.8 (`ppc`+`ppc64`), macOS 10.6 PPC (`ppc`), macOS 10.6.8 (`ppc`, `x86_64`)

<!--
You can freely edit this text. Remove any lines you believe are unnecessary.
-->

</pre>

<hr>

<a href="https://github.com/python/cpython/issues/93045">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>