Closed debohman closed 1 year ago
I can confirm that backing out https://github.com/python/cpython/commit/3e3a7da590e1c3e5f03802e538f26c5204889c82 also resolves things for me.
I wrote PR #110720 to revert my "NoLTO" change which introduced the bug.
I don't understand exactly why/how Programs/_testembed is miscompiled on macOS using LLVM 16 or 17, but it's bad: we should not miscompile Python. My change was just to optimize "build Python" command faster (run make
), it should not miscompile Python.
It would be nice if someone can dig into the issue, but I don't have the bandwidth for that. I cannot reproduce the issue on Linux, and I don't have access to any macOS machine.
If I may hazard a guess as to why this is failing, we seem to be using objects built with LTO and linking them to create Programs/_testembed
without LTO. Perhaps if you wish to to build _testembed
without LTO, then you need a set of object files built without any LTO. Note that everything works fine when building Python without any LTO.
In the case which fails, the generated _testembed
contains no symbols, so when it tries to runtime load a module, it fails because it cannot resolve the undefined symbols in the module.
I suppose that the best way to build with LTO only once instead of 3 times (freeze, testembed, libpython) is to use ./configure --enable-shared
. So most object files are only linked once into libpython, and then libpython is reused in freeze and testembed.
If I recall correctly, GCC implementation of LTO is very different and so the NOLTO hack to reduce build time when enable-shared is not used still works. Maybe we just use -flto=full in NOLTO on macOS (when cland is used).
Shall we close this issue? I have successfully built 3.13.0a1
and current main
with both PGO and LTO.
I am also using the latest Clang 17.0.4
.
Ok, I close the issue.
Issues Identified Environment Changes: Several tests failed with the message (env changed). This often means that the test environment was altered in a way that affected the tests, possibly due to external factors or previous tests impacting the state.
Memory Allocation Errors: The output shows multiple instances of malloc: *** mach_vm_map(size=...) failed (error code=3), indicating that the system ran out of memory while trying to allocate space. This could be a result of a memory leak or simply running out of available memory.
Warnings: There are warnings about mpd_setminalloc being ignored, which may not be critical but should be noted.
Failures in Tests: A significant number of tests (41 failures) did not pass. Specific tests like test_base64, test_bytes, and others are mentioned as failed.
Troubleshooting Steps Increase File Descriptor Limit: The initial message about RLIMIT_NOFILE: 256 -> 1024 indicates that the limit on open files is low. You can try increasing this limit using the following command in your terminal before running your Python command:
bash Copy code ulimit -n 2048 Check System Resources: Ensure that your system has enough free memory and CPU resources. Close unnecessary applications to free up resources.
Run Tests Individually: Instead of running all tests at once, consider running them individually to identify which specific tests are failing. This can help isolate problematic tests:
bash Copy code ./python.exe -m test test_base64 Update or Rebuild Python: If you are using a custom build of Python, ensure it’s up-to-date. You may want to rebuild it using the latest version of LLVM and Clang, or consider using a pre-built version of Python.
Consult Documentation: Refer to the Python testing documentation or the issue tracker (e.g., GitHub) for known issues regarding the specific version you are using.
Run Without PGO: If you're using Profile-Guided Optimization (PGO), consider running the tests without it to see if the issues persist:
bash Copy code ./python.exe -m test --timeout= Check for Updates: Ensure you have the latest macOS updates and check for updates to LLVM/Clang.
Conclusion These steps should help you diagnose and potentially resolve the issues you are experiencing. If the problems persist, you may want to file a bug report with more detailed logs and information about your environment. Let me know if you need further assistance!
Bug report
Bug description:
This is on macOS 10.12.6, building with LLVM / Clang 17.0.1. The system otherwise has Python 3.11.6 installed.
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs