halide: 18.0.0 -> 19.0.0 (#375175)

This commit is contained in:
Gaétan Lepage 2025-01-30 12:10:55 +01:00 committed by GitHub
commit e2b93da896
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 92 additions and 42 deletions

View File

@ -4,6 +4,7 @@
lib,
fetchFromGitHub,
cmake,
fetchpatch2,
flatbuffers,
libffi,
libpng,
@ -14,71 +15,116 @@
openblas,
blas,
lapack,
removeReferencesTo,
ninja,
pythonSupport ? false,
python3Packages ? null,
python3Packages,
wasmSupport ? false,
wabt,
doCheck ? true,
}:
assert blas.implementation == "openblas" && lapack.implementation == "openblas";
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "halide";
version = "18.0.0";
version = "19.0.0";
src = fetchFromGitHub {
owner = "halide";
repo = "Halide";
rev = "v${version}";
hash = "sha256-BPalUh9EgdCqVaWC1HoreyyRcPQc4QMIYnLrRoNDDCI=";
tag = "v${finalAttrs.version}";
hash = "sha256-0SFGX4G6UR8NS4UsdFOb99IBq2/hEkr/Cm2p6zkIh/8=";
};
postPatch = ''
# See https://github.com/halide/Halide/issues/7785
substituteInPlace 'src/runtime/HalideRuntime.h' \
--replace '#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
#define HALIDE_CPP_COMPILER_HAS_FLOAT16' \
'#if defined(__x86_64__) || defined(__i386__)
#define HALIDE_CPP_COMPILER_HAS_FLOAT16'
'';
patches = [
# The following two patches fix cmake/HalidePackageConfigHelpers.cmake to
# support specifying an absolute library install path (which is what Nix
# does when "lib" is included as a separate output)
(fetchpatch2 {
url = "https://github.com/halide/Halide/commit/ac2cd23951aff9ac3b765e51938f1e576f1f0ee9.diff?full_index=1";
hash = "sha256-JTktOTSyReDUEHTaPPMoi+/K/Gzg39i6MI97cO3654k=";
})
(fetchpatch2 {
url = "https://github.com/halide/Halide/commit/59f4fff30f4ab628da9aa7e5f77a7f1bb218a779.diff?full_index=1";
hash = "sha256-yOzE+1jai1w1GQisLYfu8F9pbTE/bYg0MTLq8rPXdGk=";
})
];
postPatch =
''
substituteInPlace src/runtime/CMakeLists.txt --replace-fail \
'-isystem "''${VulkanHeaders_INCLUDE_DIR}"' \
'-isystem "''${VulkanHeaders_INCLUDE_DIR}"
-isystem "${llvmPackages.clang}/resource-root/include"'
''
# Upstream Halide include a check in their CMake files that forces Halide to
# link LLVM dynamically because of WebAssembly. It unnecessarily increases
# the closure size in cases when the WebAssembly target is not used. Hence,
# the following hack
+ lib.optionalString (!wasmSupport) ''
substituteInPlace cmake/FindHalide_LLVM.cmake --replace-fail \
'if (comp STREQUAL "WebAssembly")' \
'if (FALSE)'
'';
cmakeFlags = [
"-DWARNINGS_AS_ERRORS=OFF"
"-DWITH_PYTHON_BINDINGS=${if pythonSupport then "ON" else "OFF"}"
"-DTARGET_WEBASSEMBLY=OFF"
(lib.cmakeBool "WITH_TESTS" doCheck)
(lib.cmakeBool "WITH_TUTORIALS" doCheck)
# Disable performance tests since they may fail on busy machines
"-DWITH_TEST_PERFORMANCE=OFF"
# Disable fuzzing tests -- this has become the default upstream after the
# v16 release (See https://github.com/halide/Halide/commit/09c5d1d19ec8e6280ccbc01a8a12decfb27226ba)
# These tests also fail to compile on Darwin because of some missing command line options...
"-DWITH_TEST_FUZZ=OFF"
# Disable FetchContent for flatbuffers and use the version from nixpkgs instead
"-DFLATBUFFERS_USE_FETCHCONTENT=OFF"
"-DPYBIND11_USE_FETCHCONTENT=OFF"
# Disable FetchContent and use versions from nixpkgs instead
"-DHalide_USE_FETCHCONTENT=OFF"
"-DHalide_WASM_BACKEND=${if wasmSupport then "wabt" else "OFF"}"
(lib.cmakeBool "Halide_LLVM_SHARED_LIBS" wasmSupport)
];
doCheck = true;
outputs = [
"out"
"lib"
];
preCheck =
let
disabledTests = lib.strings.concatStringsSep "|" [
# Requires too much parallelism for remote builders.
"mullapudi2016_fibonacci"
# Take too long---we don't want to run these in CI.
"adams2019_test_apps_autoscheduler"
"anderson2021_test_apps_autoscheduler"
"correctness_cross_compilation"
"correctness_simd_op_check_hvx"
];
in
''
checkFlagsArray+=("ARGS=-E '${disabledTests}'")
'';
inherit doCheck;
postInstall = lib.optionalString pythonSupport ''
mkdir -p $out/${builtins.dirOf python3Packages.python.sitePackages}
mv -v $out/lib/python3/site-packages $out/${python3Packages.python.sitePackages}
rmdir $out/lib/python3/
disabledTests = [
# Requires too much parallelism for remote builders.
"mullapudi2016_fibonacci"
# Tests performance---flaky in CI
"mullapudi2016_reorder"
# Take too long---we don't want to run these in CI.
"adams2019_test_apps_autoscheduler"
"anderson2021_test_apps_autoscheduler"
"correctness_cross_compilation"
"correctness_simd_op_check_hvx"
];
# ninja's setup-hook doesn't let us specify custom flags for the checkPhase, see
# https://discourse.nixos.org/t/building-only-specific-targets-with-cmake/31545/4
# so we resort to overriding the whole checkPhase
dontUseNinjaCheck = true;
checkPhase = ''
runHook preCheck
ctest --exclude-regex '^(${lib.strings.concatStringsSep "|" finalAttrs.disabledTests})$'
runHook postCheck
'';
postInstall =
lib.optionalString pythonSupport ''
mkdir -p $lib/lib/${python3Packages.python.libPrefix}
mv -v $lib/lib/python3/site-packages $lib/lib/${python3Packages.python.libPrefix}
rmdir $lib/lib/python3/
''
# Debug symbols in the runtime include references to clang, but they're not
# required for running the code. llvmPackages.clang increases the runtime
# closure by at least a GB which is a waste, so we remove references to clang.
+ lib.optionalString (stdenv != llvmPackages.stdenv) ''
remove-references-to -t ${llvmPackages.clang} $lib/lib/libHalide*
'';
# Note: only openblas and not atlas part of this Nix expression
# see pkgs/development/libraries/science/math/liblapack/3.5.0.nix
# to get a hint howto setup atlas instead of openblas
@ -97,12 +143,15 @@ stdenv.mkDerivation rec {
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
libgbm
libGL
];
]
++ lib.optionals wasmSupport [ wabt ];
nativeBuildInputs =
[
cmake
flatbuffers
removeReferencesTo
ninja
]
++ lib.optionals pythonSupport [
python3Packages.python
@ -124,5 +173,6 @@ stdenv.mkDerivation rec {
atila
twesterhout
];
broken = !stdenv.buildPlatform.canExecute stdenv.hostPlatform;
};
}
})

View File

@ -3592,7 +3592,7 @@ with pkgs;
hal-hardware-analyzer = libsForQt5.callPackage ../applications/science/electronics/hal-hardware-analyzer { };
halide = callPackage ../development/compilers/halide {
llvmPackages = llvmPackages_18;
llvmPackages = llvmPackages_19;
};
hareThirdParty = recurseIntoAttrs (callPackage ./hare-third-party.nix { });

View File

@ -5793,7 +5793,7 @@ self: super: with self; {
hakuin = callPackage ../development/python-modules/hakuin { };
halide = toPythonModule (pkgs.halide.override { pythonSupport = true; python3Packages = self; });
halide = toPythonModule (pkgs.halide.override { pythonSupport = true; python3Packages = self; }).lib;
halo = callPackage ../development/python-modules/halo { };