From f38be3bd9674fba335a69317d3d8ca5c5a106010 Mon Sep 17 00:00:00 2001 From: Italo Date: Wed, 20 May 2026 14:14:14 -0400 Subject: [PATCH 1/2] Compilation optimization for modern CPU --- .github/workflows/release.yml | 69 +++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dc5d7454..6874de54 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,29 +12,66 @@ env: jobs: build: - name: Build ${{ matrix.target }} + name: Build ${{ matrix.target }} (${{ matrix.cpu_version || 'native' }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: + # --- Linux x86_64 --- - target: x86_64-unknown-linux-gnu os: ubuntu-latest archive: tar.gz + cpu_version: x86-64-v2 + rustflags: "-C target-cpu=x86-64-v2" + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + archive: tar.gz + cpu_version: x86-64-v3 + rustflags: "-C target-cpu=x86-64-v3" + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + archive: tar.gz + cpu_version: x86-64-v4 + rustflags: "-C target-cpu=x86-64-v4" + + # --- Linux ARM --- - target: aarch64-unknown-linux-gnu os: ubuntu-latest archive: tar.gz + + # --- macOS x86_64 --- - target: x86_64-apple-darwin os: macos-latest archive: tar.gz macos_sign: true + cpu_version: x86-64-v2 + rustflags: "-C target-cpu=x86-64-v2" + + # --- macOS ARM --- - target: aarch64-apple-darwin os: macos-latest archive: tar.gz macos_sign: true + + # --- Windows x86_64 --- + - target: x86_64-pc-windows-msvc + os: windows-latest + archive: zip + cpu_version: x86-64-v2 + rustflags: "-C target-cpu=x86-64-v2" + - target: x86_64-pc-windows-msvc + os: windows-latest + archive: zip + cpu_version: x86-64-v3 + rustflags: "-C target-cpu=x86-64-v3" - target: x86_64-pc-windows-msvc os: windows-latest archive: zip + cpu_version: x86-64-v4 + rustflags: "-C target-cpu=x86-64-v4" + + # --- Windows ARM --- - target: aarch64-pc-windows-msvc os: windows-latest archive: zip @@ -55,9 +92,15 @@ jobs: - uses: Swatinem/rust-cache@v2 with: - key: ${{ matrix.target }} + # Scopes the cache by CPU version as well so v2, v3, and v4 don't thrash each other's cache + key: ${{ matrix.target }}-${{ matrix.cpu_version || 'default' }} - name: Build + env: + RUSTFLAGS: ${{ matrix.rustflags || '' }} + CARGO_PROFILE_RELEASE_OPT_LEVEL: "3" + CARGO_PROFILE_RELEASE_LTO: "fat" + CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "1" run: cargo build --release --target ${{ matrix.target }} # --- macOS: import certificate and sign the binary --- @@ -68,27 +111,19 @@ jobs: APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} run: | - # Write the .p12 to disk echo "$APPLE_CERTIFICATE" | base64 --decode > certificate.p12 - - # Create a temporary keychain so we don't touch the login keychain security create-keychain -p actions-keychain phpantom.keychain security set-keychain-settings -lut 21600 phpantom.keychain security unlock-keychain -p actions-keychain phpantom.keychain - - # Import the certificate + private key security import certificate.p12 \ -k phpantom.keychain \ -P "$APPLE_CERTIFICATE_PASSWORD" \ -T /usr/bin/codesign security list-keychain -d user -s phpantom.keychain - - # Allow codesign to use the key without a UI prompt security set-key-partition-list \ -S apple-tool:,apple: \ -k actions-keychain \ phpantom.keychain - rm certificate.p12 - name: Sign binary (macOS) @@ -111,7 +146,6 @@ jobs: APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} run: | - # Zip just for submission — notarytool requires an archive ditto -c -k --keepParent \ target/${{ matrix.target }}/release/phpantom_lsp \ phpantom_lsp-notarize.zip @@ -135,22 +169,25 @@ jobs: if: matrix.archive == 'tar.gz' run: | cd target/${{ matrix.target }}/release - tar czf ../../../phpantom_lsp-${{ matrix.target }}.tar.gz phpantom_lsp + # Appends the cpu_version (e.g., -x86-64-v3) to the archive name if it exists + SUFFIX="${{ matrix.cpu_version && format('-{0}', matrix.cpu_version) || '' }}" + tar czf ../../../phpantom_lsp-${{ matrix.target }}${SUFFIX}.tar.gz phpantom_lsp cd ../../.. - name: Package (windows) if: matrix.archive == 'zip' shell: pwsh run: | + $suffix = "${{ matrix.cpu_version }}" ? "-${{ matrix.cpu_version }}" : "" Compress-Archive ` -Path "target/${{ matrix.target }}/release/phpantom_lsp.exe" ` - -DestinationPath "phpantom_lsp-${{ matrix.target }}.zip" + -DestinationPath "phpantom_lsp-${{ matrix.target }}$suffix.zip" - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: phpantom_lsp-${{ matrix.target }} - path: phpantom_lsp-${{ matrix.target }}.${{ matrix.archive }} + name: phpantom_lsp-${{ matrix.target }}-${{ matrix.cpu_version || 'native' }} + path: phpantom_lsp-${{ matrix.target }}${{ matrix.cpu_version && format('-{0}', matrix.cpu_version) || '' }}.${{ matrix.archive }} release: name: Create Release @@ -171,4 +208,4 @@ jobs: run: | for file in artifacts/*; do gh release upload "${{ github.event.release.tag_name }}" "$file" --clobber - done + done \ No newline at end of file From 1f95de11733ad878e257695f73b86604bba1b7eb Mon Sep 17 00:00:00 2001 From: Italo Date: Wed, 20 May 2026 20:10:55 -0400 Subject: [PATCH 2/2] Fixes and brodens release --- .github/workflows/release.yml | 38 +++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6874de54..c51c2544 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,11 +28,13 @@ jobs: os: ubuntu-latest archive: tar.gz cpu_version: x86-64-v3 + suffix: modern rustflags: "-C target-cpu=x86-64-v3" - target: x86_64-unknown-linux-gnu os: ubuntu-latest archive: tar.gz cpu_version: x86-64-v4 + suffix: avx512 rustflags: "-C target-cpu=x86-64-v4" # --- Linux ARM --- @@ -47,6 +49,20 @@ jobs: macos_sign: true cpu_version: x86-64-v2 rustflags: "-C target-cpu=x86-64-v2" + - target: x86_64-apple-darwin + os: macos-latest + archive: tar.gz + macos_sign: true + cpu_version: x86-64-v3 + suffix: modern + rustflags: "-C target-cpu=x86-64-v3" + - target: x86_64-apple-darwin + os: macos-latest + archive: tar.gz + macos_sign: true + cpu_version: x86-64-v4 + suffix: avx512 + rustflags: "-C target-cpu=x86-64-v4" # --- macOS ARM --- - target: aarch64-apple-darwin @@ -64,11 +80,13 @@ jobs: os: windows-latest archive: zip cpu_version: x86-64-v3 + suffix: modern rustflags: "-C target-cpu=x86-64-v3" - target: x86_64-pc-windows-msvc os: windows-latest archive: zip cpu_version: x86-64-v4 + suffix: avx512 rustflags: "-C target-cpu=x86-64-v4" # --- Windows ARM --- @@ -99,8 +117,7 @@ jobs: env: RUSTFLAGS: ${{ matrix.rustflags || '' }} CARGO_PROFILE_RELEASE_OPT_LEVEL: "3" - CARGO_PROFILE_RELEASE_LTO: "fat" - CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "1" + CARGO_PROFILE_RELEASE_LTO: "thin" run: cargo build --release --target ${{ matrix.target }} # --- macOS: import certificate and sign the binary --- @@ -111,19 +128,27 @@ jobs: APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} run: | + # Write the .p12 to disk echo "$APPLE_CERTIFICATE" | base64 --decode > certificate.p12 + + # Create a temporary keychain so we don't touch the login keychain security create-keychain -p actions-keychain phpantom.keychain security set-keychain-settings -lut 21600 phpantom.keychain security unlock-keychain -p actions-keychain phpantom.keychain + + # Import the certificate + private key security import certificate.p12 \ -k phpantom.keychain \ -P "$APPLE_CERTIFICATE_PASSWORD" \ -T /usr/bin/codesign security list-keychain -d user -s phpantom.keychain + + # Allow codesign to use the key without a UI prompt security set-key-partition-list \ -S apple-tool:,apple: \ -k actions-keychain \ phpantom.keychain + rm certificate.p12 - name: Sign binary (macOS) @@ -146,6 +171,7 @@ jobs: APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} run: | + # Zip just for submission — notarytool requires an archive ditto -c -k --keepParent \ target/${{ matrix.target }}/release/phpantom_lsp \ phpantom_lsp-notarize.zip @@ -170,7 +196,7 @@ jobs: run: | cd target/${{ matrix.target }}/release # Appends the cpu_version (e.g., -x86-64-v3) to the archive name if it exists - SUFFIX="${{ matrix.cpu_version && format('-{0}', matrix.cpu_version) || '' }}" + SUFFIX="${{ matrix.suffix && format('-{0}', matrix.suffix) || '' }}" tar czf ../../../phpantom_lsp-${{ matrix.target }}${SUFFIX}.tar.gz phpantom_lsp cd ../../.. @@ -178,7 +204,7 @@ jobs: if: matrix.archive == 'zip' shell: pwsh run: | - $suffix = "${{ matrix.cpu_version }}" ? "-${{ matrix.cpu_version }}" : "" + $suffix = "${{ matrix.suffix }}" ? "-${{ matrix.suffix }}" : "" Compress-Archive ` -Path "target/${{ matrix.target }}/release/phpantom_lsp.exe" ` -DestinationPath "phpantom_lsp-${{ matrix.target }}$suffix.zip" @@ -186,8 +212,8 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: phpantom_lsp-${{ matrix.target }}-${{ matrix.cpu_version || 'native' }} - path: phpantom_lsp-${{ matrix.target }}${{ matrix.cpu_version && format('-{0}', matrix.cpu_version) || '' }}.${{ matrix.archive }} + name: phpantom_lsp-${{ matrix.target }}-${{ matrix.suffix || '' }} + path: phpantom_lsp-${{ matrix.target }}${{ matrix.suffix && format('-{0}', matrix.suffix) || '' }}.${{ matrix.archive }} release: name: Create Release