|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# PyPI's tcmlib wheel is Intel's own prebuilt x86_64/win_amd64-only binary under a closed |
| 5 | +# redistribution licence with no sdist; this builds the Apache-2.0 TCM source instead (same |
| 6 | +# shape as the tbb port, see build-tbb.yml). TCM lives inside the oneTBB repo as a |
| 7 | +# git-subtree-merged subdirectory, not a separate project, and is versioned independently of |
| 8 | +# oneTBB itself, so there is no oneTBB tag for a given TCM release - pin the commit instead. |
| 9 | +# Based on: https://github.com/uxlfoundation/oneTBB/tree/master/thread_composability_manager |
| 10 | +# (no upstream CI builds this wheel) |
| 11 | +name: Build tcmlib wheels (riscv64) |
| 12 | + |
| 13 | +on: |
| 14 | + workflow_dispatch: |
| 15 | + inputs: |
| 16 | + version: |
| 17 | + description: 'tcmlib version to build' |
| 18 | + required: true |
| 19 | + default: '1.5.0' |
| 20 | + pull_request: |
| 21 | + paths: |
| 22 | + - '.github/workflows/build-tcmlib.yml' |
| 23 | + - 'patches/tcmlib/**' |
| 24 | + |
| 25 | +concurrency: |
| 26 | + group: ${{ github.workflow }}-${{ inputs.version || '1.5.0' }}-${{ github.head_ref || github.run_id }} |
| 27 | + cancel-in-progress: true |
| 28 | + |
| 29 | +permissions: |
| 30 | + contents: read # to fetch code (actions/checkout) |
| 31 | + |
| 32 | +env: |
| 33 | + TCM_VERSION: ${{ inputs.version || '1.5.0' }} |
| 34 | + # oneTBB commit that introduced TCM at version 1.5.0 (git-subtree merge of TCM's own |
| 35 | + # history, one day before the matching PyPI upload). Update alongside TCM_VERSION. |
| 36 | + TCM_REF: 7bc8577403df32b69b25157caad45677a8552861 |
| 37 | + HWLOC_VERSION: 2.14.0 |
| 38 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 39 | + |
| 40 | +jobs: |
| 41 | + setup: |
| 42 | + uses: $/.github/workflows/_setup.yml |
| 43 | + |
| 44 | + build_wheels: |
| 45 | + needs: [setup] |
| 46 | + name: Build tcmlib ${{ inputs.version || '1.5.0' }} py2.py3-none-manylinux_riscv64 |
| 47 | + runs-on: ubuntu-24.04-riscv |
| 48 | + timeout-minutes: 120 |
| 49 | + |
| 50 | + steps: |
| 51 | + - name: Checkout oneTBB @ TCM ${{ env.TCM_VERSION }} (thread_composability_manager) |
| 52 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 53 | + with: |
| 54 | + repository: uxlfoundation/oneTBB |
| 55 | + ref: ${{ env.TCM_REF }} |
| 56 | + persist-credentials: false |
| 57 | + |
| 58 | + - name: Checkout python-wheels |
| 59 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 60 | + with: |
| 61 | + path: python-wheels |
| 62 | + persist-credentials: false |
| 63 | + |
| 64 | + # TCM's own cmake/compilers/GNU.cmake applies -fcf-protection=full (x86 CET |
| 65 | + # hardening) unconditionally, unlike oneTBB's own copy of the same file, which |
| 66 | + # gates it to x86 - GCC rejects the flag outright on other architectures. |
| 67 | + - name: Patch TCM source |
| 68 | + run: git apply python-wheels/patches/tcmlib/${{ env.TCM_VERSION }}/*.patch |
| 69 | + |
| 70 | + - name: Pull manylinux_riscv64 image |
| 71 | + run: docker pull "${MANYLINUX_RISCV64_IMAGE}" |
| 72 | + |
| 73 | + # TCM requires HWLOC >= 2.5 to build (find_package(HWLOC REQUIRED)); it isn't |
| 74 | + # manylinux-portable as a system dependency (same fact that made tbb drop its |
| 75 | + # optional libtbbbind), so build it from source and bundle it alongside libtcm.so, |
| 76 | + # exactly like Intel's own wheel does. TCM_TEST=OFF skips its test suite, |
| 77 | + # TCM_STRICT=OFF avoids upstream's warnings-as-errors on a newer GCC than they test. |
| 78 | + - name: Build HWLOC, TCM, and the wheel |
| 79 | + run: | |
| 80 | + docker run --rm -v "$(pwd):/work" -w /work -e TCM_VERSION -e HWLOC_VERSION "${MANYLINUX_RISCV64_IMAGE}" bash -c ' |
| 81 | + set -euxo pipefail |
| 82 | + curl -fsSL -o hwloc.tar.gz "https://download.open-mpi.org/release/hwloc/v${HWLOC_VERSION%.*}/hwloc-${HWLOC_VERSION}.tar.gz" |
| 83 | + tar xzf hwloc.tar.gz |
| 84 | + (cd "hwloc-${HWLOC_VERSION}" && ./configure --prefix=/work/hwloc-install --disable-static && make -j"$(nproc)" && make install) |
| 85 | + export HWLOCROOT=/work/hwloc-install |
| 86 | + cmake -S thread_composability_manager -B build -DCMAKE_BUILD_TYPE=Release -DTCM_TEST=OFF -DTCM_STRICT=OFF -DCMAKE_INSTALL_LIBDIR=lib |
| 87 | + cmake --build build -j"$(nproc)" |
| 88 | + cmake --install build --prefix /work/install |
| 89 | + mkdir -p dist_libs |
| 90 | + cp -L install/lib/libtcm.so* hwloc-install/lib/libhwloc.so* dist_libs/ |
| 91 | + for f in dist_libs/libtcm.so*; do patchelf --set-rpath "\$ORIGIN" "$f"; done |
| 92 | + strip dist_libs/*.so* |
| 93 | + file dist_libs/*.so* |
| 94 | + ldd dist_libs/libtcm.so.1 |
| 95 | + cp thread_composability_manager/licensing/LICENSE.txt LICENSE.txt |
| 96 | + cp "hwloc-${HWLOC_VERSION}/COPYING" LICENSE-hwloc.txt |
| 97 | + cat > setup.py <<PYEOF |
| 98 | + import glob |
| 99 | + import os |
| 100 | + from setuptools import setup |
| 101 | + setup( |
| 102 | + name="tcmlib", |
| 103 | + version=os.environ["TCM_VERSION"], |
| 104 | + description="Thread Composability Manager", |
| 105 | + long_description="Thread Composability Manager (TCM) riscv64 dynamic library for Linux, built from the Apache-2.0 licensed oneTBB source, bundling a BSD-3-Clause HWLOC build it depends on.", |
| 106 | + url="https://github.com/uxlfoundation/oneTBB/tree/master/thread_composability_manager", |
| 107 | + license="Apache-2.0", |
| 108 | + license_files=["LICENSE.txt", "LICENSE-hwloc.txt"], |
| 109 | + classifiers=[ |
| 110 | + "Operating System :: POSIX :: Linux", |
| 111 | + "Topic :: Software Development :: Libraries", |
| 112 | + ], |
| 113 | + data_files=[("lib", sorted(glob.glob("dist_libs/*.so*")))], |
| 114 | + ) |
| 115 | + PYEOF |
| 116 | + pybin=/opt/python/cp312-cp312/bin |
| 117 | + "$pybin/pip" install -q -U setuptools wheel |
| 118 | + "$pybin/python3" setup.py bdist_wheel --python-tag py2.py3 --plat-name manylinux_2_39_riscv64 |
| 119 | + "$pybin/pip" install -q dist/*.whl |
| 120 | + "$pybin/python3" - <<PYEOF |
| 121 | + import ctypes, os, sysconfig |
| 122 | + libdir = os.path.join(sysconfig.get_path("data"), "lib") |
| 123 | + tcm = ctypes.CDLL(os.path.join(libdir, "libtcm.so.1")) |
| 124 | + tcm.tcmGetVersion.restype = ctypes.c_uint |
| 125 | + version = tcm.tcmGetVersion() |
| 126 | + major, minor, patch = (int(p) for p in os.environ["TCM_VERSION"].split(".")) |
| 127 | + assert version == 10000 * major + 100 * minor + patch, version |
| 128 | + print("smoke test OK: tcmGetVersion() =", version) |
| 129 | + PYEOF |
| 130 | + ' |
| 131 | +
|
| 132 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 133 | + with: |
| 134 | + name: tcmlib-${{ env.TCM_VERSION }}-py2.py3-none-manylinux_riscv64 |
| 135 | + path: dist/*.whl |
| 136 | + if-no-files-found: error |
| 137 | + |
| 138 | + publish: |
| 139 | + name: Publish tcmlib ${{ inputs.version || '1.5.0' }} |
| 140 | + needs: [setup, build_wheels] |
| 141 | + permissions: |
| 142 | + contents: write |
| 143 | + pull-requests: write |
| 144 | + uses: $/.github/workflows/_publish-wheel.yml |
| 145 | + with: |
| 146 | + artifact-pattern: tcmlib-${{ inputs.version || '1.5.0' }}-*-manylinux_riscv64 |
0 commit comments