diff --git a/.github/workflows/build-clangd.yml b/.github/workflows/build-clangd.yml new file mode 100644 index 000000000000..c2c79d858408 --- /dev/null +++ b/.github/workflows/build-clangd.yml @@ -0,0 +1,131 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on: https://github.com/jmpfar/clangd-wheel/blob/main/.github/workflows/build.yml +name: Build clangd wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'Version glob to (re)build; empty builds every version of docs/packages/clangd.yaml not released yet' + required: false + default: '' + pull_request: + branches: [main] + paths: + - '.github/workflows/build-clangd.yml' + - 'docs/packages/clangd.yaml' + - 'patches/clangd/**' + push: + branches: [main] + paths: + - '.github/workflows/build-clangd.yml' + - 'docs/packages/clangd.yaml' + - 'patches/clangd/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + with: + package: clangd + version: ${{ inputs.version }} + + build_wheels: + needs: [setup] + if: needs.setup.outputs.versions != '[]' + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + name: Build clangd ${{ matrix.version }} py2.py3-none-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 1440 # full LLVM+clang+clang-tools-extra compile from source + + env: + CLANGD_VERSION: ${{ matrix.version }} + + steps: + # jmpfar/clangd-wheel tags as v...; + # scikit-build-core's own version regex (pyproject.toml) drops a trailing + # ".0" revision, so a pending 3-component version maps back to ".0". + - name: Resolve clangd-wheel tag for ${{ env.CLANGD_VERSION }} + id: tag + run: | + version="${CLANGD_VERSION}" + if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "tag=v${version}.0" >> "$GITHUB_OUTPUT" + else + echo "tag=v${version}" >> "$GITHUB_OUTPUT" + fi + + - name: Checkout clangd-wheel ${{ steps.tag.outputs.tag }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: jmpfar/clangd-wheel + ref: ${{ steps.tag.outputs.tag }} + persist-credentials: false + + - name: Checkout python-wheels + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: python-wheels + persist-credentials: false + + - name: Patch clangd-wheel source + run: git apply python-wheels/patches/clangd/${{ env.CLANGD_VERSION }}/*.patch + + - name: Build wheel + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + with: + output-dir: wheelhouse/ + # wheel.py-api = "py2.py3", so one build serves every interpreter. + only: cp312-manylinux_riscv64 + env: + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + # Rocky 10 AppStream ships lld matching the image's clang; the ExternalProject_Add + # LLVM sub-build inherits the environment, so LDFLAGS steers its final static + # clangd link onto lld instead of ld.bfd. build-circt.yml hit this runner's 15GB + # RAM ceiling on an unrestricted-target LLVM/MLIR link; clangd's CMakeLists.txt + # likewise leaves LLVM_TARGETS_TO_BUILD at upstream's default (all targets). + CIBW_BEFORE_ALL: dnf -y install lld + # Repeats pyproject.toml's own `environment` table: CIBW_ENVIRONMENT replaces + # rather than merges with it (gotcha 107). + CIBW_ENVIRONMENT: >- + CMAKE_GENERATOR=Ninja + CMAKE_BUILD_PARALLEL_LEVEL=3 + LDFLAGS=-fuse-ld=lld + PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: clangd-${{ env.CLANGD_VERSION }}-py2.py3-none-manylinux_riscv64 + path: wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish clangd ${{ matrix.version }} + needs: [setup, build_wheels] + if: needs.setup.outputs.versions != '[]' + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + secrets: + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} + with: + artifact-pattern: clangd-${{ matrix.version }}-*-manylinux_riscv64 diff --git a/docs/packages/clangd.yaml b/docs/packages/clangd.yaml new file mode 100644 index 000000000000..2c3ac06280d3 --- /dev/null +++ b/docs/packages/clangd.yaml @@ -0,0 +1,5 @@ +package-name: clangd +source-code: https://github.com/jmpfar/clangd-wheel +license: Apache-2.0 WITH LLVM-exception +versions: +- version: 22.1.1 diff --git a/patches/clangd/22.1.1/0001-Use-build.verbose-instead-of-the-removed-cmake.verbos.patch b/patches/clangd/22.1.1/0001-Use-build.verbose-instead-of-the-removed-cmake.verbos.patch new file mode 100644 index 000000000000..a8c6dd564119 --- /dev/null +++ b/patches/clangd/22.1.1/0001-Use-build.verbose-instead-of-the-removed-cmake.verbos.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ludovic Henry +Date: Thu, 15 Oct 2026 12:00:00 +0000 +Subject: [PATCH] Use build.verbose instead of the removed cmake.verbose + +scikit-build-core renamed `cmake.verbose` to `build.verbose` in 0.10 and +kept the old key as a deprecation warning through 0.12.x. Starting with +1.0, an unset `minimum-version` turns that warning into a hard error in +get_requires_for_build_wheel: + + ERROR: Use build.verbose instead of cmake.verbose for scikit-build-core >= 0.10 + +`[build-system] requires` leaves scikit-build-core unpinned, so any fresh +build of this tag now resolves 1.x and fails before CMake runs, on every +platform. `build.verbose` exists since 0.10, so the rename keeps working +with the 0.12.x releases upstream last built with. + +Upstream-Status: To upstream [affects every platform's fresh build with scikit-build-core >= 1.0; upstream main still carries cmake.verbose] +--- + pyproject.toml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pyproject.toml b/pyproject.toml +index 765f9f8..9915dac 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -59,7 +59,7 @@ wheel.packages = ["src/clangd"] + wheel.py-api = "py2.py3" + cmake.version = ">=3.16.0" + ninja.version = ">=1.10.0" +-cmake.verbose = true ++build.verbose = true + logging.level = "DEBUG" + + [tool.pytest.ini_options] +-- +2.43.0 +