Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.3k
gh-143120: pixi builds for free-threading and TSAN#142872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
d930e1257d45b95ff29b49a2a89697979e0456503bc46f283d1a38c157715f58243c2012da3b8bfa4da31a4106f2402f7756f4403546dcc0cd4cd26f028deda86d3450aa587262b7d1cad6c740fd6ca6dabae5a5a3f59ccfd87e8426492860e98a4a4f492287b8f9d31ae77a5cddc93343eead155242c32f5dabafdacca72d4472fdefe6a6e33bc48325dc99File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,56 @@ | ||
| # CPython Pixi packages | ||
| This directory contains definitions for [Pixi packages](https://pixi.sh/latest/reference/pixi_manifest/#the-package-section) | ||
| which can be built from the CPython source code. | ||
| This directory contains definitions for [Pixi | ||
| packages](https://pixi.sh/latest/reference/pixi_manifest/#the-package-section) which can | ||
| be built from the CPython source code. | ||
| Downstream developers can make use of these packages by adding them as Git dependencies in a | ||
| [Pixi workspace](https://pixi.sh/latest/first_workspace/), like: | ||
| Downstream developers can make use of these packages by adding them as Git dependencies | ||
| in a [Pixi workspace](https://pixi.sh/latest/first_workspace/), like: | ||
| ```toml | ||
| [dependencies] | ||
| python = { git = "https://github.com/python/cpython", subdirectory = "Tools/pixi-packages/asan" } | ||
| python.git = "https://github.com/python/cpython" | ||
| python.subdirectory = "Tools/pixi-packages/asan" | ||
| ``` | ||
| This is particularly useful when developers need to build CPython from source | ||
| (for example, for an ASan-instrumented build), as it does not require any manual | ||
| (for example, for an ASan or TSan-instrumented build), as it does not require any manual | ||
| clone or build steps. Instead, Pixi will automatically handle both the build | ||
| and installation of the package. | ||
| Each package definition is contained in a subdirectory, but they share the build script | ||
| `build.sh` in this directory. Currently defined package variants: | ||
| - `default` | ||
| - `asan`: ASan-instrumented build with `PYTHON_ASAN=1` | ||
| - `freethreading` | ||
| - `asan`: ASan-instrumented build | ||
| - `tsan-freethreading`: TSan-instrumented free-threading build | ||
| ## Maintenance | ||
| - Keep the `version` fields in each `recipe.yaml` up to date with the Python version | ||
| - Keep the dependency requirements up to date in each `recipe.yaml` | ||
| - Keep the `abi_tag` and `version` fields in each `variants.yaml` up to date with the | ||
| Python version | ||
| - Update `build.sh` for any breaking changes in the `configure` and `make` workflow | ||
| ## Opportunities for future improvement | ||
| - More package variants (such as TSan, UBSan) | ||
| - More package variants (such as UBSan) | ||
| - Support for Windows | ||
| - Using a single `pixi.toml` and `recipe.yaml` for all package variants is blocked on https://github.com/prefix-dev/pixi/issues/4599 | ||
| - A workaround can be removed from the build script once https://github.com/prefix-dev/rattler-build/issues/2012 is resolved | ||
| - Using a single `pixi.toml` and `recipe.yaml` for all package variants is blocked on | ||
| [pixi-build-backends#532](https://github.com/prefix-dev/pixi-build-backends/pull/532) | ||
| and [pixi#5248](https://github.com/prefix-dev/pixi/issues/5248) | ||
| ## Troubleshooting | ||
| TSan builds may crash on Linux with | ||
| ``` | ||
| FATAL: ThreadSanitizer: unexpected memory mapping 0x7977bd072000-0x7977bd500000 | ||
| ``` | ||
| To fix it, try reducing `mmap_rnd_bits`: | ||
| ```bash | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip for next time: $ sudo sysctl vm.mmap_rnd_bits
vm.mmap_rnd_bits = 32 # too high for TSan
$ sudo sysctl vm.mmap_rnd_bits=28 # reduce it
vm.mmap_rnd_bits = 28$ sudo sysctl vm.mmap_rnd_bitsvm.mmap_rnd_bits = 32 # too high for TSan
$ sudo sysctl vm.mmap_rnd_bits=28 # reduce itvm.mmap_rnd_bits = 28 | ||
| $ sudo sysctl vm.mmap_rnd_bits | ||
| vm.mmap_rnd_bits = 32 # too high for TSan | ||
| $ sudo sysctl vm.mmap_rnd_bits=28 # reduce it | ||
| vm.mmap_rnd_bits = 28 | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| variant: | ||
| - asan | ||
| abi_tag: | ||
| - asan_cp315 | ||
| version: | ||
| - 3.15 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,36 @@ | ||
| #!/bin/bash | ||
| if [[ "${PYTHON_VARIANT}" == "asan" ]]; then | ||
| echo "BUILD TYPE: ASAN" | ||
| BUILD_DIR="../build_asan" | ||
| echo "PYTHON_VARIANT: ${PYTHON_VARIANT}" | ||
| if [[ "${PYTHON_VARIANT}" == "freethreading" ]]; then | ||
| CONFIGURE_EXTRA="--disable-gil" | ||
| elif [[ "${PYTHON_VARIANT}" == "asan" ]]; then | ||
| CONFIGURE_EXTRA="--with-address-sanitizer" | ||
| export PYTHON_ASAN="1" | ||
crusaderky marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| export ASAN_OPTIONS="strict_init_order=true" | ||
| else | ||
| echo "BUILD TYPE: DEFAULT" | ||
| BUILD_DIR="../build" | ||
| elif [[ "${PYTHON_VARIANT}" == "tsan-freethreading" ]]; then | ||
| CONFIGURE_EXTRA="--disable-gil --with-thread-sanitizer" | ||
| export TSAN_OPTIONS="suppressions=${SRC_DIR}/Tools/tsan/suppressions_free_threading.txt" | ||
| elif [[ "${PYTHON_VARIANT}" == "default" ]]; then | ||
| CONFIGURE_EXTRA="" | ||
| else | ||
| echo "Unknown PYTHON_VARIANT: ${PYTHON_VARIANT}" | ||
| exit 1 | ||
| fi | ||
| # rattler-build by default set a target of 10.9 | ||
| # override it to at least 10.12 | ||
| case ${MACOSX_DEPLOYMENT_TARGET:-10.12} in | ||
| 10.12|10.13|10.14|10.15|10.16) | ||
| ;; | ||
| 10.*) | ||
| export CPPFLAGS=${CPPFLAGS/-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}/-mmacosx-version-min=10.12} | ||
| export MACOSX_DEPLOYMENT_TARGET=10.12 | ||
| ;; | ||
| *) | ||
| ;; | ||
| esac | ||
| BUILD_DIR="../build_${PYTHON_VARIANT}" | ||
| mkdir -p "${BUILD_DIR}" | ||
| cd "${BUILD_DIR}" | ||
| @@ -23,15 +42,11 @@ else | ||
| --oldincludedir="${BUILD_PREFIX}/${HOST}/sysroot/usr/include" \ | ||
| --enable-shared \ | ||
| --srcdir="${SRC_DIR}" \ | ||
| --with-system-expat \ | ||
crusaderky marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ${CONFIGURE_EXTRA} | ||
| fi | ||
| touch configure-done | ||
| make -j"${CPU_COUNT}" install | ||
| ln -sf "${PREFIX}/bin/python3" "${PREFIX}/bin/python" | ||
| # https://github.com/prefix-dev/rattler-build/issues/2012 | ||
| if [[ ${OSTYPE} == "darwin"* ]]; then | ||
| cp "${BUILD_PREFIX}/lib/clang/21/lib/darwin/libclang_rt.asan_osx_dynamic.dylib" "${PREFIX}/lib/libclang_rt.asan_osx_dynamic.dylib" | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
| # Please always only modify default/recipe.yaml and default/pixi.toml and then run this | ||
| # script to propagate the changes to the other variants. | ||
| set -o errexit | ||
| cd "$(dirname "$0")" | ||
| for variant in asan freethreading tsan-freethreading; do | ||
| cp -av default/recipe.yaml default/pixi.toml ${variant}/ | ||
| done |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to update the
README.mdright now, but noting this repo has been archived and the new PR is at prefix-dev/pixi#5364.