diff --git a/.github/workflows/halide-prebuilt.yml b/.github/workflows/halide-prebuilt.yml index df7e33c..717f847 100644 --- a/.github/workflows/halide-prebuilt.yml +++ b/.github/workflows/halide-prebuilt.yml @@ -15,11 +15,15 @@ jobs: matrix: arch: [ x86_64, aarch64 ] os: [ windows, macos, ubuntu-20.04, ubuntu-22.04 ] - version: [ 16.0.0 ] + version: [ 14.0.0, 16.0.0 ] include: - os: windows + version: 16.0.0 runner: windows-2022 + - os: windows + version: 14.0.0 + runner: windows-2019 - os: macos runner: macos-12 - os: ubuntu-20.04 @@ -61,6 +65,19 @@ jobs: sudo apt install ninja-build sudo apt install g++-aarch64-linux-gnu + - name: Preflight + shell: pwsh + run: | + $LlvmVersion = if ('${{matrix.version}}' -eq "14.0.0") { "14.0.6" } else { "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 + - name: Install host clang+llvm shell: pwsh env: @@ -68,15 +85,10 @@ jobs: run: | $LlvmPlatform='${{matrix.os}}' $LlvmArch='x86_64' - $LlvmVersion = if ('${{matrix.version}}' -eq "14.0.0") { "14.0.6" } else { "16.0.6" } + $LlvmVersion = $Env:LLVM_VERSION + $LlvmRunId = $Env:LLVM_RUN_ID $LlvmName="clang+llvm-${LlvmVersion}-${LlvmArch}-${LlvmPlatform}" - $RunId = '${{ github.event.inputs.run_id }}' - if ($RunId -eq 'latest') { - $RunId = $(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 - } - & gh run download $RunId --repo $Env:GITHUB_REPOSITORY -n $LlvmName + & gh run download $LlvmRunId --repo $Env:GITHUB_REPOSITORY -n $LlvmName if ($IsWindows) { $TempDir = "C:/temp" $LLVM_PREFIX = "C:/llvm" @@ -88,11 +100,9 @@ jobs: tar -xvf "${LlvmName}.tar.xz" -C $TempDir sudo mv "$TempDir/${LlvmName}" $LLVM_PREFIX } - $LLVM_BIN_PATH="$LLVM_PREFIX/bin" + $LLVM_BIN_DIR="$LLVM_PREFIX/bin" $LLVM_DIR="$LLVM_PREFIX/lib/cmake/llvm" $CLANG_DIR="$LLVM_PREFIX/lib/cmake/clang" - echo "LLVM_X86_64_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV - echo "CLANG_X86_64_DIR=$CLANG_DIR" >> $Env:GITHUB_ENV echo "LLVM_HOST_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV echo "CLANG_HOST_DIR=$CLANG_DIR" >> $Env:GITHUB_ENV @@ -102,8 +112,8 @@ jobs: echo "CLANG_TARGET_DIR=$CLANG_DIR" >> $Env:GITHUB_ENV } - echo "LLVM_HOST_BIN_DIR=$LLVM_BIN_PATH" >> $Env:GITHUB_ENV - echo "PATH=$LLVM_BIN_PATH$([IO.Path]::PathSeparator)$Env:PATH" >> $Env:GITHUB_ENV + echo "LLVM_HOST_BIN_DIR=$LLVM_BIN_DIR" >> $Env:GITHUB_ENV + echo "PATH=$LLVM_BIN_DIR$([IO.Path]::PathSeparator)$Env:PATH" >> $Env:GITHUB_ENV - name: Install target clang+llvm if: matrix.arch == 'aarch64' @@ -113,15 +123,10 @@ jobs: run: | $LlvmPlatform='${{matrix.os}}' $LlvmArch='${{matrix.arch}}' - $LlvmVersion = if ('${{matrix.version}}' -eq "14.0.0") { "14.0.6" } else { "16.0.6" } + $LlvmVersion = $Env:LLVM_VERSION + $LlvmRunId = $Env:LLVM_RUN_ID $LlvmName="clang+llvm-${LlvmVersion}-${LlvmArch}-${LlvmPlatform}" - $RunId = '${{ github.event.inputs.run_id }}' - if ($RunId -eq 'latest') { - $RunId = $(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 - } - & gh run download $RunId --repo $Env:GITHUB_REPOSITORY -n $LlvmName + & gh run download $LlvmRunId --repo $Env:GITHUB_REPOSITORY -n $LlvmName if ($IsWindows) { $TempDir = "C:/temp" $LLVM_PREFIX = "C:/llvm-$LlvmArch" @@ -133,25 +138,18 @@ jobs: tar -xf "${LlvmName}.tar.xz" -C $TempDir sudo mv "$TempDir/${LlvmName}" $LLVM_PREFIX } - $LLVM_BIN_PATH="$LLVM_PREFIX/bin" + $LLVM_BIN_DIR="$LLVM_PREFIX/bin" $LLVM_DIR="$LLVM_PREFIX/lib/cmake/llvm" $CLANG_DIR="$LLVM_PREFIX/lib/cmake/clang" - echo "LLVM_AARCH64_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV - echo "CLANG_AARCH64_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV - echo "LLVM_TARGET_DIR=$LLVM_DIR" >> $Env:GITHUB_ENV echo "CLANG_TARGET_DIR=$CLANG_DIR" >> $Env:GITHUB_ENV $LLVM_HOST_BIN_DIR=$Env:LLVM_HOST_BIN_DIR - $LLVM_TARGET_BIN_DIR=$LLVM_BIN_PATH - if ($IsWindows) { - @('llvm-as.exe', 'clang.exe', 'clang-format.exe') | ForEach-Object { - Copy-Item -Path "${LLVM_HOST_BIN_DIR}\$_" -Destination "${LLVM_TARGET_BIN_DIR}\$_" -Force - } - } else { - @('llvm-as', 'clang', 'clang-format') | ForEach-Object { - Copy-Item -Path "${LLVM_HOST_BIN_DIR}/$_" -Destination "${LLVM_TARGET_BIN_DIR}/$_" -Force - } + $LLVM_TARGET_BIN_DIR=$LLVM_BIN_DIR + $ExeSuffix = if ($IsWindows) { ".exe" } else { "" } + @('llvm-as', 'clang', 'clang-format') | ForEach-Object { + $ExeFileName = "$_${ExeSuffix}" + Copy-Item -Path "${LLVM_HOST_BIN_DIR}/$ExeFileName" -Destination "${LLVM_TARGET_BIN_DIR}/$ExeFileName" -Force } - name: Clone project @@ -177,7 +175,6 @@ jobs: } else { git -C halide apply ../llvm-prebuilt/patches/halide-16-add-halide-host-tools-dir-cmake-option.patch git -C halide apply ../llvm-prebuilt/patches/halide-16-disable-autoschedulers.patch - git -C halide apply ../llvm-prebuilt/patches/halide-16-add-llvm-host-bin-dir-cmake-option.patch git -C halide apply ../llvm-prebuilt/patches/halide-16-disable-clang-verbose-build-warnings.patch } @@ -247,19 +244,15 @@ jobs: run: cmake --install halide-build - name: Package Halide - if: runner.os != 'Windows' - run: | - PACKAGE_NAME="halide-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}" - mv halide-install ./${PACKAGE_NAME} - tar -cJf ${PACKAGE_NAME}.tar.xz ${PACKAGE_NAME} - - - name: Package Halide - if: runner.os == 'Windows' shell: pwsh run: | - $PACKAGE_NAME="halide-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}" - mv halide-install $PACKAGE_NAME - cmd.exe /c "7z a -ttar -snl -so $PACKAGE_NAME.tar $PACKAGE_NAME | 7z a -si $PACKAGE_NAME.tar.xz" + $PackageName="halide-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}" + Move-Item halide-install $PackageName + if ($IsWindows) { + cmd.exe /c "7z a -ttar -snl -so $PackageName.tar $PackageName | 7z a -si $PackageName.tar.xz" + } else { + tar -cJf "${PackageName}.tar.xz" "${PackageName}" + } - name: Upload Halide package uses: actions/upload-artifact@v3 diff --git a/patches/halide-16-add-llvm-host-bin-dir-cmake-option.patch b/patches/halide-16-add-llvm-host-bin-dir-cmake-option.patch deleted file mode 100644 index 2eed786..0000000 --- a/patches/halide-16-add-llvm-host-bin-dir-cmake-option.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 7c51e8dfd9fa384b8a46574412238f9f0a1b2595 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= -Date: Tue, 7 Nov 2023 15:38:24 -0500 -Subject: [PATCH] [PATCH] add LLVM_HOST_BIN_DIR cmake option - ---- - dependencies/llvm/CMakeLists.txt | 22 ++++++++++++++++++---- - 1 file changed, 18 insertions(+), 4 deletions(-) - -diff --git a/dependencies/llvm/CMakeLists.txt b/dependencies/llvm/CMakeLists.txt -index bfb6967f3..85609e652 100644 ---- a/dependencies/llvm/CMakeLists.txt -+++ b/dependencies/llvm/CMakeLists.txt -@@ -11,7 +11,7 @@ set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO RelWithDebInfo Release MinSizeRel " - set(CMAKE_MAP_IMPORTED_CONFIG_RELEASE Release MinSizeRel RelWithDebInfo "") - - find_package(LLVM ${Halide_REQUIRE_LLVM_VERSION} REQUIRED) --find_package(Clang REQUIRED CONFIG HINTS "${LLVM_DIR}/../clang" "${LLVM_DIR}/../lib/cmake/clang") -+find_package(Clang REQUIRED CONFIG HINTS "${Clang_DIR}" "${LLVM_DIR}/../clang" "${LLVM_DIR}/../lib/cmake/clang") - - set(LLVM_PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}" - CACHE INTERNAL "LLVM version") -@@ -58,11 +58,25 @@ cmake_dependent_option(Halide_BUNDLE_LLVM "When built as a static library, inclu - # Promote LLVM/Clang executable targets - ## - --set_target_properties(llvm-as clang PROPERTIES IMPORTED_GLOBAL TRUE) -+if (LLVM_HOST_BIN_DIR) -+ set_target_properties(llvm-as clang PROPERTIES IMPORTED_GLOBAL TRUE) -+ set_property(TARGET llvm-as PROPERTY IMPORTED_LOCATION -+ "${LLVM_HOST_BIN_DIR}/llvm-as${CMAKE_EXECUTABLE_SUFFIX}") -+ set_property(TARGET clang PROPERTY IMPORTED_LOCATION -+ "${LLVM_HOST_BIN_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}") - --# clang-tools-extra is optional, but provides the clang-format target --if (TARGET clang-format) -+ if (TARGET clang-format) - set_target_properties(clang-format PROPERTIES IMPORTED_GLOBAL TRUE) -+ set_property(TARGET clang-format PROPERTY IMPORTED_LOCATION -+ "${LLVM_HOST_BIN_DIR}/clang-format${CMAKE_EXECUTABLE_SUFFIX}") -+ endif () -+else () -+ set_target_properties(llvm-as clang PROPERTIES IMPORTED_GLOBAL TRUE) -+ -+ # clang-tools-extra is optional, but provides the clang-format target -+ if (TARGET clang-format) -+ set_target_properties(clang-format PROPERTIES IMPORTED_GLOBAL TRUE) -+ endif () - endif () - - ## --- -2.25.1 -