diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index 6e1d1111f2cdcd..912239f9d11bde 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -199,6 +199,21 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: ${{ matrix.platform.arch }} + - name: "Install LLVM profiling tools" + if: ${{ matrix.platform.target == 'x86_64-pc-windows-msvc' }} + run: rustup component add llvm-tools-preview + - name: "Train PGO Ruff" + if: ${{ matrix.platform.target == 'x86_64-pc-windows-msvc' }} + shell: bash + run: | + export RUSTFLAGS="${RUSTFLAGS:+${RUSTFLAGS} }-C target-feature=+crt-static" + + python scripts/build_ruff_pgo.py \ + --target "${{ matrix.platform.target }}" \ + --target-dir "${{ github.workspace }}/target/ruff-pgo" \ + --train-only + + echo "RUSTFLAGS=${RUSTFLAGS:+${RUSTFLAGS} }-Cprofile-use=${{ github.workspace }}/target/ruff-pgo/ruff.profdata" >> "$GITHUB_ENV" - name: "Prep README.md" run: python scripts/transform_readme.py --target pypi - name: "Build wheels" @@ -210,6 +225,18 @@ jobs: env: # aarch64 build fails, see https://github.com/PyO3/maturin/issues/2110 XWIN_VERSION: 16 + - name: "Verify static Windows runtime" + if: ${{ matrix.platform.target == 'x86_64-pc-windows-msvc' }} + shell: bash + run: | + LLVM_READOBJ="$(rustc --print sysroot)/lib/rustlib/${{ matrix.platform.target }}/bin/llvm-readobj.exe" + IMPORTS_FILE="$RUNNER_TEMP/ruff-coff-imports.txt" + "$LLVM_READOBJ" --coff-imports "target/${{ matrix.platform.target }}/release/ruff.exe" > "$IMPORTS_FILE" + + if grep -Eiq 'vcruntime[[:digit:]_]*\.dll|api-ms-win-crt-' "$IMPORTS_FILE"; then + echo "Ruff must not dynamically link the Visual C++ runtime" >&2 + exit 1 + fi - name: "Test wheel" if: ${{ !startsWith(matrix.platform.target, 'aarch64') }} shell: bash