From ed9cdf2552d95ef93bcea8c3a3bb565971f666ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 8 Nov 2023 11:11:15 -0500 Subject: [PATCH] update Rust --- .github/workflows/rust-prebuilt.yml | 65 ++++++++++++------- ...windows-msvc-dynamic-runtime-linking.patch | 16 +++-- 2 files changed, 49 insertions(+), 32 deletions(-) diff --git a/.github/workflows/rust-prebuilt.yml b/.github/workflows/rust-prebuilt.yml index 5c844d9..887e6a6 100644 --- a/.github/workflows/rust-prebuilt.yml +++ b/.github/workflows/rust-prebuilt.yml @@ -22,6 +22,27 @@ jobs: runner: ubuntu-22.04 steps: + - name: Preflight + shell: pwsh + run: | + $LlvmVersion = "16.0.6" + $LlvmRunId = '${{ github.event.inputs.run_id }}' + if ($LlvmRunId -eq 'latest') { + $LlvmRunId = $(gh run list -w 'LLVM prebuilt' --json 'status,databaseId,conclusion') | + ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } | + Select-Object -First 1 -ExpandProperty databaseId + } + echo "LLVM_VERSION=$LlvmVersion" >> $Env:GITHUB_ENV + echo "LLVM_RUN_ID=$LlvmRunId" >> $Env:GITHUB_ENV + + $RustBuildDir = if ($IsWindows) { "C:\rust" } else { "${{runner.temp}}" } + echo "RUST_BUILD_DIR=$RustBuildDir" >> $Env:GITHUB_ENV + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + - name: Configure Windows runner if: runner.os == 'Windows' shell: pwsh @@ -29,7 +50,7 @@ jobs: choco install --no-progress ninja 7zip wget Install-Module VsDevShell -Force docker system prune -a -f # free some space on C:\ - New-Item -Path "C:\rust" -ItemType Directory | Out-Null + New-Item -Path $Env:RUST_BUILD_DIR -ItemType Directory | Out-Null - name: Configure macOS runner if: runner.os == 'macOS' @@ -86,20 +107,26 @@ jobs: - name: Install clang+llvm shell: pwsh + env: + GH_TOKEN: ${{ github.token }} run: | - $CLANG_LLVM_OS='${{matrix.os}}'.ToLower() - $CLANG_LLVM_BASE_URL="https://github.com/awakecoding/llvm-prebuilt/releases/download/v2022.2.0" - $CLANG_LLVM_NAME="clang+llvm-14.0.6-x86_64-${CLANG_LLVM_OS}" - wget -q "${CLANG_LLVM_BASE_URL}/${CLANG_LLVM_NAME}.tar.xz" + $LlvmPlatform='${{matrix.os}}' + $LlvmArch='x86_64' + $LlvmVersion = $Env:LLVM_VERSION + $LlvmRunId = $Env:LLVM_RUN_ID + $LlvmName="clang+llvm-${LlvmVersion}-${LlvmArch}-${LlvmPlatform}" + & gh run download $LlvmRunId --repo $Env:GITHUB_REPOSITORY -n $LlvmName if ($IsWindows) { - $LLVM_PREFIX="C:/llvm" - cmd.exe /c "7z.exe x ${CLANG_LLVM_NAME}.tar.xz -so | 7z x -si -ttar -o`"C:/temp`"" - mv "C:/temp/${CLANG_LLVM_NAME}" $LLVM_PREFIX + $TempDir = "C:/temp" + $LLVM_PREFIX = "C:/llvm" + cmd.exe /c "7z.exe x ${LlvmName}.tar.xz -so | 7z x -si -ttar -o`"C:/temp`"" + mv "$TempDir/${LlvmName}" $LLVM_PREFIX $LLVM_CONFIG="$LLVM_PREFIX/bin/llvm-config.exe" } else { - $LLVM_PREFIX="/opt/llvm" - tar -xf "${CLANG_LLVM_NAME}.tar.xz" -C /tmp - sudo mv "/tmp/${CLANG_LLVM_NAME}" $LLVM_PREFIX + $TempDir = "/tmp" + $LLVM_PREFIX = "/opt/llvm" + tar -xvf "${LlvmName}.tar.xz" -C $TempDir + sudo mv "$TempDir/${LlvmName}" $LLVM_PREFIX $LLVM_CONFIG="$LLVM_PREFIX/bin/llvm-config" } $LLVM_BIN_PATH="$LLVM_PREFIX/bin" @@ -108,18 +135,6 @@ jobs: echo "LLVM_CONFIG=$LLVM_CONFIG" >> $Env:GITHUB_ENV echo "PATH=$LLVM_BIN_PATH$([IO.Path]::PathSeparator)$Env:PATH" >> $Env:GITHUB_ENV - - name: Setup dynamic variables - id: dynamic-variables - shell: pwsh - run: | - $RustBuildDir = if ($IsWindows) { "C:\rust" } else { "${{runner.temp}}" } - echo "::set-output name=rust-build-dir::$RustBuildDir" - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.9' - - name: Clone project uses: actions/checkout@v3 with: @@ -146,7 +161,7 @@ jobs: shell: pwsh working-directory: rust run: | - $RustBuildDir = "${{steps.dynamic-variables.outputs.rust-build-dir}}".Replace('\','\\') + $RustBuildDir = "$Env:RUST_BUILD_DIR".Replace('\','\\') $RustLlvmConfig = $Env:LLVM_CONFIG.Replace('\','\\') $RustHostArch = '${{matrix.arch}}' $RustHostPlatform = @{'windows'='pc-windows-msvc'; @@ -197,4 +212,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: rust-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}} - path: ${{steps.dynamic-variables.outputs.rust-build-dir}}/dist + path: ${{ env.RUST_BUILD_DIR }}/dist diff --git a/patches/rust-1.73.0-force-windows-msvc-dynamic-runtime-linking.patch b/patches/rust-1.73.0-force-windows-msvc-dynamic-runtime-linking.patch index be8dec1..dbfaa46 100644 --- a/patches/rust-1.73.0-force-windows-msvc-dynamic-runtime-linking.patch +++ b/patches/rust-1.73.0-force-windows-msvc-dynamic-runtime-linking.patch @@ -1,14 +1,14 @@ -From 83b2827d0c833b8676677a0053e5c6ea55be668b Mon Sep 17 00:00:00 2001 +From e0a1ccb6e00c27ce541f3883d3484827928d24e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= -Date: Thu, 2 Nov 2023 09:45:19 -0400 +Date: Wed, 8 Nov 2023 11:47:42 -0500 Subject: [PATCH] [PATCH] force Windows MSVC dynamic runtime linking --- src/bootstrap/bin/rustc.rs | 2 +- src/bootstrap/bootstrap.py | 2 +- src/bootstrap/builder.rs | 2 +- - src/bootstrap/cc_detect.rs | 4 ++-- - 4 files changed, 5 insertions(+), 5 deletions(-) + src/bootstrap/cc_detect.rs | 6 +++--- + 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 10718aeb89f..6bff20c84c1 100644 @@ -50,14 +50,16 @@ index b3666192853..198b1e0a46d 100644 rustflags.arg("-Ctarget-feature=-crt-static"); } diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs -index 2496c2a9db5..6f0985310ae 100644 +index 2496c2a9db5..b745a05b78e 100644 --- a/src/bootstrap/cc_detect.rs +++ b/src/bootstrap/cc_detect.rs -@@ -75,11 +75,11 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build { +@@ -74,12 +74,12 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build { + .target(&target.triple) .host(&build.build.triple); match build.crt_static(target) { - Some(a) => { +- Some(a) => { - cfg.static_crt(a); ++ Some(_a) => { + cfg.static_crt(false); } None => {