diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index 006de1aaed12..059e38929c4c 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -40,8 +40,12 @@ jobs: runs-on: macos-14 steps: - uses: actions/checkout@v4 - - name: Install clang-tidy - run: brew install llvm@21 lld@21 + + # We intentionally don't use VCPKG here so that we get some + # notification that the ecosystem is moving on without us. + - name: Install clang-tidy & dependencies + run: brew install flatbuffers llvm@21 lld@21 pybind11 wabt + - name: Run clang-tidy run: ./run-clang-tidy.sh env: diff --git a/.github/workflows/testing-arm-linux.yml b/.github/workflows/testing-arm-linux.yml index a04944fe5c38..48ee5b157fd8 100644 --- a/.github/workflows/testing-arm-linux.yml +++ b/.github/workflows/testing-arm-linux.yml @@ -78,17 +78,7 @@ jobs: run: echo "Halide_LLVM_ROOT=$(halide-llvm --prefix)" >> "$GITHUB_ENV" - name: Configure CMake - run: | - TOOLCHAIN_ARGS=() - if [[ "${{ matrix.bits }}" == "32" ]]; then - TOOLCHAIN_ARGS+=("-DCMAKE_TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/cmake/toolchain.linux-arm32.cmake") - fi - - cmake -G Ninja -S . -B build \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DHalide_LLVM_ROOT="${Halide_LLVM_ROOT}" \ - -DWITH_PYTHON_BINDINGS=OFF \ - "${TOOLCHAIN_ARGS[@]}" + run: cmake --preset ci-linux-arm-${{ matrix.bits }} - name: Initial build run: cmake --build build diff --git a/.github/workflows/testing-linux.yml b/.github/workflows/testing-linux.yml index ee5954871253..9e6954a5a39c 100644 --- a/.github/workflows/testing-linux.yml +++ b/.github/workflows/testing-linux.yml @@ -75,19 +75,7 @@ jobs: run: echo "Halide_LLVM_ROOT=$(halide-llvm --prefix)" >> "$GITHUB_ENV" - name: Configure CMake - run: | - TOOLCHAIN_ARGS=() - if [[ "${{ matrix.bits }}" == "32" ]]; then - TOOLCHAIN_ARGS+=( - "-DCMAKE_TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/cmake/toolchain.linux-i386.cmake" - "-DWITH_PYTHON_BINDINGS=OFF" - ) - fi - - cmake -G Ninja -S . -B build \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DHalide_LLVM_ROOT="${Halide_LLVM_ROOT}" \ - "${TOOLCHAIN_ARGS[@]}" + run: cmake --preset ci-linux-x86-${{ matrix.bits }} - name: Initial build run: cmake --build build diff --git a/.github/workflows/testing-windows.yml b/.github/workflows/testing-windows.yml index 001eead19a02..b03e5bde6d1e 100644 --- a/.github/workflows/testing-windows.yml +++ b/.github/workflows/testing-windows.yml @@ -63,21 +63,7 @@ jobs: run: echo "Halide_LLVM_ROOT=$(halide-llvm --prefix)" >> "$GITHUB_ENV" - name: Configure CMake - run: | - # NB: vcpkg docs use VCPKG_ROOT, but GHA runners use VCPKG_INSTALLATION_ROOT - TOOLCHAIN_ARGS=( - "-DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" - "-DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-windows" - "-DVCPKG_MANIFEST_FEATURES=developer" - ) - if [[ "${{ matrix.bits }}" == "32" ]]; then - TOOLCHAIN_ARGS+=("-DWITH_PYTHON_BINDINGS=OFF") - fi - - cmake -G Ninja -S . -B build \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DHalide_LLVM_ROOT="${Halide_LLVM_ROOT}" \ - "${TOOLCHAIN_ARGS[@]}" + run: cmake --preset ci-windows-x86-${{ matrix.bits }} - name: Initial build run: cmake --build build diff --git a/CMakeLists.txt b/CMakeLists.txt index 5aceebd61679..c776cfd505e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,4 @@ cmake_minimum_required(VERSION 3.28) - -# TODO: remove this after updating build bots. -if (CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg") - if (NOT DEFINED VCPKG_MANIFEST_FEATURES) - set(VCPKG_MANIFEST_FEATURES developer) - endif () - - # vcpkg and FetchContent are incompatible - set(Halide_USE_FETCHCONTENT OFF) -endif () - -option(Halide_USE_FETCHCONTENT "When Halide is top-level, use FetchContent for build-time dependencies." ON) -if (Halide_USE_FETCHCONTENT) - list(APPEND CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${CMAKE_CURRENT_LIST_DIR}/cmake/dependencies.cmake") -endif () - project(Halide VERSION 22.0.0 DESCRIPTION "Halide compiler and libraries" diff --git a/CMakePresets.json b/CMakePresets.json index cf6d7b9f39f0..abc1421f37aa 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,11 +15,59 @@ { "name": "ci", "hidden": true, - "inherits": "base", - "toolchainFile": "${sourceDir}/cmake/toolchain.${presetName}.cmake", + "binaryDir": "build", + "installDir": "local", + "generator": "Ninja", + "toolchainFile": "$env{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake", "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "Halide_LLVM_SHARED_LIBS": false + "FETCHCONTENT_FULLY_DISCONNECTED": "ON", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/cmake/toolchain.${presetName}.cmake", + "VCPKG_MANIFEST_FEATURES": "developer" + } + }, + { + "name": "ci-linux-x86-64", + "inherits": "ci" + }, + { + "name": "ci-linux-x86-32", + "inherits": "ci", + "cacheVariables": { + "WITH_PYTHON_BINDINGS": "NO" + } + }, + { + "name": "ci-linux-arm-64", + "inherits": "ci", + "cacheVariables": { + "WITH_PYTHON_BINDINGS": "NO" + } + }, + { + "name": "ci-linux-arm-32", + "inherits": "ci", + "cacheVariables": { + "WITH_PYTHON_BINDINGS": "NO" + } + }, + { + "name": "ci-macos-arm-64", + "inherits": "ci" + }, + { + "name": "ci-macos-x86-64", + "inherits": "ci" + }, + { + "name": "ci-windows-x86-64", + "inherits": "ci" + }, + { + "name": "ci-windows-x86-32", + "inherits": "ci", + "cacheVariables": { + "WITH_PYTHON_BINDINGS": "NO" } }, { @@ -30,7 +78,7 @@ "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", "cacheVariables": { "VCPKG_MANIFEST_FEATURES": "developer", - "Halide_USE_FETCHCONTENT": false + "FETCHCONTENT_FULLY_DISCONNECTED": "ON" } }, { @@ -121,49 +169,6 @@ "displayName": "macOS (vcpkg)", "description": "macOS build with vcpkg dependencies" }, - { - "name": "package", - "hidden": true, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release", - "LLVM_DIR": "$env{LLVM_DIR}", - "Clang_DIR": "$env{Clang_DIR}", - "LLD_DIR": "$env{LLD_DIR}", - "WITH_TESTS": "NO", - "WITH_TUTORIALS": "NO", - "WITH_DOCS": "YES", - "WITH_UTILS": "YES", - "WITH_PYTHON_BINDINGS": "NO", - "CMAKE_INSTALL_DATADIR": "share/Halide" - } - }, - { - "name": "package-windows", - "inherits": [ - "package", - "vs2022" - ], - "displayName": "Package ZIP for Windows", - "description": "Build for packaging Windows shared libraries.", - "binaryDir": "${sourceDir}/build", - "cacheVariables": { - "BUILD_SHARED_LIBS": "YES", - "CMAKE_INSTALL_BINDIR": "bin/$", - "CMAKE_INSTALL_LIBDIR": "lib/$", - "Halide_INSTALL_CMAKEDIR": "lib/cmake/Halide", - "Halide_INSTALL_HELPERSDIR": "lib/cmake/HalideHelpers" - } - }, - { - "name": "package-unix", - "inherits": "package", - "displayName": "Package UNIX shared libs", - "description": "Build for packaging UNIX shared libraries.", - "binaryDir": "shared-Release", - "cacheVariables": { - "BUILD_SHARED_LIBS": "YES" - } - }, { "name": "linux-x64-asan", "inherits": "ci", @@ -195,72 +200,5 @@ "BUILD_SHARED_LIBS": "NO" } } - ], - "buildPresets": [ - { - "name": "debug", - "configurePreset": "debug", - "displayName": "Debug", - "description": "Debug build with no special settings" - }, - { - "name": "release", - "configurePreset": "release", - "displayName": "Release", - "description": "Release build with no special settings" - }, - { - "name": "linux-x64-asan", - "configurePreset": "linux-x64-asan", - "displayName": "ASAN (Linux x64)", - "description": "Build everything with ASAN enabled" - }, - { - "name": "linux-x64-fuzzer", - "configurePreset": "linux-x64-fuzzer", - "displayName": "Fuzzing (Linux x64)", - "description": "Build everything with fuzzing enabled" - } - ], - "testPresets": [ - { - "name": "debug", - "configurePreset": "debug", - "displayName": "Debug", - "description": "Test everything with Debug build", - "output": { - "outputOnFailure": true - } - }, - { - "name": "release", - "configurePreset": "release", - "displayName": "Release", - "description": "Test everything with Release build", - "output": { - "outputOnFailure": true - } - }, - { - "name": "linux-x64-asan", - "configurePreset": "linux-x64-asan", - "displayName": "ASAN (Linux x64)", - "description": "Test everything with ASAN enabled", - "environment": { - "ASAN_OPTIONS": "detect_leaks=0:detect_container_overflow=0" - }, - "output": { - "outputOnFailure": true - } - }, - { - "name": "linux-x64-fuzzer", - "configurePreset": "linux-x64-fuzzer", - "displayName": "Fuzzing (Linux x64)", - "description": "Test everything with fuzzing enabled", - "output": { - "outputOnFailure": true - } - } ] } diff --git a/apps/vcpkg.json b/apps/vcpkg.json index 9420a5f7ec93..af06e85f6de8 100644 --- a/apps/vcpkg.json +++ b/apps/vcpkg.json @@ -12,7 +12,10 @@ "eigen3", "libjpeg-turbo", "libpng", - "openblas", + { + "name": "openblas", + "platform": "(windows & x64 & !uwp & !xbox) | (linux & x64) | (linux & arm64)" + }, { "name": "opencl", "platform": "(windows & x64 & !uwp & !xbox) | (linux & x64) | (linux & arm64)" diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake deleted file mode 100644 index 7a887f2b76ed..000000000000 --- a/cmake/dependencies.cmake +++ /dev/null @@ -1,77 +0,0 @@ -include(FetchContent) - -FetchContent_Declare( - flatbuffers - GIT_REPOSITORY https://github.com/google/flatbuffers.git - GIT_TAG 0100f6a5779831fa7a651e4b67ef389a8752bd9b # v23.5.26 - GIT_SHALLOW TRUE - SYSTEM -) - -FetchContent_Declare( - pybind11 - GIT_REPOSITORY https://github.com/pybind/pybind11.git - GIT_TAG 8a099e44b3d5f85b20f05828d919d2332a8de841 # v2.11.1 - GIT_SHALLOW TRUE - SYSTEM -) - -FetchContent_Declare( - wabt - GIT_REPOSITORY https://github.com/WebAssembly/wabt.git - GIT_TAG ad75c5edcdff96d73c245b57fbc07607aaca9f95 # 1.0.39 - GIT_SHALLOW TRUE - SYSTEM -) - -macro(Halide_provide_dependency method dep_name) - set(${dep_name}_FOUND 1) - - ## Set up sub-builds for Halide's requirements - if ("${dep_name}" STREQUAL "flatbuffers") - set(FLATBUFFERS_BUILD_TESTS OFF) - set(FLATBUFFERS_INSTALL OFF) - elseif ("${dep_name}" STREQUAL "pybind11") - # No special build options necessary - elseif ("${dep_name}" STREQUAL "wabt") - set(WITH_EXCEPTIONS "${Halide_ENABLE_EXCEPTIONS}") - set(BUILD_TESTS OFF) - set(BUILD_TOOLS OFF) - set(BUILD_LIBWASM OFF) - set(USE_INTERNAL_SHA256 ON) - else () - set(${dep_name}_FOUND 0) - endif () - - if (${dep_name}_FOUND) - list(APPEND Halide_provide_dependency_args "${method}" "${dep_name}") - FetchContent_MakeAvailable(${dep_name}) - list(POP_BACK Halide_provide_dependency_args method dep_name) - - ## Patches for broken packages - if ("${dep_name}" STREQUAL "flatbuffers") - if (NOT TARGET flatbuffers::flatbuffers) - add_library(flatbuffers::flatbuffers ALIAS flatbuffers) - add_executable(flatbuffers::flatc ALIAS flatc) - set_target_properties( - flatbuffers flatc - PROPERTIES - EXPORT_COMPILE_COMMANDS OFF - ) - endif () - endif () - if ("${dep_name}" STREQUAL "wabt") - set_target_properties( - wabt wasm-rt-impl - PROPERTIES - POSITION_INDEPENDENT_CODE ON - EXPORT_COMPILE_COMMANDS OFF - ) - endif () - endif () -endmacro() - -cmake_language( - SET_DEPENDENCY_PROVIDER Halide_provide_dependency - SUPPORTED_METHODS FIND_PACKAGE -) diff --git a/cmake/toolchain.ci-linux-arm-32.cmake b/cmake/toolchain.ci-linux-arm-32.cmake new file mode 100644 index 000000000000..5cb9c493d0d5 --- /dev/null +++ b/cmake/toolchain.ci-linux-arm-32.cmake @@ -0,0 +1,11 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) + +set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) +set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) + +set(CMAKE_C_FLAGS_INIT "-mfp16-format=ieee -Wno-psabi") +set(CMAKE_CXX_FLAGS_INIT "-mfp16-format=ieee -Wno-psabi") + +set(VCPKG_TARGET_TRIPLET arm-linux) +set(CMAKE_CROSSCOMPILING FALSE) diff --git a/cmake/toolchain.ci-linux-arm-64.cmake b/cmake/toolchain.ci-linux-arm-64.cmake new file mode 100644 index 000000000000..53e63bde0cdf --- /dev/null +++ b/cmake/toolchain.ci-linux-arm-64.cmake @@ -0,0 +1 @@ +# Native AArch64 Linux build. No toolchain configuration needed. \ No newline at end of file diff --git a/cmake/toolchain.ci-linux-x86-32.cmake b/cmake/toolchain.ci-linux-x86-32.cmake new file mode 100644 index 000000000000..5d9ab03994b4 --- /dev/null +++ b/cmake/toolchain.ci-linux-x86-32.cmake @@ -0,0 +1,11 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR i686) + +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) + +set(CMAKE_CXX_FLAGS_INIT "-m32") +set(CMAKE_C_FLAGS_INIT "-m32") + +set(VCPKG_TARGET_TRIPLET x86-linux) +set(CMAKE_CROSSCOMPILING FALSE) diff --git a/cmake/toolchain.ci-linux-x86-64.cmake b/cmake/toolchain.ci-linux-x86-64.cmake new file mode 100644 index 000000000000..c619faabc54c --- /dev/null +++ b/cmake/toolchain.ci-linux-x86-64.cmake @@ -0,0 +1 @@ +# Native x86-64 Linux build. No toolchain configuration needed. \ No newline at end of file diff --git a/cmake/toolchain.ci-macos-arm-64.cmake b/cmake/toolchain.ci-macos-arm-64.cmake new file mode 100644 index 000000000000..81120b0a197c --- /dev/null +++ b/cmake/toolchain.ci-macos-arm-64.cmake @@ -0,0 +1 @@ +# Native ARM64 macOS build. No toolchain configuration needed. \ No newline at end of file diff --git a/cmake/toolchain.ci-macos-x86-64.cmake b/cmake/toolchain.ci-macos-x86-64.cmake new file mode 100644 index 000000000000..4f27ee2fbe93 --- /dev/null +++ b/cmake/toolchain.ci-macos-x86-64.cmake @@ -0,0 +1 @@ +# Native x86-64 macOS build. No toolchain configuration needed. \ No newline at end of file diff --git a/cmake/toolchain.ci-windows-x86-32.cmake b/cmake/toolchain.ci-windows-x86-32.cmake new file mode 100644 index 000000000000..01bf380734f9 --- /dev/null +++ b/cmake/toolchain.ci-windows-x86-32.cmake @@ -0,0 +1,2 @@ +# 32-bit Windows build. The Developer Command Prompt environment +# provides the correct compiler, so no toolchain configuration is needed here. \ No newline at end of file diff --git a/cmake/toolchain.ci-windows-x86-64.cmake b/cmake/toolchain.ci-windows-x86-64.cmake new file mode 100644 index 000000000000..d1f9a892ed8f --- /dev/null +++ b/cmake/toolchain.ci-windows-x86-64.cmake @@ -0,0 +1 @@ +# Native x86-64 Windows build. No toolchain configuration needed. \ No newline at end of file diff --git a/cmake/toolchain.linux-arm32.cmake b/cmake/toolchain.linux-arm32.cmake deleted file mode 100644 index 8957fde34191..000000000000 --- a/cmake/toolchain.linux-arm32.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# Toolchain for cross-compiling to Linux-arm32 on a Linux-x86-64 or Linux-aarch64 host. -# -# If you just want to crosscompile, you need to install: -# -# apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf -# -# On an aarch64 host, you can also run the results if you: -# -# dpkg --add-architecture armhf -# apt-get install libc6:armhf libstdc++6:armhf - -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR arm) - -if (NOT DEFINED CMAKE_C_COMPILER) - set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) -endif () -if (NOT DEFINED CMAKE_CXX_COMPILER) - set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) -endif () - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -set(CMAKE_C_FLAGS_INIT "-mfp16-format=ieee -Wno-psabi") -set(CMAKE_CXX_FLAGS_INIT "-mfp16-format=ieee -Wno-psabi") - -# add_custom_command() will make bad decisions about running the command -# when crosscompiling (it won't expand the target into a full path). -# Setting CMAKE_CROSSCOMPILING_EMULATOR to /usr/bin/env tricks it into -# doing the right thing (ie, running it directly). Note that if you want -# to build/run on x86-64 systems, you could set this to some qemu command\ -# (though the results will likely be very slow). -set(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/env) diff --git a/cmake/toolchain.linux-i386.cmake b/cmake/toolchain.linux-i386.cmake deleted file mode 100644 index f7b4dae5df70..000000000000 --- a/cmake/toolchain.linux-i386.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# Toolchain for cross-compiling to Linux-i386 on a Linux-x86-64 host. - -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR i686) - -set(CMAKE_CXX_FLAGS_INIT -m32) -set(CMAKE_C_FLAGS_INIT -m32) - -set(CMAKE_EXE_LINKER_FLAGS_INIT -m32) -set(CMAKE_SHARED_LINKER_FLAGS_INIT -m32) -set(CMAKE_MODULE_LINKER_FLAGS_INIT -m32) - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -set(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/env) diff --git a/cmake/vcpkg-triplets/arm-linux.cmake b/cmake/vcpkg-triplets/arm-linux.cmake new file mode 100644 index 000000000000..9100c5281a9d --- /dev/null +++ b/cmake/vcpkg-triplets/arm-linux.cmake @@ -0,0 +1,8 @@ +set(VCPKG_TARGET_ARCHITECTURE arm) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) + +set(VCPKG_C_FLAGS "-mfp16-format=ieee -Wno-psabi") +set(VCPKG_CXX_FLAGS "-mfp16-format=ieee -Wno-psabi") diff --git a/doc/BuildingHalideWithCMake.md b/doc/BuildingHalideWithCMake.md index adf2fcc7eadf..fe3f7bf7cc23 100644 --- a/doc/BuildingHalideWithCMake.md +++ b/doc/BuildingHalideWithCMake.md @@ -230,7 +230,7 @@ necessary, it is convenient to install Python system-wide on Windows (i.e. `C:\Program Files`) because CMake looks at standard paths and registry keys. This removes the need to manually set the `PATH`. -Once Python is installed, you can install the Python module dependencies in +Once Python is installed, you can install the Python module dependencies in a [virtual environment][venv] by running ```shell @@ -444,12 +444,12 @@ The following options are _advanced_ and should not be required in typical workflows. Generally, these are used by Halide's own CI infrastructure, or as escape hatches for third-party packagers. -| Option | Default | Description | -|-----------------------------|--------------------------------------------------------------------|------------------------------------------------------------------------------------------| -| `Halide_CCACHE_BUILD` | `OFF` | Use ccache with Halide-recommended settings to accelerate rebuilds. | -| `Halide_CCACHE_PARAMS` | `CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines` | Options to pass to `ccache` when using `Halide_CCACHE_BUILD`. | -| `Halide_VERSION_OVERRIDE` | `${Halide_VERSION}` | Override the VERSION for libHalide. | -| `Halide_SOVERSION_OVERRIDE` | `${Halide_VERSION_MAJOR}` | Override the SOVERSION for libHalide. Expects a positive integer (i.e. not a version). | +| Option | Default | Description | +|-----------------------------|--------------------------------------------------------------------|----------------------------------------------------------------------------------------| +| `Halide_CCACHE_BUILD` | `OFF` | Use ccache with Halide-recommended settings to accelerate rebuilds. | +| `Halide_CCACHE_PARAMS` | `CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines` | Options to pass to `ccache` when using `Halide_CCACHE_BUILD`. | +| `Halide_VERSION_OVERRIDE` | `${Halide_VERSION}` | Override the VERSION for libHalide. | +| `Halide_SOVERSION_OVERRIDE` | `${Halide_VERSION_MAJOR}` | Override the SOVERSION for libHalide. Expects a positive integer (i.e. not a version). | The following options control whether to build certain test subsets. They only apply when `WITH_TESTS=ON`: @@ -501,10 +501,9 @@ install it into the currently active Python environment. However, this comes with a few caveats: -1. `Halide_USE_FETCHCONTENT` is disabled, so the environment must be prepared - for CMake to find its dependencies. This is easiest to do by setting either - `CMAKE_PREFIX_PATH` to pre-built dependencies or by setting - `CMAKE_TOOLCHAIN_FILE` to vcpkg. +1. The environment must be prepared for CMake to find its dependencies. This is + easiest to do by setting either `CMAKE_PREFIX_PATH` to pre-built dependencies + or by setting `CMAKE_TOOLCHAIN_FILE` to vcpkg. 2. The build settings are fixed, meaning that `wabt` is required on non-Windows systems, `flatbuffers` is always required, and the Python bindings must be built. @@ -577,8 +576,8 @@ Local storage: Misses: 0 / 1079 ( 0.00%) ``` -On this test system (an M3 MacBook Pro), the build is three times faster, -with a 100% cache hit rate! +On this test system (an M3 MacBook Pro), the build is three times faster, with a +100% cache hit rate! [ATLAS]: http://math-atlas.sourceforge.net/ diff --git a/doc/CodeStyleCMake.md b/doc/CodeStyleCMake.md index 6a08d1b77317..0df6c36a5211 100644 --- a/doc/CodeStyleCMake.md +++ b/doc/CodeStyleCMake.md @@ -137,14 +137,14 @@ There are also several functions that are disallowed for other reasons: | `include_external_msproject` | Halide must remain portable | Write a CMake package config file or find module. | | `include_guard` | Use of recursive inclusion is not allowed | Write (recursive) functions. | | `include_regular_expression` | Changes default dependency checking behavior | None | -| `load_cache` | Superseded by [`FetchContent`][FetchContent]/[`ExternalProject`][ExternalProject] | Use aforementioned modules | +| `load_cache` | Superseded by [`FetchContent`][FetchContent]/[`ExternalProject`][ExternalProject] | Write a vcpkg port or present a case for an exception. | | `macro` | CMake macros are not hygienic and are therefore error-prone | Use functions instead. | | `site_name` | Privacy: do not want leak host name information | Provide a cache variable, generate a unique name. | | `variable_watch` | Debugging helper | None. Not needed in production. | Do not introduce any dependencies via [`find_package`][find_package] -without broader approval. Importantly, never introduce a new use of -`FetchContent`; prefer to add dependencies to `vcpkg.json`. +without broader approval. Importantly, never introduce a use of `FetchContent`. +Add dependencies to `vcpkg.json` or create a custom port. ## Prohibited variables list diff --git a/pyproject.toml b/pyproject.toml index 95b311ab43a3..f3045587aa42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,10 +109,10 @@ metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" [tool.scikit-build.cmake.define] CMAKE_DISABLE_FIND_PACKAGE_JPEG = true CMAKE_DISABLE_FIND_PACKAGE_PNG = true +FETCHCONTENT_FULLY_DISCONNECTED = true Halide_ENABLE_EXCEPTIONS = true Halide_ENABLE_RTTI = true Halide_INSTALL_PYTHONDIR = "." -Halide_USE_FETCHCONTENT = false Halide_WASM_BACKEND = "wabt" WITH_PYTHON_BINDINGS = true WITH_TESTS = false diff --git a/python_bindings/src/halide/halide_/PyIROperator.cpp b/python_bindings/src/halide/halide_/PyIROperator.cpp index aa2a667e79bd..55e19786b7cf 100644 --- a/python_bindings/src/halide/halide_/PyIROperator.cpp +++ b/python_bindings/src/halide/halide_/PyIROperator.cpp @@ -36,7 +36,7 @@ T cast_arg(const py::handle &arg) { } catch (const py::cast_error &) { _halide_user_error << "select(): Expected " << py::str(py::type::of().attr("__name__")) - << " but got " << py::str(arg.get_type().attr("__name__")) << ": " + << " but got " << py::str(py::type::of(arg).attr("__name__")) << ": " << py::str(arg); } } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 162bb6f74e4e..f8085eb5cda8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -530,12 +530,7 @@ if (WITH_SERIALIZATION) ) _Halide_pkgdep(flatbuffers) - if (Halide_USE_FETCHCONTENT AND NOT BUILD_SHARED_LIBS) - target_sources(Halide PRIVATE "$") - target_link_libraries(Halide PRIVATE "$>") - else () - target_link_libraries(Halide PRIVATE flatbuffers::flatbuffers) - endif () + target_link_libraries(Halide PRIVATE flatbuffers::flatbuffers) set(fb_def "${CMAKE_CURRENT_SOURCE_DIR}/halide_ir.fbs") set(fb_dir "${Halide_BINARY_DIR}/include/flatc") @@ -591,13 +586,7 @@ if (Halide_WASM_BACKEND STREQUAL "wabt") find_package(wabt 1.0.39 REQUIRED) _Halide_pkgdep(wabt) - if (Halide_USE_FETCHCONTENT AND NOT BUILD_SHARED_LIBS) - target_sources(Halide PRIVATE "$") - target_link_libraries(Halide PRIVATE "$>") - else () - target_link_libraries(Halide PRIVATE wabt::wabt) - endif () - + target_link_libraries(Halide PRIVATE wabt::wabt) target_compile_definitions(Halide PRIVATE WITH_WABT) elseif (Halide_WASM_BACKEND STREQUAL "V8") find_package(V8 REQUIRED) diff --git a/src/runtime/hexagon_remote/CMakeLists.txt b/src/runtime/hexagon_remote/CMakeLists.txt index c5fe73ab7405..0e0b92f13b5f 100644 --- a/src/runtime/hexagon_remote/CMakeLists.txt +++ b/src/runtime/hexagon_remote/CMakeLists.txt @@ -27,8 +27,16 @@ set(common_cache_args "-DCMAKE_INSTALL_PREFIX:PATH=" ) -if (CMAKE_BUILD_TYPE) - list(APPEND common_cache_args "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}") +# The Hexagon SDK toolchain only handles Release and Debug build types. +# Map other types (e.g. RelWithDebInfo) to the appropriate one. +if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE STREQUAL "Debug") + set(_hexagon_build_type "${CMAKE_BUILD_TYPE}") +else () + set(_hexagon_build_type "Release") +endif () + +if (_hexagon_build_type) + list(APPEND common_cache_args "-DCMAKE_BUILD_TYPE:STRING=${_hexagon_build_type}") endif () ExternalProject_Add( diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index efc8ed739b69..d7954f111667 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -1,5 +1,8 @@ { "overlay-ports": [ "cmake/vcpkg" + ], + "overlay-triplets": [ + "cmake/vcpkg-triplets" ] } diff --git a/vcpkg.json b/vcpkg.json index b06eea986832..6a404753c8eb 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -36,7 +36,14 @@ "name": "halide", "default-features": false, "features": [ - "python-bindings", + "python-bindings" + ], + "platform": "x64 | arm64" + }, + { + "name": "halide", + "default-features": false, + "features": [ "serialization", "wasm-executor" ]