name: Build Windows Artifacts on: workflow_dispatch: inputs: amdgpu_families: type: string default: gfx1151 artifact_group: type: string default: gfx1151 build_variant_label: type: string description: "A label for the build variant (ex: 'release', 'asan')" default: "release" build_variant_suffix: type: string description: "The build variant suffix (ex: 'asan' suffix -> 'gfx94X-dcgpu-asan')" default: "" build_variant_cmake_preset: type: string description: "The name of the cmake preset to use for this build variant, matching an entry in CMakePresets.json (ex: 'linux-release-asan')" default: "" package_version: type: string default: ADHOCBUILD expect_failure: type: boolean extra_cmake_options: type: string workflow_call: inputs: package_version: type: string default: ADHOCBUILD amdgpu_families: type: string artifact_group: type: string build_variant_label: type: string build_variant_suffix: type: string build_variant_cmake_preset: type: string expect_failure: type: boolean extra_cmake_options: type: string test_type: type: string permissions: contents: read jobs: build_windows_artifacts: name: Build ${{ inputs.build_variant_label }} (xfail ${{ inputs.expect_failure }}) runs-on: azure-windows-scale-rocm continue-on-error: ${{ inputs.expect_failure }} timeout-minutes: 720 # 12 hour timeout permissions: id-token: write defaults: run: shell: bash strategy: fail-fast: true env: BUILD_DIR: B:\build CACHE_DIR: "${{github.workspace}}/.cache" CCACHE_DIR: "${{github.workspace}}/.cache/ccache" CCACHE_MAXSIZE: "4000M" TEATIME_FORCE_INTERACTIVE: 0 AMDGPU_FAMILIES: ${{ inputs.amdgpu_families }} IS_PR_FROM_FORK: ${{ github.event.pull_request.head.repo.fork }} steps: - name: Checkout TheRock repository uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: repository: "ROCm/TheRock" ref: 'compiler/amd-staging' - name: Update Submodule Pointer to the PR if: ${{ github.event_name == 'pull_request' }} run: | git config --global --add safe.directory $PWD # Fetch the latest commit SHA from the PR branch PR_SHA=${{ github.event.pull_request.head.sha }} # Update the submodule pointer using cacheinfo git update-index --cacheinfo 160000,$PR_SHA,compiler/amd-llvm git config --global user.email "z1-cciauto@amd.com" git config --global user.name "Z1 cciauto" git commit -m "Update submodule reference for compiler/amd-llvm" # Verify the pointer update git submodule status git submodule - name: Update Submodule Pointer at compiler/amd-llvm for manual debug if: ${{ github.event_name != 'pull_request' && github.workflow == 'ROCK CI Windows Debug Support' }} run: | git config --global --add safe.directory $PWD echo "sha: $GITHUB_SHA" # Update the submodule pointer using cacheinfo git update-index --cacheinfo 160000,$GITHUB_SHA,compiler/amd-llvm git config --global user.email "z1-cciauto@amd.com" git config --global user.name "Z1 cciauto" git commit -m "Update submodule reference for compiler/amd-llvm using branch SHA" # Verify the pointer update git submodule status git submodule - name: Download LLVM, SPIRV and HIPIFY PR's stored in file if: ${{ github.event_name == 'workflow_dispatch' }} continue-on-error: true uses: actions/download-artifact@v4 with: name: multiple-pr-build-params path: . - name: Check for parameterised PR trigger id: check_parameterised_trigger if: ${{ github.event_name == 'workflow_dispatch' }} run: | if [ -f "./${{ github.run_id }}_PR_params.env" ]; then echo "parameterised_trigger=true" >> "$GITHUB_OUTPUT" else echo "parameterised_trigger=false" >> "$GITHUB_OUTPUT" fi - name: Source the multiple PR's of params if: ${{ github.event_name == 'workflow_dispatch' && steps.check_parameterised_trigger.outputs.parameterised_trigger == 'true' }} run: | set -a source ./${{ github.run_id }}_PR_params.env set +a echo "LLVM_PR_URL=$LLVM_PR_URL" >> "$GITHUB_ENV" echo "SPIRV_PR_URL=$SPIRV_PR_URL" >> "$GITHUB_ENV" echo "HIPIFY_PR_URL=$HIPIFY_PR_URL" >> "$GITHUB_ENV" - name: Update submodule pointers from provided parameter PR values if: ${{ github.event_name == 'workflow_dispatch' && steps.check_parameterised_trigger.outputs.parameterised_trigger == 'true' }} run: | git config --global --add safe.directory "$PWD" # Function to get SHA with git-ls get_pr_sha() { local pr_url="$1" local base_repo_url=$(echo "$pr_url" | sed 's|/pull/.*||') local pr_num=$(echo "$pr_url" | sed 's|.*/pull/||') git ls-remote "${base_repo_url}.git" "refs/pull/${pr_num}/head" | awk '{print $1}' } # LLVM PR LLVM_SHA="$(get_pr_sha "$LLVM_PR_URL")" echo "LLVM head SHA: $LLVM_SHA" git update-index --cacheinfo 160000,"$LLVM_SHA","compiler/amd-llvm" # SPIRV PR if [[ -n "$SPIRV_PR_URL" ]]; then SPIRV_SHA="$(get_pr_sha "$SPIRV_PR_URL")" echo "SPIRV head SHA: $SPIRV_SHA" git update-index --cacheinfo 160000,"$SPIRV_SHA","compiler/spirv-llvm-translator" else SPIRV_SHA="$(git ls-remote https://github.com/ROCm/SPIRV-LLVM-Translator.git refs/heads/amd-staging | awk '{print $1}')" echo "SPIRV PR NOT Passed, defaulting to the amd-staging tip : $SPIRV_SHA" git update-index --cacheinfo 160000,"$SPIRV_SHA","compiler/spirv-llvm-translator" fi # HIPIFY PR if [[ -n "$HIPIFY_PR_URL" ]]; then HIPIFY_SHA="$(get_pr_sha "$HIPIFY_PR_URL")" echo "HIPIFY head SHA: $HIPIFY_SHA" git update-index --cacheinfo 160000,"$HIPIFY_SHA","compiler/hipify" else HIPIFY_SHA="$(git ls-remote https://github.com/ROCm/HIPIFY.git refs/heads/amd-staging | awk '{print $1}')" echo "HIPIFY PR NOT Passed, defaulting to the amd-staging tip : $HIPIFY_SHA" git update-index --cacheinfo 160000,"$HIPIFY_SHA","compiler/hipify" fi git config --global user.email "z1-cciauto@amd.com" git config --global user.name "Z1 cciauto" git commit -m "Update submodule references from PR URLs" git submodule status git submodule - name: "Map Current Directory to L Drive" id: subst shell: cmd run: | REM Get the current working directory set currentDir=%cd% REM Substitute the current directory with L: drive subst L: %currentDir% cd L: dir L: wmic logicaldisk get name - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: 3.12 - name: Install python deps run: | pip install -r requirements.txt - name: Install requirements # The first two lines removes the default commmunity feed and uses the internal proxy feed run: | choco source disable -n=chocolatey choco source add -n=internal -s http://10.0.167.96:8081/repository/choco-group/ --priority=1 choco install --no-progress -y ccache # ninja pinned due to a bug in the 1.13.0 release: # https://github.com/ninja-build/ninja/issues/2616 choco install --no-progress -y ninja --version 1.12.1 choco install --no-progress -y strawberryperl echo "$PATH;C:\Strawberry\c\bin" >> $GITHUB_PATH choco install --no-progress -y awscli choco install --no-progress -y pkgconfiglite echo "$PATH;C:\Program Files\Amazon\AWSCLIV2" >> $GITHUB_PATH - uses: iterative/setup-dvc@4bdfd2b0f6f1ad7e08afadb03b1a895c352a5239 # v2.0.0 with: version: '3.62.0' # After other installs, so MSVC get priority in the PATH. - name: Configure MSVC uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 - name: Runner health status run: | ccache --zero-stats python ./build_tools/health_status.py - name: Remove ununsed existing patchces run: | rm -fv patches/amd-mainline/llvm-project/0003-HACK-Handle-ROCM-installation-layout-of-lib-llvm-bin.patch rm -fv patches/amd-mainline/llvm-project/0009-Add-gcc-toolset-13-prefix-detection.patch rm -fv patches/amd-mainline/llvm-project/0001-Ensure-to-use-libamdhip64-with-major-version.patch - name: Fetch sources timeout-minutes: 30 run: | cd L: git config fetch.parallel 10 git config --global core.symlinks true git config --global core.longpaths true python ./build_tools/fetch_sources.py --jobs 12 - name: TheRock and llvm SHA if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} run: | git config --global --add safe.directory $PWD git log --oneline -1 ls -l compiler/amd-llvm cd compiler/amd-llvm/llvm ls -l git log --oneline -3 cd - - name: Configure PR Projects if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.test_type != 'full') }} env: cmake_preset: ${{ inputs.build_variant_cmake_preset }} amdgpu_families: ${{ inputs.amdgpu_families }} package_version: ${{ inputs.package_version }} #extra_cmake_options: ${{ inputs.extra_cmake_options }} extra_cmake_options: "-DTHEROCK_ENABLE_ALL=OFF -DTHEROCK_ENABLE_COMPILER=ON -DTHEROCK_ENABLE_HIP_RUNTIME=ON -DTHEROCK_ENABLE_PRIM=ON -DTHEROCK_ENABLE_BLAS=ON -DTHEROCK_ENABLE_RAND=ON -DTHEROCK_ENABLE_SOLVER=ON -DTHEROCK_ENABLE_SPARSE=ON -DTHEROCK_ENABLE_SYSDEPS=OFF -DTHEROCK_ENABLE_COMPOSABLE_KERNEL=OFF -DTHEROCK_ENABLE_OCL_RUNTIME=ON -DTHEROCK_ENABLE_MATH_LIBS=ON -DLLVM_SMREV_REPO='' -DLLVM_SMREV_REVISION=''" run: | cd L: # clear cache before build and after download ccache -z python3 build_tools/github_actions/build_configure.py - name: Configure All Projects if: ${{ github.event_name != 'pull_request' && inputs.test_type == 'full' }} env: cmake_preset: ${{ inputs.build_variant_cmake_preset }} amdgpu_families: ${{ inputs.amdgpu_families }} package_version: ${{ inputs.package_version }} extra_cmake_options: ${{ inputs.extra_cmake_options }} run: | # clear cache before build and after download cd L: ccache -z cmake -B 'B:\build' -GNinja -S 'L:\' --preset windows-release -DTHEROCK_AMDGPU_FAMILIES=gfx1151 '-DCMAKE_C_COMPILER=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\/bin/Hostx64/x64/cl.exe' '-DCMAKE_CXX_COMPILER=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\/bin/Hostx64/x64/cl.exe' '-DCMAKE_LINKER=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\/bin/Hostx64/x64/link.exe' -DTHEROCK_BACKGROUND_BUILD_JOBS=4 - name: Build therock-archives and therock-dist run: | cd L: cmake --build "${{ env.BUILD_DIR }}" --target therock-archives therock-dist -- -j32 - name: Report if: ${{ !cancelled() }} shell: bash run: | if [ -d "${{ env.BUILD_DIR }}" ]; then echo "Build dir:" echo "------------" ls -lh "${{ env.BUILD_DIR }}" echo "Artifact Archives:" echo "------------------" ls -lh "${{ env.BUILD_DIR }}"/artifacts/*.tar.xz echo "Artifacts:" echo "----------" du -h -d 1 "${{ env.BUILD_DIR }}"/artifacts echo "CCache Stats:" echo "-------------" ccache -s else echo "[ERROR] Build directory ${{ env.BUILD_DIR }} does not exist. Skipping report!" echo " This should only happen if the CI is cancelled before the build step." exit 1 fi - name: "Build size report" if: always() shell: powershell run: | $fs = Get-PSDrive -PSProvider "FileSystem" $fsout = $fs | Select-Object -Property Name,Used,Free,Root $fsout | % {$_.Used/=1GB;$_.Free/=1GB;$_} | Write-Host get-disk | Select-object @{Name="Size(GB)";Expression={$_.Size/1GB}} | Write-Host - name: Configure AWS Credentials for non-forked repos if: ${{ github.repository == 'ROCm/TheRock' }} uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708 # v5.1.1 with: aws-region: us-east-2 role-to-assume: arn:aws:iam::692859939525:role/therock-ci-external special-characters-workaround: true - name: Post Build Upload if: always() run: | python3 build_tools/github_actions/post_build_upload.py \ --run-id ${{ github.run_id }} \ --artifact-group ${{ inputs.artifact_group }} \ --build-dir ${{ env.BUILD_DIR }} \ --upload - name: Remove Drive Substitution if: always() && steps.subst.outcome == 'success' shell: cmd run: | REM Remove the drive mapping subst L: /D