diff --git a/.github/actions/build.sh b/.github/actions/build.sh index 011b26708e4..5e8b0858fef 100755 --- a/.github/actions/build.sh +++ b/.github/actions/build.sh @@ -12,8 +12,9 @@ # - The build output is structured into log groups by package. # - As the disk space in the workflow environment is limitted, we clean the # work folder of each package after build. At 2020.06 this limit is 14GB. -# - ffmpeg5 and ffmpeg6 are not cleaned to be available for dependents. -# - Therefore ffmpeg5 and ffmpeg6 are built first if triggered by its +# - synocli-videodriver and ffmpeg5-6 are not cleaned to be available for dependents. +# - Therefore synocli-videodriver is built first if triggered by ffmpeg5-6 +# - Therefore ffmpeg5 and ffmpeg6 are built second if triggered by its # own or a dependent (see prepare.sh). set -o pipefail @@ -59,7 +60,7 @@ if [ -n "$API_KEY" ] && [ "$PUBLISH" == "true" ]; then fi # Build -PACKAGES_TO_KEEP="ffmpeg5 ffmpeg6 python310 python311" +PACKAGES_TO_KEEP="synocli-videodriver ffmpeg5 ffmpeg6 python310 python311" for package in ${build_packages} do echo "::group:: ---- build ${package}" diff --git a/.github/actions/prepare.sh b/.github/actions/prepare.sh index c0c4368c90a..11e71f55be4 100755 --- a/.github/actions/prepare.sh +++ b/.github/actions/prepare.sh @@ -6,7 +6,8 @@ # # Functions: # - Evaluate all packages to build depending on files defined in ${GH_FILES}. -# - python310, python311, ffmpeg5 and ffmpeg6 are moved to head of packages to build first if triggered by its own or a dependent. +# - synocli-videodriver is moved to head of packages to build first if triggered by its ffmpeg5-6 +# - python310-311 and ffmpeg5-6 are moved to head of remaining packages to build when triggered by its own or a dependent. # - Referenced native and cross packages of the packages to build are added to the download list. set -o pipefail @@ -53,12 +54,12 @@ fi # remove duplicate packages packages=$(printf %s "${SPK_TO_BUILD}" | tr ' ' '\n' | sort -u | tr '\n' ' ') -# for ffmpeg v4-6 find all packages that depend on them +# for ffmpeg v5-6 find all packages that depend on them for i in {5..6}; do - ffmpeg_dependent_packages=$(find spk/ -maxdepth 2 -mindepth 2 -name "Makefile" -exec grep -Ho "FFMPEG_VERSION = ${i}" {} \; | grep -Po ".*spk/\K[^/]*" | sort | tr '\n' ' ') + ffmpeg_dependent_packages=$(find spk/ -maxdepth 2 -mindepth 2 -name "Makefile" -exec grep -Ho "FFMPEG_PACKAGE = ffmpeg${i}" {} \; | grep -Po ".*spk/\K[^/]*" | sort | tr '\n' ' ') - # If packages contain a package that depends on ffmpeg (or is ffmpeg), then ensure - # relevant ffmpeg5|ffmpeg6 is first in list + # If packages contain a package that depends on ffmpeg (or is ffmpeg), + # then ensure relevant ffmpeg5|ffmpeg6 is first in list for package in ${packages} do if [ "$(echo ffmpeg${i} ${ffmpeg_dependent_packages} | grep -ow ${package})" != "" ]; then @@ -69,6 +70,20 @@ for i in {5..6}; do done done +# for synocli-videodriver that ffmpeg v5-6 depends on +videodrv_dependent_packages=$(find spk/ -maxdepth 2 -mindepth 2 -name "Makefile" -exec grep -Ho "spksrc.videodriver.mk" {} \; | grep -Po ".*spk/\K[^/]*" | sort | tr '\n' ' ') + +# If packages contain a package that depends on spksrc.videodriver.mk, +# then ensure synocli-videodriver spk is first in list +for package in ${packages} +do + if [ "$(echo synocli-videodriver ${videodrv_dependent_packages} | grep -ow ${package})" != "" ]; then + packages_without_videodrv=$(echo "${packages}" | tr ' ' '\n' | grep -v "synocli-videodriver" | tr '\n' ' ') + packages="synocli-videodriver ${packages_without_videodrv}" + break + fi +done + # for python (310, 311) find all packages that depend on them for py in python310 python311; do python_dependent_packages=$(find spk/ -maxdepth 2 -mindepth 2 -name "Makefile" -exec grep -Ho "PYTHON_PACKAGE = ${py}" {} \; | grep -Po ".*spk/\K[^/]*" | sort | tr '\n' ' ') diff --git a/cross/Khronos-OpenCL-Headers/Makefile b/cross/Khronos-OpenCL-Headers/Makefile new file mode 100644 index 00000000000..f698fdf40e6 --- /dev/null +++ b/cross/Khronos-OpenCL-Headers/Makefile @@ -0,0 +1,19 @@ +PKG_NAME = OpenCL-Headers +PKG_VERS = 2024.05.08 +PKG_EXT = tar.gz +PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT) +PKG_DIST_FILE = khronos-opencl-headers-$(PKG_VERS).$(PKG_EXT) +PKG_DIST_SITE = https://github.com/KhronosGroup/OpenCL-Headers/archive/refs/tags +PKG_DIR = $(PKG_NAME)-$(PKG_VERS) + +HOMEPAGE = https://github.com/KhronosGroup/SPIRV-Headers +COMMENT = Machine-readable files for the SPIR-V Registry +LICENSE = Copyright (c) 2015-2024 The Khronos Group Inc. + +POST_EXTRACT_TARGET = SPIRV-Headers_post_extract_target + +include ../../mk/spksrc.cross-cmake.mk + +.PHONY: SPIRV-Headers_post_extract_target +SPIRV-Headers_post_extract_target: + @cd $(WORK_DIR) && ln -s $(PKG_DIR) $(PKG_NAME) diff --git a/cross/Khronos-OpenCL-Headers/digests b/cross/Khronos-OpenCL-Headers/digests new file mode 100644 index 00000000000..eea2899d8eb --- /dev/null +++ b/cross/Khronos-OpenCL-Headers/digests @@ -0,0 +1,3 @@ +khronos-opencl-headers-2024.05.08.tar.gz SHA1 188ef91da8210d120271a9b74b8b8858e897d9b8 +khronos-opencl-headers-2024.05.08.tar.gz SHA256 3c3dd236d35f4960028f4f58ce8d963fb63f3d50251d1e9854b76f1caab9a309 +khronos-opencl-headers-2024.05.08.tar.gz MD5 56d28bdc7957be155aa81114ce504794 diff --git a/cross/Khronos-SPIRV-Headers/Makefile b/cross/Khronos-SPIRV-Headers/Makefile new file mode 100644 index 00000000000..28002dd9288 --- /dev/null +++ b/cross/Khronos-SPIRV-Headers/Makefile @@ -0,0 +1,18 @@ +PKG_NAME = SPIRV-Headers +PKG_VERS = 1.3.283.0 +PKG_EXT = tar.gz +PKG_DIST_NAME = vulkan-sdk-$(PKG_VERS).$(PKG_EXT) +PKG_DIST_SITE = https://github.com/KhronosGroup/SPIRV-Headers/archive/refs/tags +PKG_DIR = $(PKG_NAME)-vulkan-sdk-$(PKG_VERS) + +HOMEPAGE = https://github.com/KhronosGroup/SPIRV-Headers +COMMENT = Machine-readable files for the SPIR-V Registry +LICENSE = Copyright (c) 2015-2024 The Khronos Group Inc. + +POST_EXTRACT_TARGET = SPIRV-Headers_post_extract_target + +include ../../mk/spksrc.cross-cmake.mk + +.PHONY: SPIRV-Headers_post_extract_target +SPIRV-Headers_post_extract_target: + @cd $(WORK_DIR) && ln -s $(PKG_DIR) $(PKG_NAME) diff --git a/cross/Khronos-SPIRV-Headers/digests b/cross/Khronos-SPIRV-Headers/digests new file mode 100644 index 00000000000..f1c4a632ab6 --- /dev/null +++ b/cross/Khronos-SPIRV-Headers/digests @@ -0,0 +1,3 @@ +vulkan-sdk-1.3.283.0.tar.gz SHA1 b532efb95ddbcb28128897992a390767c6a93772 +vulkan-sdk-1.3.283.0.tar.gz SHA256 a68a25996268841073c01514df7bab8f64e2db1945944b45087e5c40eed12cb9 +vulkan-sdk-1.3.283.0.tar.gz MD5 5f258f65b4526c053d9ca3cddc94e71b diff --git a/cross/Khronos-SPIRV-LLVM-Translator-140.src/Makefile b/cross/Khronos-SPIRV-LLVM-Translator-140.src/Makefile new file mode 100644 index 00000000000..a5b72b733c7 --- /dev/null +++ b/cross/Khronos-SPIRV-LLVM-Translator-140.src/Makefile @@ -0,0 +1,39 @@ +PKG_NAME = SPIRV-LLVM-Translator +PKG_LLVM_MAJ = 14 +PKG_LLVM_MIN = 0.3 +PKG_EXT = tar.gz +PKG_DIST_NAME = v$(PKG_LLVM_MAJ).$(PKG_LLVM_MIN).$(PKG_EXT) +PKG_DIST_FILE = $(PKG_NAME)-$(PKG_LLVM_MAJ).$(PKG_LLVM_MIN).$(PKG_EXT) +PKG_DIST_SITE = https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags +PKG_DIR = $(PKG_NAME)-$(PKG_LLVM_MAJ).$(PKG_LLVM_MIN) + +# llvm_release_140 branch is still receiving updates +# using latest gis hash to ensure replicable builds +#PKG_GIT_HASH = f23845001443049a9f1b0472b9a6f491aee46e3e +#PKG_DIST_NAME = $(PKG_GIT_HASH).$(PKG_EXT) +#PKG_DIST_FILE = $(PKG_NAME)-git$(PKG_GIT_HASH).$(PKG_EXT) +#PKG_DIST_SITE = https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive +#PKG_DIR = $(PKG_NAME)-$(PKG_GIT_HASH) + +# use below for direct llvm_release_140 branch +#PKG_VERS = $(PKG_LLVM_MAJ)0 +#PKG_GIT_BRANCH = llvm_release_$(PKG_VERS) +#PKG_DIST_NAME = $(PKG_GIT_BRANCH).$(PKG_EXT) +#PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) +#PKG_DIST_SITE = https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive +#PKG_DIR = $(PKG_NAME)-$(PKG_GIT_BRANCH) + +HOMEPAGE = https://github.com/KhronosGroup/SPIRV-LLVM-Translator +COMMENT = Library and tool for translation between LLVM IR and SPIR-V. +LICENSE = LLVM Release License + +POST_EXTRACT_TARGET = llvm_post_extract_target +CONFIGURE_TARGET = nop +COMPILE_TARGET = nop +INSTALL_TARGET = nop + +include ../../mk/spksrc.cross-cmake.mk + +.PHONY: llvm_post_extract_target +llvm_post_extract_target: + @cd $(WORK_DIR) && ln -s $(PKG_DIR) $(PKG_NAME) diff --git a/cross/Khronos-SPIRV-LLVM-Translator-140.src/digests b/cross/Khronos-SPIRV-LLVM-Translator-140.src/digests new file mode 100644 index 00000000000..55547b2b3cf --- /dev/null +++ b/cross/Khronos-SPIRV-LLVM-Translator-140.src/digests @@ -0,0 +1,3 @@ +SPIRV-LLVM-Translator-14.0.3.tar.gz SHA1 7fb0a38086390b130ff3981d54a1bc89d3e4393d +SPIRV-LLVM-Translator-14.0.3.tar.gz SHA256 c225f6929e5433c303c0f8f63a8e201322363c6817ebb1368ddb068279131ba7 +SPIRV-LLVM-Translator-14.0.3.tar.gz MD5 08f17fc6b891931d41049ad2bb2a7f51 diff --git a/cross/Khronos-SPIRV-Tools/Makefile b/cross/Khronos-SPIRV-Tools/Makefile new file mode 100644 index 00000000000..99e595ade1d --- /dev/null +++ b/cross/Khronos-SPIRV-Tools/Makefile @@ -0,0 +1,31 @@ +PKG_NAME = SPIRV-Tools +PKG_VERS = 2024.2 +PKG_EXT = tar.gz +PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT) +PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) +PKG_DIST_SITE = https://github.com/KhronosGroup/SPIRV-Tools/archive/refs/tags +PKG_DIR = $(PKG_NAME)-$(PKG_VERS) + +HOMEPAGE = https://github.com/KhronosGroup/SPIRV-Tools +COMMENT = The SPIR-V Tools project provides an API and commands for processing SPIR-V modules. +LICENSE = Apache-2.0 license + +BUILD_DEPENDS = cross/Khronos-SPIRV-Headers + +POST_EXTRACT_TARGET = SPIRV-Tools_post_extract_target + +CMAKE_ARGS += -DSPIRV_WERROR=OFF +CMAKE_ARGS += -DSPIRV_TOOLS_BUILD_STATIC=OFF +CMAKE_ARGS += -DSPIRV-Headers_SOURCE_DIR=$(WORK_DIR)/SPIRV-Headers + +include ../../mk/spksrc.cross-cmake.mk + +# Using gcc-8 we must use: make LDLIBS=-lstdc++fs +# or by adding the following +ifeq ($(call version_le, $(TC_GCC), 9),1) +CMAKE_ARGS += -DCMAKE_CXX_STANDARD_LIBRARIES=-lstdc++fs +endif + +.PHONY: SPIRV-Tools_post_extract_target +SPIRV-Tools_post_extract_target: + @cd $(WORK_DIR) && ln -s $(PKG_DIR) $(PKG_NAME) diff --git a/cross/Khronos-SPIRV-Tools/PLIST b/cross/Khronos-SPIRV-Tools/PLIST new file mode 100644 index 00000000000..69e98a18bdc --- /dev/null +++ b/cross/Khronos-SPIRV-Tools/PLIST @@ -0,0 +1,17 @@ +bin:bin/spirv-as +bin:bin/spirv-cfg +bin:bin/spirv-dis +rsc:bin/spirv-lesspipe.sh +bin:bin/spirv-link +bin:bin/spirv-lint +bin:bin/spirv-objdump +bin:bin/spirv-opt +bin:bin/spirv-reduce +bin:bin/spirv-val +lib:lib/libSPIRV-Tools-diff.so +lib:lib/libSPIRV-Tools-link.so +lib:lib/libSPIRV-Tools-lint.so +lib:lib/libSPIRV-Tools-opt.so +lib:lib/libSPIRV-Tools-reduce.so +lib:lib/libSPIRV-Tools-shared.so +lib:lib/libSPIRV-Tools.so diff --git a/cross/Khronos-SPIRV-Tools/digests b/cross/Khronos-SPIRV-Tools/digests new file mode 100644 index 00000000000..5c872535167 --- /dev/null +++ b/cross/Khronos-SPIRV-Tools/digests @@ -0,0 +1,3 @@ +SPIRV-Tools-2024.2.tar.gz SHA1 1e838970271113e0191a37e6d1ab929de61d605b +SPIRV-Tools-2024.2.tar.gz SHA256 58c5f4e6961c3d4936f7dbcd7f0b495c830b96972ee731452eaa9ade873f0095 +SPIRV-Tools-2024.2.tar.gz MD5 bde778ea43ee00f81ced9e441d69a0c9 diff --git a/cross/chromaprint/Makefile b/cross/chromaprint/Makefile index befa93e5588..8ea36bd6bf4 100644 --- a/cross/chromaprint/Makefile +++ b/cross/chromaprint/Makefile @@ -1,34 +1,53 @@ PKG_NAME = chromaprint -PKG_VERS = 1.5.2 +PKG_VERS = 1.5.1 PKG_EXT = tar.gz -PKG_GIT_HASH = aa67c95b9e486884a6d3ee8b0c91207d8c2b0551 -PKG_DIST_NAME = $(PKG_GIT_HASH).$(PKG_EXT) +PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/acoustid/chromaprint/archive -PKG_DIST_FILE = $(PKG_NAME)-git$(PKG_GIT_HASH).$(PKG_EXT) -PKG_DIR = $(PKG_NAME)-$(PKG_GIT_HASH) +PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) +PKG_DIR = $(PKG_NAME)-$(PKG_VERS) + +#PKG_GIT_HASH = aa67c95b9e486884a6d3ee8b0c91207d8c2b0551 +#PKG_DIST_NAME = $(PKG_GIT_HASH).$(PKG_EXT) +#PKG_DIST_FILE = $(PKG_NAME)-git$(PKG_GIT_HASH).$(PKG_EXT) +#PKG_DIR = $(PKG_NAME)-$(PKG_GIT_HASH) HOMEPAGE = https://acoustid.org/chromaprint COMMENT = Chromaprint is the core component of the AcoustID project. It\'s a client-side library that implements a custom algorithm for extracting fingerprints from any audio source. LICENSE = LGPL2.1+ -OPTIONAL_DEPENDS = cross/ffmpeg$(FFMPEG_VERSION) +OPTIONAL_DEPENDS = cross/ffmpeg6 # compiler too old UNSUPPORTED_ARCHS = $(ARMv5_ARCHS) $(OLD_PPC_ARCHS) -ifneq ($(wildcard $(FFMPEG_DIR)),) -CMAKE_RPATH = /var/packages/ffmpeg$(subst 4,,$(FFMPEG_VERSION))/target/lib +CMAKE_ARGS += -DBUILD_TOOLS=ON +CMAKE_ARGS += -DBUILD_TESTS=OFF +CMAKE_ARGS += -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" + +ifneq ($(wildcard $(FFMPEG_PACKAGE_ROOT)),) +CMAKE_ARGS += -DCMAKE_INSTALL_RPATH=$(FFMPEG_PREFIX)/lib + +# Location of FFMPEG Headers +CMAKE_ARGS += -DFFMPEG_LIBAVCODEC_FFT_INCLUDE_DIRS:PATH=$(FFMPEG_STAGING_PREFIX)/include +CMAKE_ARGS += -DFFMPEG_LIBAVCODEC_FFT_LIBRARIES:FILEPATH=$(FFMPEG_STAGING_PREFIX)/lib/libavcodec.so +CMAKE_ARGS += -DFFMPEG_LIBAVCODEC_INCLUDE_DIRS:PATH=$(FFMPEG_STAGING_PREFIX)/include +CMAKE_ARGS += -DFFMPEG_LIBAVCODEC_LIBRARIES:FILEPATH=$(FFMPEG_STAGING_PREFIX)/lib/libavcodec.so +CMAKE_ARGS += -DFFMPEG_LIBAVDEVICE_INCLUDE_DIRS:PATH=$(FFMPEG_STAGING_PREFIX)/include +CMAKE_ARGS += -DFFMPEG_LIBAVDEVICE_LIBRARIES:FILEPATH=$(FFMPEG_STAGING_PREFIX)/lib/libavdevice.so +CMAKE_ARGS += -DFFMPEG_LIBAVFORMAT_INCLUDE_DIRS:PATH=$(FFMPEG_STAGING_PREFIX)/include +CMAKE_ARGS += -DFFMPEG_LIBAVFORMAT_LIBRARIES:FILEPATH=$(FFMPEG_STAGING_PREFIX)/lib/libavformat.so +#CMAKE_ARGS += -DFFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS:PATH=$(FFMPEG_STAGING_PREFIX)/include +#CMAKE_ARGS += -DFFMPEG_LIBAVRESAMPLE_LIBRARIES:FILEPATH=$(FFMPEG_STAGING_PREFIX)/lib/libswresample.so +CMAKE_ARGS += -DFFMPEG_LIBAVUTIL_INCLUDE_DIRS:PATH=$(FFMPEG_STAGING_PREFIX)/include +CMAKE_ARGS += -DFFMPEG_LIBAVUTIL_LIBRARIES:FILEPATH=$(FFMPEG_STAGING_PREFIX)/lib/libavutil.so +CMAKE_ARGS += -DFFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS:PATH=$(FFMPEG_STAGING_PREFIX)/include +CMAKE_ARGS += -DFFMPEG_LIBSWRESAMPLE_LIBRARIES:FILEPATH=$(FFMPEG_STAGING_PREFIX)/lib/libswresample.so +CMAKE_ARGS += -DFFMPEG_LIBSWSCALE_INCLUDE_DIRS:PATH=$(FFMPEG_STAGING_PREFIX)/include +CMAKE_ARGS += -DFFMPEG_LIBSWSCALE_LIBRARIES:FILEPATH=$(FFMPEG_STAGING_PREFIX)/lib/libswscale.so + else -DEPENDS = cross/ffmpeg$(FFMPEG_VERSION) +DEPENDS = cross/ffmpeg6 CMAKE_RPATH = endif -CMAKE_BUILD_DIR = $(WORK_DIR)/$(PKG_DIR) -CMAKE_USE_TOOLCHAIN_FILE = OFF - include ../../mk/spksrc.cross-cmake.mk - -CMAKE_ARGS += -DBUILD_TOOLS=ON -CMAKE_ARGS += -DBUILD_TESTS=OFF -CMAKE_ARGS += -DCMAKE_INSTALL_RPATH=$(CMAKE_RPATH) -CMAKE_ARGS += -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" diff --git a/cross/chromaprint/digests b/cross/chromaprint/digests index af1964365f6..c3dbb009e49 100644 --- a/cross/chromaprint/digests +++ b/cross/chromaprint/digests @@ -1,3 +1,3 @@ -chromaprint-gitaa67c95b9e486884a6d3ee8b0c91207d8c2b0551.tar.gz SHA1 3e85f4bd134263b1699b7e7412b1e089865185d7 -chromaprint-gitaa67c95b9e486884a6d3ee8b0c91207d8c2b0551.tar.gz SHA256 88e13f065e31d59d102339d956d0e2f99b125386e4d58ae7de6f09b90104b90f -chromaprint-gitaa67c95b9e486884a6d3ee8b0c91207d8c2b0551.tar.gz MD5 80d7d474a585c186a6a3285465bfef1e +chromaprint-1.5.1.tar.gz SHA1 f54d8b58ff514ab65851d524237b38d8965cba57 +chromaprint-1.5.1.tar.gz SHA256 a1aad8fa3b8b18b78d3755b3767faff9abb67242e01b478ec9a64e190f335e1c +chromaprint-1.5.1.tar.gz MD5 54e71f86bcf1d34989db639044ba9628 diff --git a/cross/chromaprint/patches/001-arch-linux-8ccad693.patch b/cross/chromaprint/patches/001-arch-linux-8ccad693.patch new file mode 100644 index 00000000000..16b2f67f875 --- /dev/null +++ b/cross/chromaprint/patches/001-arch-linux-8ccad693.patch @@ -0,0 +1,777 @@ +From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= +Date: Fri, 4 Nov 2022 21:47:38 +0100 +Subject: [PATCH] Use FFmpeg 5.x (#120) + +* Use FFmpeg 5.1.2 for CI builds + +* Build on Ubuntu 20.04 + +* Upgrade code to FFmpeg 5.x APIs + +* Only set FFmpeg include dirs if building tools + +* No longer needed + +* Use ubuntu 20.04 +--- + .github/workflows/build.yml | 6 +- + CMakeLists.txt | 16 -- + package/build.sh | 4 +- + src/audio/ffmpeg_audio_processor.h | 2 - + src/audio/ffmpeg_audio_processor_avresample.h | 72 ------- + src/audio/ffmpeg_audio_processor_swresample.h | 18 +- + src/audio/ffmpeg_audio_reader.h | 197 +++++++++--------- + tests/CMakeLists.txt | 6 + + 8 files changed, 122 insertions(+), 199 deletions(-) + delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h + +diff -uprN ../chromaprint-1.5.1-orig/CMakeLists.txt ./CMakeLists.txt +--- ../chromaprint-1.5.1-orig/CMakeLists.txt 2021-12-23 05:57:54.000000000 +0000 ++++ ./CMakeLists.txt 2024-09-18 00:40:00.177326496 +0000 +@@ -82,9 +82,6 @@ find_package(FFmpeg) + if(FFMPEG_LIBRARIES) + cmake_push_check_state(RESET) + set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm) +- check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF) +- check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC) +- check_function_exists(av_frame_free HAVE_AV_FRAME_FREE) + cmake_pop_check_state() + endif() + +@@ -161,30 +158,17 @@ message(STATUS "Using ${FFT_LIB} for FFT + if(NOT AUDIO_PROCESSOR_LIB) + if(FFMPEG_LIBSWRESAMPLE_FOUND) + set(AUDIO_PROCESSOR_LIB "swresample") +- elseif(FFMPEG_LIBAVRESAMPLE_FOUND) +- set(AUDIO_PROCESSOR_LIB "avresample") + endif() + endif() + + if(AUDIO_PROCESSOR_LIB STREQUAL "swresample") + if(FFMPEG_LIBSWRESAMPLE_FOUND) +- set(USE_AVRESAMPLE OFF) + set(USE_SWRESAMPLE ON) + set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES}) + set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS}) + else() + message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found") + endif() +- message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion") +-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample") +- if(FFMPEG_LIBAVRESAMPLE_FOUND) +- set(USE_AVRESAMPLE ON) +- set(USE_SWRESAMPLE OFF) +- set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES}) +- set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS}) +- else() +- message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found") +- endif() + message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion") + else() + message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample") +diff -uprN ../chromaprint-1.5.1-orig/CMakeLists.txt.orig ./CMakeLists.txt.orig +--- ../chromaprint-1.5.1-orig/CMakeLists.txt.orig 1970-01-01 00:00:00.000000000 +0000 ++++ ./CMakeLists.txt.orig 2021-12-23 05:57:54.000000000 +0000 +@@ -0,0 +1,231 @@ ++cmake_minimum_required(VERSION 3.3) ++ ++set(chromaprint_VERSION_MAJOR 1) ++set(chromaprint_VERSION_MINOR 5) ++set(chromaprint_VERSION_PATCH 1) ++set(chromaprint_VERSION "${chromaprint_VERSION_MAJOR}.${chromaprint_VERSION_MINOR}.${chromaprint_VERSION_PATCH}") ++ ++project(chromaprint LANGUAGES C CXX VERSION "${chromaprint_VERSION}") ++ ++set(chromaprint_SOVERSION 1) ++ ++set(AUDIO_PROCESSOR_LIB CACHE STRING "Library to use for audio processing") ++set_property(CACHE AUDIO_PROCESSOR_LIB PROPERTY STRINGS avresample swresample) ++ ++set(FFT_LIB CACHE STRING "Library to use for FFT calculations") ++set_property(CACHE FFT_LIB PROPERTY STRINGS avfft fftw3 fftw3f kissfft vdsp) ++ ++include(CMakePushCheckState) ++include(CheckFunctionExists) ++include(CheckSymbolExists) ++include(CheckCXXCompilerFlag) ++ ++find_package(Threads) ++ ++option(BUILD_SHARED_LIBS "Build shared libraries" ON) ++ ++set(CMAKE_CXX_STANDARD 11) ++ ++if(BUILD_SHARED_LIBS) ++ set(CMAKE_C_VISIBILITY_PRESET hidden) ++ set(CMAKE_CXX_VISIBILITY_PRESET hidden) ++ set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) ++endif() ++ ++if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL "Debug") ++ add_definitions(-D_GLIBCXX_DEBUG) ++endif() ++ ++cmake_push_check_state(RESET) ++set(CMAKE_REQUIRED_LIBRARIES -lm) ++check_symbol_exists(lrintf math.h HAVE_LRINTF) ++check_symbol_exists(round math.h HAVE_ROUND) ++cmake_pop_check_state() ++ ++add_definitions( ++ -DHAVE_CONFIG_H ++ -D_SCL_SECURE_NO_WARNINGS ++ -D_USE_MATH_DEFINES ++ -D__STDC_LIMIT_MACROS ++ -D__STDC_CONSTANT_MACROS ++) ++ ++set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)") ++set(EXEC_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Installation prefix for executables and object code libraries" FORCE) ++set(BIN_INSTALL_DIR ${EXEC_INSTALL_PREFIX}/bin CACHE PATH "Installation prefix for user executables" FORCE) ++set(LIB_INSTALL_DIR ${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX} CACHE PATH "Installation prefix for object code libraries" FORCE) ++set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include CACHE PATH "Installation prefix for C header files" FORCE) ++ ++if(APPLE) ++ option(BUILD_FRAMEWORK "Build an OS X framework" OFF) ++ set(FRAMEWORK_INSTALL_DIR "/Library/Frameworks" CACHE STRING "Directory to install frameworks to") ++endif() ++ ++option(BUILD_TOOLS "Build command line tools" OFF) ++option(BUILD_TESTS "Build test suite" ON) ++ ++if(CMAKE_COMPILER_IS_GNUCXX) ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") ++endif() ++ ++if(NOT BUILD_SHARED_LIBS) ++ add_definitions(-DCHROMAPRINT_NODLL) ++endif() ++ ++set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/) ++ ++set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) ++ ++find_package(FFmpeg) ++ ++if(FFMPEG_LIBRARIES) ++ cmake_push_check_state(RESET) ++ set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm) ++ check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF) ++ check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC) ++ check_function_exists(av_frame_free HAVE_AV_FRAME_FREE) ++ cmake_pop_check_state() ++endif() ++ ++if(NOT FFT_LIB OR FFT_LIB STREQUAL "fftw3" OR FFT_LIB STREQUAL "fftw3f") ++ find_package(FFTW3) ++endif() ++ ++if(APPLE) ++ if(NOT FFT_LIB OR FFT_LIB STREQUAL "vdsp") ++ find_library(ACCELERATE_LIBRARIES Accelerate) ++ endif() ++endif() ++ ++if(NOT FFT_LIB OR FFT_LIB STREQUAL "kissfft") ++ find_package(KissFFT) ++endif() ++ ++set(USE_VDSP OFF) ++set(USE_AVFFT OFF) ++set(USE_FFTW3 OFF) ++set(USE_FFTW3F OFF) ++set(USE_KISSFFT OFF) ++ ++if(NOT FFT_LIB) ++ if(APPLE AND ACCELERATE_LIBRARIES) ++ set(FFT_LIB "vdsp") ++ elseif(FFMPEG_LIBAVCODEC_FFT_FOUND) ++ set(FFT_LIB "avfft") ++ elseif(FFTW3_LIBRARIES) ++ set(FFT_LIB "fftw3") ++ elseif(FFTW3_FFTWF_LIBRARY) ++ set(FFT_LIB "fftw3f") ++ elseif(KISSFFT_FOUND) ++ set(FFT_LIB "kissfft") ++ endif() ++endif() ++ ++if(FFT_LIB STREQUAL "vdsp") ++ if(ACCELERATE_LIBRARIES) ++ set(USE_VDSP ON) ++ else() ++ message(FATAL_ERROR "Selected ${FFT_LIB} for FFT calculations, but the library is not found") ++ endif() ++elseif(FFT_LIB STREQUAL "avfft") ++ if(FFMPEG_LIBAVCODEC_FFT_FOUND) ++ set(USE_AVFFT ON) ++ else() ++ message(FATAL_ERROR "Selected ${FFT_LIB} for FFT calculations, but the library is not found") ++ endif() ++elseif(FFT_LIB STREQUAL "fftw3") ++ if(FFTW3_LIBRARIES) ++ set(USE_FFTW3 ON) ++ else() ++ message(FATAL_ERROR "Selected ${FFT_LIB} for FFT calculations, but the library is not found") ++ endif() ++elseif(FFT_LIB STREQUAL "fftw3f") ++ if(FFTW3_FFTWF_LIBRARY) ++ set(USE_FFTW3F ON) ++ else() ++ message(FATAL_ERROR "Selected ${FFT_LIB} for FFT calculations, but the library is not found") ++ endif() ++elseif(FFT_LIB STREQUAL "kissfft") ++ if(KISSFFT_FOUND) ++ set(USE_KISSFFT ON) ++ else() ++ message(FATAL_ERROR "Selected ${FFT_LIB} for FFT calculations, but the library is not found") ++ endif() ++else() ++ message(FATAL_ERROR "No FFT library found") ++endif() ++ ++message(STATUS "Using ${FFT_LIB} for FFT calculations") ++ ++if(NOT AUDIO_PROCESSOR_LIB) ++ if(FFMPEG_LIBSWRESAMPLE_FOUND) ++ set(AUDIO_PROCESSOR_LIB "swresample") ++ elseif(FFMPEG_LIBAVRESAMPLE_FOUND) ++ set(AUDIO_PROCESSOR_LIB "avresample") ++ endif() ++endif() ++ ++if(AUDIO_PROCESSOR_LIB STREQUAL "swresample") ++ if(FFMPEG_LIBSWRESAMPLE_FOUND) ++ set(USE_AVRESAMPLE OFF) ++ set(USE_SWRESAMPLE ON) ++ set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES}) ++ set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS}) ++ else() ++ message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found") ++ endif() ++ message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion") ++elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample") ++ if(FFMPEG_LIBAVRESAMPLE_FOUND) ++ set(USE_AVRESAMPLE ON) ++ set(USE_SWRESAMPLE OFF) ++ set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES}) ++ set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS}) ++ else() ++ message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found") ++ endif() ++ message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion") ++else() ++ message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample") ++endif() ++ ++if(NOT BUILD_FRAMEWORK) ++ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libchromaprint.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libchromaprint.pc) ++ install( ++ FILES ${CMAKE_CURRENT_BINARY_DIR}/libchromaprint.pc ++ DESTINATION ${LIB_INSTALL_DIR}/pkgconfig ++ COMPONENT chromaprint) ++endif() ++ ++configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) ++ ++include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src) ++add_definitions( ++ -DHAVE_CONFIG_H ++ -D_SCL_SECURE_NO_WARNINGS ++ -D_USE_MATH_DEFINES ++ -D__STDC_LIMIT_MACROS ++ -D__STDC_CONSTANT_MACROS ++) ++ ++if(UNIX) ++ link_libraries(m) ++endif() ++ ++add_subdirectory(src) ++ ++if(BUILD_TESTS) ++ add_subdirectory(tests) ++endif(BUILD_TESTS) ++ ++configure_file( ++ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" ++ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" ++ IMMEDIATE @ONLY) ++ ++add_custom_target(uninstall ++ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) ++ ++configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.cmake" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile") ++add_custom_target(docs doxygen) +diff -uprN ../chromaprint-1.5.1-orig/src/audio/ffmpeg_audio_processor_avresample.h ./src/audio/ffmpeg_audio_processor_avresample.h +--- ../chromaprint-1.5.1-orig/src/audio/ffmpeg_audio_processor_avresample.h 2021-12-23 05:57:54.000000000 +0000 ++++ ./src/audio/ffmpeg_audio_processor_avresample.h 1970-01-01 00:00:00.000000000 +0000 +@@ -1,72 +0,0 @@ +-// Copyright (C) 2016 Lukas Lalinsky +-// Distributed under the MIT license, see the LICENSE file for details. +- +-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_ +-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_ +- +-extern "C" { +-#include +-} +- +-namespace chromaprint { +- +-class FFmpegAudioProcessor { +-public: +- FFmpegAudioProcessor() { +- m_resample_ctx = avresample_alloc_context(); +- } +- +- ~FFmpegAudioProcessor() { +- avresample_free(&m_resample_ctx); +- } +- +- void SetCompatibleMode() { +- av_opt_set_int(m_resample_ctx, "filter_size", 16, 0); +- av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0); +- av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0); +- av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0); +- } +- +- void SetInputChannelLayout(int64_t channel_layout) { +- av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0); +- } +- +- void SetInputSampleFormat(AVSampleFormat sample_format) { +- av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0); +- } +- +- void SetInputSampleRate(int sample_rate) { +- av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0); +- } +- +- void SetOutputChannelLayout(int64_t channel_layout) { +- av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0); +- } +- +- void SetOutputSampleFormat(AVSampleFormat sample_format) { +- av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0); +- } +- +- void SetOutputSampleRate(int sample_rate) { +- av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0); +- } +- +- int Init() { +- return avresample_open(m_resample_ctx); +- } +- +- int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) { +- return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count); +- } +- +- int Flush(uint8_t **out, int out_count) { +- return avresample_read(m_resample_ctx, out, out_count); +- } +- +-private: +- AVAudioResampleContext *m_resample_ctx = nullptr; +-}; +- +-}; // namespace chromaprint +- +-#endif +diff -uprN ../chromaprint-1.5.1-orig/src/audio/ffmpeg_audio_processor.h ./src/audio/ffmpeg_audio_processor.h +--- ../chromaprint-1.5.1-orig/src/audio/ffmpeg_audio_processor.h 2021-12-23 05:57:54.000000000 +0000 ++++ ./src/audio/ffmpeg_audio_processor.h 2024-09-18 00:40:00.178326509 +0000 +@@ -10,8 +10,6 @@ + + #if defined(USE_SWRESAMPLE) + #include "audio/ffmpeg_audio_processor_swresample.h" +-#elif defined(USE_AVRESAMPLE) +-#include "audio/ffmpeg_audio_processor_avresample.h" + #else + #error "no audio processing library" + #endif +diff -uprN ../chromaprint-1.5.1-orig/src/audio/ffmpeg_audio_processor_swresample.h ./src/audio/ffmpeg_audio_processor_swresample.h +--- ../chromaprint-1.5.1-orig/src/audio/ffmpeg_audio_processor_swresample.h 2021-12-23 05:57:54.000000000 +0000 ++++ ./src/audio/ffmpeg_audio_processor_swresample.h 2024-09-18 00:40:00.178326509 +0000 +@@ -28,30 +28,28 @@ public: + av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0); + } + +- void SetInputChannelLayout(int64_t channel_layout) { +- av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0); +- av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0); ++ void SetInputChannelLayout(AVChannelLayout *channel_layout) { ++ av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0); + } + + void SetInputSampleFormat(AVSampleFormat sample_format) { +- av_opt_set_int(m_swr_ctx, "isf", sample_format, 0); ++ av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0); + } + + void SetInputSampleRate(int sample_rate) { +- av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0); ++ av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0); + } + +- void SetOutputChannelLayout(int64_t channel_layout) { +- av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0); +- av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0); ++ void SetOutputChannelLayout(AVChannelLayout *channel_layout) { ++ av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0); + } + + void SetOutputSampleFormat(AVSampleFormat sample_format) { +- av_opt_set_int(m_swr_ctx, "osf", sample_format, 0); ++ av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0); + } + + void SetOutputSampleRate(int sample_rate) { +- av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0); ++ av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0); + } + + int Init() { +diff -uprN ../chromaprint-1.5.1-orig/src/audio/ffmpeg_audio_reader.h ./src/audio/ffmpeg_audio_reader.h +--- ../chromaprint-1.5.1-orig/src/audio/ffmpeg_audio_reader.h 2021-12-23 05:57:54.000000000 +0000 ++++ ./src/audio/ffmpeg_audio_reader.h 2024-09-18 00:40:00.178326509 +0000 +@@ -62,7 +62,7 @@ public: + bool Read(const int16_t **data, size_t *size); + + bool IsOpen() const { return m_opened; } +- bool IsFinished() const { return m_finished && !m_got_frame; } ++ bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; } + + std::string GetError() const { return m_error; } + int GetErrorCode() const { return m_error_code; } +@@ -74,20 +74,19 @@ private: + uint8_t *m_convert_buffer[1] = { nullptr }; + int m_convert_buffer_nb_samples = 0; + +- AVInputFormat *m_input_fmt = nullptr; ++ const AVInputFormat *m_input_fmt = nullptr; + AVDictionary *m_input_opts = nullptr; + + AVFormatContext *m_format_ctx = nullptr; + AVCodecContext *m_codec_ctx = nullptr; +- AVFrame *m_frame = nullptr; + int m_stream_index = -1; + std::string m_error; + int m_error_code = 0; +- bool m_finished = false; + bool m_opened = false; +- int m_got_frame = 0; +- AVPacket m_packet; +- AVPacket m_packet0; ++ bool m_has_more_packets = true; ++ bool m_has_more_frames = true; ++ AVPacket *m_packet = nullptr; ++ AVFrame *m_frame = nullptr; + + int m_output_sample_rate = 0; + int m_output_channels = 0; +@@ -98,19 +97,12 @@ private: + + inline FFmpegAudioReader::FFmpegAudioReader() { + av_log_set_level(AV_LOG_QUIET); +- +- av_init_packet(&m_packet); +- m_packet.data = nullptr; +- m_packet.size = 0; +- +- m_packet0 = m_packet; + } + + inline FFmpegAudioReader::~FFmpegAudioReader() { + Close(); + av_dict_free(&m_input_opts); + av_freep(&m_convert_buffer[0]); +- av_packet_unref(&m_packet0); + } + + inline bool FFmpegAudioReader::SetInputFormat(const char *name) { +@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(cons + + Close(); + +- av_init_packet(&m_packet); +- m_packet.data = nullptr; +- m_packet.size = 0; +- +- m_packet0 = m_packet; ++ m_packet = av_packet_alloc(); ++ if (!m_packet) { ++ return false; ++ } + + ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts); + if (ret < 0) { +@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(cons + return false; + } + +- AVCodec *codec; ++ const AVCodec *codec; + ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0); + if (ret < 0) { + SetError("Could not find any audio stream in the file", ret); + return false; + } + m_stream_index = ret; ++ auto stream = m_format_ctx->streams[m_stream_index]; + +- m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec; ++ m_codec_ctx = avcodec_alloc_context3(codec); + m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16; + ++ ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar); ++ if (ret < 0) { ++ SetError("Could not copy the stream parameters", ret); ++ return false; ++ } ++ + ret = avcodec_open2(m_codec_ctx, codec, nullptr); + if (ret < 0) { + SetError("Could not open the codec", ret); + return false; + } + +- if (!m_codec_ctx->channel_layout) { +- m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels); +- } ++ av_dump_format(m_format_ctx, 0, "foo", 0); + + m_frame = av_frame_alloc(); + if (!m_frame) { +@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(cons + m_output_sample_rate = m_codec_ctx->sample_rate; + } + +- if (!m_output_channels) { +- m_output_channels = m_codec_ctx->channels; ++ AVChannelLayout output_channel_layout; ++ if (m_output_channels) { ++ av_channel_layout_default(&output_channel_layout, m_output_channels); ++ } else { ++ m_output_channels = m_codec_ctx->ch_layout.nb_channels; ++ av_channel_layout_default(&output_channel_layout, m_output_channels); + } + +- if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) { ++ if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) { + m_converter.reset(new FFmpegAudioProcessor()); + m_converter->SetCompatibleMode(); + m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt); + m_converter->SetInputSampleRate(m_codec_ctx->sample_rate); +- m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout); ++ m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout)); + m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16); + m_converter->SetOutputSampleRate(m_output_sample_rate); +- m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels)); ++ m_converter->SetOutputChannelLayout(&output_channel_layout); + auto ret = m_converter->Init(); + if (ret != 0) { + SetError("Could not create an audio converter instance", ret); +@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(cons + } + } + ++ av_channel_layout_uninit(&output_channel_layout); ++ + m_opened = true; +- m_finished = false; +- m_got_frame = 0; +- m_nb_packets = 0; ++ m_has_more_packets = true; ++ m_has_more_frames = true; + m_decode_error = 0; + + return true; +@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(cons + + inline void FFmpegAudioReader::Close() { + av_frame_free(&m_frame); ++ av_packet_free(&m_packet); + + m_stream_index = -1; + +@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(cons + return false; + } + ++ *data = nullptr; ++ *size = 0; ++ + int ret; ++ bool needs_packet = false; + while (true) { +- while (m_packet.size <= 0) { +- av_packet_unref(&m_packet0); +- av_init_packet(&m_packet); +- m_packet.data = nullptr; +- m_packet.size = 0; +- ret = av_read_frame(m_format_ctx, &m_packet); ++ while (needs_packet && m_packet->size == 0) { ++ ret = av_read_frame(m_format_ctx, m_packet); + if (ret < 0) { + if (ret == AVERROR_EOF) { +- m_finished = true; ++ needs_packet = false; ++ m_has_more_packets = false; + break; +- } else { ++ } ++ SetError("Error reading from the audio source", ret); ++ return false; ++ } ++ if (m_packet->stream_index == m_stream_index) { ++ needs_packet = false; ++ } else { ++ av_packet_unref(m_packet); ++ } ++ } ++ ++ if (m_packet->size != 0) { ++ ret = avcodec_send_packet(m_codec_ctx, m_packet); ++ if (ret < 0) { ++ if (ret != AVERROR(EAGAIN)) { + SetError("Error reading from the audio source", ret); + return false; + } +- } +- m_packet0 = m_packet; +- if (m_packet.stream_index != m_stream_index) { +- m_packet.data = nullptr; +- m_packet.size = 0; + } else { +- m_nb_packets++; ++ av_packet_unref(m_packet); + } + } + +- ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet); ++ ret = avcodec_receive_frame(m_codec_ctx, m_frame); + if (ret < 0) { +- if (m_decode_error) { +- SetError("Error decoding audio frame", m_decode_error); +- return false; ++ if (ret == AVERROR_EOF) { ++ m_has_more_frames = false; ++ } else if (ret == AVERROR(EAGAIN)) { ++ if (m_has_more_packets) { ++ needs_packet = true; ++ continue; ++ } else { ++ m_has_more_frames = false; ++ } + } +- m_decode_error = ret; +- m_packet.data = nullptr; +- m_packet.size = 0; +- continue; ++ SetError("Error decoding the audio source", ret); ++ return false; + } + +- break; +- } +- +- m_decode_error = 0; +- +- const int decoded = std::min(ret, m_packet.size); +- m_packet.data += decoded; +- m_packet.size -= decoded; +- +- if (m_got_frame) { +- if (m_converter) { +- if (m_frame->nb_samples > m_convert_buffer_nb_samples) { +- int linsize; +- av_freep(&m_convert_buffer[0]); +- m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples); +- ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1); +- if (ret < 0) { +- SetError("Couldn't allocate audio converter buffer", ret); ++ if (m_frame->nb_samples > 0) { ++ if (m_converter) { ++ if (m_frame->nb_samples > m_convert_buffer_nb_samples) { ++ int linsize; ++ av_freep(&m_convert_buffer[0]); ++ m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples); ++ ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1); ++ if (ret < 0) { ++ SetError("Couldn't allocate audio converter buffer", ret); ++ return false; ++ } ++ } ++ auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples); ++ if (nb_samples < 0) { ++ SetError("Couldn't convert audio", ret); + return false; + } +- } +- auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples); +- if (nb_samples < 0) { +- SetError("Couldn't convert audio", ret); +- return false; +- } +- *data = (const int16_t *) m_convert_buffer[0]; +- *size = nb_samples; +- } else { +- *data = (const int16_t *) m_frame->data[0]; +- *size = m_frame->nb_samples; +- } +- } else { +- if (m_finished && m_converter) { +- auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples); +- if (nb_samples < 0) { +- SetError("Couldn't convert audio", ret); +- return false; +- } else if (nb_samples > 0) { +- m_got_frame = 1; + *data = (const int16_t *) m_convert_buffer[0]; + *size = nb_samples; ++ } else { ++ *data = (const int16_t *) m_frame->data[0]; ++ *size = m_frame->nb_samples; ++ } ++ } else { ++ if (m_converter) { ++ if (IsFinished()) { ++ auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples); ++ if (nb_samples < 0) { ++ SetError("Couldn't convert audio", ret); ++ return false; ++ } else if (nb_samples > 0) { ++ *data = (const int16_t *) m_convert_buffer[0]; ++ *size = nb_samples; ++ } ++ } + } + } +- } + +- return true; ++ return true; ++ } + } + + inline void FFmpegAudioReader::SetError(const char *message, int errnum) { +diff -uprN ../chromaprint-1.5.1-orig/tests/CMakeLists.txt ./tests/CMakeLists.txt +--- ../chromaprint-1.5.1-orig/tests/CMakeLists.txt 2021-12-23 05:57:54.000000000 +0000 ++++ ./tests/CMakeLists.txt 2024-09-18 00:40:00.179326521 +0000 +@@ -38,6 +38,12 @@ set(SRCS + + if(BUILD_TOOLS) + set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp) ++ include_directories( ++ ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS} ++ ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS} ++ ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS} ++ ${AUDIO_PROCESSOR_INCLUDE_DIRS} ++ ) + link_libraries(fpcalc_libs) + endif() + diff --git a/cross/chromaprint/patches/002-arch-linux-ffmpeg7.patch b/cross/chromaprint/patches/002-arch-linux-ffmpeg7.patch new file mode 100644 index 00000000000..62ee938b357 --- /dev/null +++ b/cross/chromaprint/patches/002-arch-linux-ffmpeg7.patch @@ -0,0 +1,19 @@ +diff -uprN ../chromaprint-1.5.1-8ccad693/src/audio/ffmpeg_audio_reader.h ./src/audio/ffmpeg_audio_reader.h +--- ../chromaprint-1.5.1-8ccad693/src/audio/ffmpeg_audio_reader.h 2024-09-18 00:40:00.178326509 +0000 ++++ ./src/audio/ffmpeg_audio_reader.h 2024-09-18 00:41:08.043183176 +0000 +@@ -118,8 +118,13 @@ inline bool FFmpegAudioReader::SetInputS + + inline bool FFmpegAudioReader::SetInputChannels(int channels) { + char buf[64]; +- sprintf(buf, "%d", channels); +- return av_dict_set(&m_input_opts, "channels", buf, 0) >= 0; ++ if (channels == 1) ++ sprintf(buf, "%s", "mono"); ++ else if (channels == 2) ++ sprintf(buf, "%s", "stereo"); ++ else ++ return false; ++ return av_dict_set(&m_input_opts, "ch_layout", buf, 0) >= 0; + } + + inline bool FFmpegAudioReader::Open(const std::string &file_name) { diff --git a/cross/clinfo/Makefile b/cross/clinfo/Makefile new file mode 100644 index 00000000000..a56e6a8d06d --- /dev/null +++ b/cross/clinfo/Makefile @@ -0,0 +1,28 @@ +PKG_NAME = clinfo +PKG_VERS = 3.0.23.01.25 +PKG_EXT = tar.gz +PKG_DIST_NAME = $(PKG_VERS).$(PKG_EXT) +PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) +PKG_DIST_SITE = https://github.com/Oblomov/clinfo/archive/refs/tags +PKG_DIR = $(PKG_NAME)-$(PKG_VERS) + +HOMEPAGE = https://github.com/Oblomov/clinfo +COMMENT = clinfo is a simple command-line application that enumerates all possible (known) properties of the OpenCL platform and devices available on the system. +LICENSE = clinfo by Giuseppe Bilotta + +DEPENDS = cross/ocl-icd + +CONFIGURE_TARGET = nop +COMPILE_TARGET = clinfo_compile_target +INSTALL_TARGET = clinfo_install_target + +include ../../mk/spksrc.cross-cc.mk + +.PHONY: clinfo_compile_target +clinfo_compile_target: + $(RUN) $(MAKE) + +.PHONY: clinfo_install_target +clinfo_install_target: + $(RUN) install -Dm755 clinfo -t $(STAGING_INSTALL_PREFIX)/bin + $(RUN) install -Dm644 LICENSE -t $(STAGING_INSTALL_PREFIX)/share/licenses/$(PKG_NAME) diff --git a/cross/clinfo/PLIST b/cross/clinfo/PLIST new file mode 100644 index 00000000000..91825fe0017 --- /dev/null +++ b/cross/clinfo/PLIST @@ -0,0 +1 @@ +bin:bin/clinfo diff --git a/cross/clinfo/digests b/cross/clinfo/digests new file mode 100644 index 00000000000..186a67875f5 --- /dev/null +++ b/cross/clinfo/digests @@ -0,0 +1,3 @@ +clinfo-3.0.23.01.25.tar.gz SHA1 f97df7b3fe1fd2ab33ad72dd36624547017647e7 +clinfo-3.0.23.01.25.tar.gz SHA256 6dcdada6c115873db78c7ffc62b9fc1ee7a2d08854a3bccea396df312e7331e3 +clinfo-3.0.23.01.25.tar.gz MD5 52548a9bb96f22f47818d085e3a0aaa9 diff --git a/cross/comskip/Makefile b/cross/comskip/Makefile index 7caadd8c91f..2f00a437aac 100644 --- a/cross/comskip/Makefile +++ b/cross/comskip/Makefile @@ -8,19 +8,19 @@ PKG_DIST_FILE = $(PKG_NAME)-git$(PKG_GIT_HASH).$(PKG_EXT) PKG_DIR = $(PKG_NAME)-$(PKG_GIT_HASH) DEPENDS = cross/argtable -OPTIONAL_DEPENDS = cross/ffmpeg$(FFMPEG_VERSION) +OPTIONAL_DEPENDS = cross/ffmpeg5 HOMEPAGE = https://www.kaashoek.com/comskip COMMENT = Commercial detector LICENSE = GNU/LGPL -ifeq ($(wildcard $(FFMPEG_DIR)),) -DEPENDS += cross/ffmpeg$(FFMPEG_VERSION) -endif - PRE_CONFIGURE_TARGET = comskip_pre_configure GNU_CONFIGURE = 1 +ifeq ($(wildcard $(FFMPEG_PACKAGE_ROOT)),) +DEPENDS = cross/ffmpeg5 +endif + include ../../mk/spksrc.cross-cc.mk .PHONY: comskip_pre_configure diff --git a/cross/ffmpeg5/Makefile b/cross/ffmpeg5/Makefile index f05b5a48ead..746feff6d1e 100644 --- a/cross/ffmpeg5/Makefile +++ b/cross/ffmpeg5/Makefile @@ -35,8 +35,7 @@ CONFIGURE_ARGS += --extra-cflags=-Wno-deprecated-declarations include ../../mk/spksrc.common.mk -OPTIONAL_DEPENDS = native/nasm -OPTIONAL_DEPENDS += cross/chromaprint-fftw +OPTIONAL_DEPENDS = cross/chromaprint-fftw OPTIONAL_DEPENDS += cross/dav1d OPTIONAL_DEPENDS += cross/frei0r OPTIONAL_DEPENDS += cross/libass @@ -51,6 +50,11 @@ OPTIONAL_DEPENDS += cross/libva-utils OPTIONAL_DEPENDS += cross/intel-vaapi-driver OPTIONAL_DEPENDS += cross/intel-media-driver OPTIONAL_DEPENDS += cross/intel-mediasdk +OPTIONAL_DEPENDS += cross/intel-level-zero +OPTIONAL_DEPENDS += cross/intel-graphics-compiler +OPTIONAL_DEPENDS += cross/intel-compute-runtime +OPTIONAL_DEPENDS += cross/ocl-icd +OPTIONAL_DEPENDS += cross/clinfo OPTIONAL_DEPENDS += cross/twolame OPTIONAL_DEPENDS += cross/x264 OPTIONAL_DEPENDS += cross/x265 @@ -58,10 +62,6 @@ OPTIONAL_DEPENDS += cross/shine # Define x86asm ifeq ($(findstring $(ARCH),$(i686_ARCHS) $(x64_ARCHS)),$(ARCH)) -BUILD_DEPENDS = native/nasm -NASM_PATH = $(abspath $(PWD)/../../native/nasm/work-native/install/usr/local/bin) -ENV += AS=$(NASM_PATH)/nasm -ENV += PATH=$(NASM_PATH):$$PATH CONFIGURE_ARGS += --x86asmexe=nasm # Allow ASM on aarch64, disable on all others @@ -233,14 +233,20 @@ CONFIGURE_ARGS += --cpu=e500 --disable-altivec endif endif +ifeq ($(findstring $(ARCH),evansport),$(ARCH)) +CONFIGURE_ARGS += --arch=x86 --cpu=atom +endif + ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH)) +# Dependencies provided by synocli-videodriver +# If built outside spksrc.videodriver.mk +ifeq ($(strip $(VIDEODRV_PACKAGE)),) DEPENDS += cross/libva cross/libva-utils cross/intel-vaapi-driver cross/intel-media-driver cross/intel-mediasdk -CONFIGURE_ARGS += --arch=x86_64 -CONFIGURE_ARGS += --enable-vaapi --enable-libmfx --enable-libdrm endif - -ifeq ($(findstring $(ARCH),evansport),$(ARCH)) -CONFIGURE_ARGS += --arch=x86 --cpu=atom +CONFIGURE_ARGS += --arch=x86_64 +CONFIGURE_ARGS += --enable-libdrm +CONFIGURE_ARGS += --enable-libmfx +CONFIGURE_ARGS += --enable-vaapi endif include ../../mk/spksrc.cross-cc.mk @@ -249,6 +255,23 @@ include ../../mk/spksrc.cross-cc.mk ## GCC SPECIFIC ## +# OpenCL acceleration +ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH)) +# Newer Intel implementations (oneAPI, level-zero) requires gcc >= 5 +ifeq ($(call version_gt, $(TC_GCC), 5),1) +# Dependencies provided by synocli-videodriver +# If built outside spksrc.videodriver.mk +ifeq ($(strip $(VIDEODRV_PACKAGE)),) +DEPENDS += cross/intel-level-zero +DEPENDS += cross/intel-graphics-compiler +DEPENDS += cross/intel-compute-runtime +DEPENDS += cross/ocl-icd +DEPENDS += cross/clinfo +endif +CONFIGURE_ARGS += --enable-opencl +endif +endif + # libass requires harfbuzz which in turns requires c++ from gcc >= 4.8 (88f6281-6.1 = gcc-4.6.4) ifeq ($(call version_ge, $(TC_GCC), 4.8),1) DEPENDS += cross/libass diff --git a/cross/ffmpeg6/Makefile b/cross/ffmpeg6/Makefile index 99818edf098..719e65cc3e8 100644 --- a/cross/ffmpeg6/Makefile +++ b/cross/ffmpeg6/Makefile @@ -35,8 +35,7 @@ CONFIGURE_ARGS += --extra-cflags=-Wno-deprecated-declarations include ../../mk/spksrc.common.mk -OPTIONAL_DEPENDS = native/nasm -OPTIONAL_DEPENDS += cross/chromaprint-fftw +OPTIONAL_DEPENDS = cross/chromaprint-fftw OPTIONAL_DEPENDS += cross/dav1d OPTIONAL_DEPENDS += cross/frei0r OPTIONAL_DEPENDS += cross/libass @@ -51,6 +50,11 @@ OPTIONAL_DEPENDS += cross/libva-utils OPTIONAL_DEPENDS += cross/intel-vaapi-driver OPTIONAL_DEPENDS += cross/intel-media-driver OPTIONAL_DEPENDS += cross/intel-mediasdk +OPTIONAL_DEPENDS += cross/intel-level-zero +OPTIONAL_DEPENDS += cross/intel-graphics-compiler +OPTIONAL_DEPENDS += cross/intel-compute-runtime +OPTIONAL_DEPENDS += cross/ocl-icd +OPTIONAL_DEPENDS += cross/clinfo OPTIONAL_DEPENDS += cross/twolame OPTIONAL_DEPENDS += cross/x264 OPTIONAL_DEPENDS += cross/x265 @@ -58,10 +62,6 @@ OPTIONAL_DEPENDS += cross/shine # Define x86asm ifeq ($(findstring $(ARCH),$(i686_ARCHS) $(x64_ARCHS)),$(ARCH)) -BUILD_DEPENDS = native/nasm -NASM_PATH = $(abspath $(PWD)/../../native/nasm/work-native/install/usr/local/bin) -ENV += AS=$(NASM_PATH)/nasm -ENV += PATH=$(NASM_PATH):$$PATH CONFIGURE_ARGS += --x86asmexe=nasm # Allow ASM on aarch64, disable on all others @@ -233,23 +233,45 @@ CONFIGURE_ARGS += --cpu=e500 --disable-altivec endif endif +ifeq ($(findstring $(ARCH),evansport),$(ARCH)) +CONFIGURE_ARGS += --arch=x86 --cpu=atom +endif + ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH)) -DEPENDS += cross/libva cross/libva-utils cross/intel-vaapi-driver +# Dependencies provided by synocli-videodriver +# If built outside spksrc.videodriver.mk +ifeq ($(strip $(VIDEODRV_PACKAGE)),) +DEPENDS += cross/libva cross/libva-utils cross/intel-vaapi-driver cross/intel-media-driver cross/intel-mediasdk +endif CONFIGURE_ARGS += --arch=x86_64 CONFIGURE_ARGS += --enable-libdrm +CONFIGURE_ARGS += --enable-libmfx CONFIGURE_ARGS += --enable-vaapi endif -ifeq ($(findstring $(ARCH),evansport),$(ARCH)) -CONFIGURE_ARGS += --arch=x86 --cpu=atom -endif - include ../../mk/spksrc.cross-cc.mk ## ## GCC SPECIFIC ## +# OpenCL acceleration +ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH)) +# Newer Intel implementations (oneAPI, level-zero) requires gcc >= 5 +ifeq ($(call version_gt, $(TC_GCC), 5),1) +# Dependencies provided by synocli-videodriver +# If built outside spksrc.videodriver.mk +ifeq ($(strip $(VIDEODRV_PACKAGE)),) +DEPENDS += cross/intel-level-zero +DEPENDS += cross/intel-graphics-compiler +DEPENDS += cross/intel-compute-runtime +DEPENDS += cross/ocl-icd +DEPENDS += cross/clinfo +endif +CONFIGURE_ARGS += --enable-opencl +endif +endif + # libass requires harfbuzz which in turns requires c++ from gcc >= 4.8 (88f6281-6.1 = gcc-4.6.4) ifeq ($(call version_ge, $(TC_GCC), 4.8),1) DEPENDS += cross/libass @@ -261,19 +283,3 @@ ifeq ($(call version_ge, $(TC_GCC), 7.5),1) DEPENDS += cross/frei0r CONFIGURE_ARGS += --enable-frei0r endif - -# Newer Intel implementations (oneAPI, level-zero) requires gcc >= 5 -# -->> can not use libmfx and libvpl together -ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH)) -DEPENDS += cross/intel-media-driver cross/intel-mediasdk - -ifeq ($(call version_lt, ${TC_GCC}, 5),1) -CONFIGURE_ARGS += --enable-libmfx -else -DEPENDS += cross/intel-level-zero -# Missing intel-graphics-compiler (IGC) -#CONFIGURE_ARGS += --enable-opencl -DEPENDS += cross/intel-libvpl cross/intel-libvpl-tools -CONFIGURE_ARGS += --enable-libvpl -endif -endif diff --git a/cross/intel-compute-runtime/Makefile b/cross/intel-compute-runtime/Makefile new file mode 100644 index 00000000000..20c727a869d --- /dev/null +++ b/cross/intel-compute-runtime/Makefile @@ -0,0 +1,46 @@ +PKG_NAME = compute-runtime +PKG_VERS = 24.31.30508.7 +PKG_EXT = tar.gz +PKG_DIST_NAME = $(PKG_VERS).$(PKG_EXT) +PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) +PKG_DIST_SITE = https://github.com/intel/compute-runtime/archive/refs/tags +PKG_DIR = $(PKG_NAME)-$(PKG_VERS) + +REQUIRED_MIN_DSM = 7.1 +UNSUPPORTED_ARCHS = $(ARM_ARCHS) $(PPC_ARCHS) $(i686_ARCHS) + +HOMEPAGE = https://github.com/intel/compute-runtime +COMMENT = The Intel(R) Graphics Compute Runtime for oneAPI Level Zero and OpenCL(TM) Driver is an open source project providing compute API support (Level Zero, OpenCL) for Intel graphics hardware architectures (HD Graphics, Xe). +LICENSE = MIT license + +POST_EXTRACT_TARGET = intel-compute-runtime_post_extract_target +POST_INSTALL_TARGET = intel-compute-runtime_post_install_target +CMAKE_USE_NINJA = 0 +CMAKE_USE_DESTDIR = 1 + +DEPENDS = cross/intel-gmmlib +DEPENDS += cross/intel-graphics-compiler + +# [Khronos-OpenCL-Headers] +BUILD_DEPENDS += cross/Khronos-OpenCL-Headers +CMAKE_ARGS += -DKHRONOS_HEADERS_DIR=$(STAGING_INSTALL_PREFIX)/include + +# [Khronos-SPIRV-Headers] +BUILD_DEPENDS += cross/Khronos-SPIRV-Headers + +CMAKE_ARGS += -DIGC_DIR=$(STAGING_INSTALL_PREFIX) +CMAKE_ARGS += -DNEO_DISABLE_LD_GOLD:BOOL='ON' +CMAKE_ARGS += -DSKIP_UNIT_TESTS=1 + +include ../../mk/spksrc.cross-cmake.mk + +ENV += LD_LIBRARY_PATH=$(STAGING_INSTALL_PREFIX)/lib + +.PHONY: intel-compute-runtime_post_extract_target +intel-compute-runtime_post_extract_target: + @cd $(WORK_DIR) && ln -s $(PKG_DIR) $(PKG_NAME) + +.PHONY: intel-compute-runtime_post_install_target +intel-compute-runtime_post_install_target: + @install -m 755 -d $(STAGING_INSTALL_PREFIX)/etc/OpenCL/vendors/ + @install -m 644 $(INSTALL_DIR)/etc/OpenCL/vendors/intel.icd $(STAGING_INSTALL_PREFIX)/etc/OpenCL/vendors/ diff --git a/cross/intel-compute-runtime/PLIST b/cross/intel-compute-runtime/PLIST new file mode 100644 index 00000000000..a3260ee225a --- /dev/null +++ b/cross/intel-compute-runtime/PLIST @@ -0,0 +1,6 @@ +bin:bin/ocloc-24.31 +lib:lib/libocloc.so +lnk:lib/libze_intel_gpu.so.1 +lnk:lib/libze_intel_gpu.so.1.3.30508 +lib:lib/intel-opencl/libigdrcl.so +rsc:etc/OpenCL/vendors/intel.icd diff --git a/cross/intel-compute-runtime/digests b/cross/intel-compute-runtime/digests new file mode 100644 index 00000000000..3ad9ab58dd1 --- /dev/null +++ b/cross/intel-compute-runtime/digests @@ -0,0 +1,3 @@ +compute-runtime-24.31.30508.7.tar.gz SHA1 67eb25c48b0d61f7449d41ec684d3f9bc1c4d7b6 +compute-runtime-24.31.30508.7.tar.gz SHA256 8dd27632119c70914e17971694cfd78b616c14d9115bfaadb0ba1451c4282f8f +compute-runtime-24.31.30508.7.tar.gz MD5 af1548896a4a4204d1be9837caa09fec diff --git a/cross/intel-gmmlib-latest/Makefile b/cross/intel-gmmlib-latest/Makefile index 018202eb12a..5cc29274c80 100644 --- a/cross/intel-gmmlib-latest/Makefile +++ b/cross/intel-gmmlib-latest/Makefile @@ -1,5 +1,5 @@ PKG_NAME = intel-gmmlib -PKG_VERS = 22.3.20 +PKG_VERS = 22.5.2 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/intel/gmmlib/archive @@ -12,6 +12,9 @@ HOMEPAGE = https://github.com/intel/gmmlib COMMENT = Intel Graphics Memory Management Library provides device specific and buffer management for the Intel Graphics Compute Runtime for OpenCL and the Intel Media Driver for VAAPI. LICENSE = MIT +# Limit compile/link-time storage space (and faster build-time) +GCC_NO_DEBUG_INFO = 1 + CMAKE_ARGS += -DRUN_TEST_SUITE=OFF include ../../mk/spksrc.cross-cmake.mk diff --git a/cross/intel-gmmlib-latest/PLIST b/cross/intel-gmmlib-latest/PLIST index ee88ccb94a2..701de4a4ae5 100644 --- a/cross/intel-gmmlib-latest/PLIST +++ b/cross/intel-gmmlib-latest/PLIST @@ -1,3 +1,3 @@ lnk:lib/libigdgmm.so lnk:lib/libigdgmm.so.12 -lib:lib/libigdgmm.so.12.3.0 +lib:lib/libigdgmm.so.12.5.0 diff --git a/cross/intel-gmmlib-latest/digests b/cross/intel-gmmlib-latest/digests index a552c5ee082..84b05cd6454 100644 --- a/cross/intel-gmmlib-latest/digests +++ b/cross/intel-gmmlib-latest/digests @@ -1,3 +1,3 @@ -intel-gmmlib-22.3.20.tar.gz SHA1 d639292bdff2d03b1136d45ac400a214feaf4b53 -intel-gmmlib-22.3.20.tar.gz SHA256 227c1614d4817154b4e6fbfb667ba2b231ea7aa53796d91f1800af9aeb703f59 -intel-gmmlib-22.3.20.tar.gz MD5 4e8f3cc09a549fcdb408b884b926fba3 +intel-gmmlib-22.5.2.tar.gz SHA1 d40803c18975b353c01fda54a7ca48db4f07355d +intel-gmmlib-22.5.2.tar.gz SHA256 dbf7cc401de7ff386306a23c1c61b3cf7bd86a4d9001b3a1d16a81e6b0e3ab2b +intel-gmmlib-22.5.2.tar.gz MD5 31179b308b376890af64b684ba8ca65d diff --git a/cross/intel-graphics-compiler/Makefile b/cross/intel-graphics-compiler/Makefile new file mode 100644 index 00000000000..0072e323292 --- /dev/null +++ b/cross/intel-graphics-compiler/Makefile @@ -0,0 +1,146 @@ +PKG_NAME = intel-graphics-compiler +PKG_VERS = 1.0.17537.20 +PKG_EXT = tar.gz +PKG_DIST_NAME = igc-$(PKG_VERS).$(PKG_EXT) +PKG_DIST_SITE = https://github.com/intel/intel-graphics-compiler/archive +PKG_DIR = $(PKG_NAME)-igc-$(PKG_VERS) + +REQUIRED_MIN_DSM = 7.1 +UNSUPPORTED_ARCHS = $(ARM_ARCHS) $(PPC_ARCHS) $(i686_ARCHS) + +DEPENDS += cross/intel-level-zero + +HOMEPAGE = https://github.com/oneapi-src/level-zero +COMMENT = This project is part of the larger oneAPI project and contains copies of the Level Zero Specification API C/C++ header files, Level Zero Loader, Level Zero Validation Layer and Level Zero Tracing Layer +LICENSE = MIT + +# Default version of LLVM used by IGC +IGC_LLVM_MAJ = 14 +IGC_LLVM_VER = $(IGC_LLVM_MAJ).0.5 + +POST_EXTRACT_TARGET = igc_post_extract_target + +# Fails when built using Ninja and/or requires various CMP0??? such as: +# CMAKE_ARGS += -DCMAKE_POLICY_DEFAULT_CMP0116='OLD|NEW' +CMAKE_USE_NINJA = 0 + +# Limit compile/link-time storage space (and faster build-time) +GCC_NO_DEBUG_INFO = 1 + +# Using various LLVM project sources needs a top-level master directory +CMAKE_BUILD_DIR = $(WORK_DIR)/igc.build +CMAKE_SOURCE_DIR = $(WORK_DIR)/igc +CMAKE_DIR = $(WORK_DIR)/igc + +# Assertions are internal checks to help find bugs. +# They typically slow down LLVM and Clang when enabled +CMAKE_ARGS += -DLLVM_ENABLE_ASSERTIONS=OFF + +# BUILD_SHARED_LIBS is only recommended for use +# by LLVM developers. If you want to build LLVM +# as a shared library, you should use the +# LLVM_BUILD_LLVM_DYLIB option +CMAKE_ARGS += -DBUILD_SHARED_LIBS=OFF + +# Disable third-party benchmarks and unittest +# as not-included in build and fails +CMAKE_ARGS += -DLLVM_INCLUDE_BENCHMARKS=OFF +CMAKE_ARGS += -DLLVM_INCLUDE_TESTS=OFF + +# [intel-opencl-clang-140] +BUILD_DEPENDS += cross/intel-opencl-clang-140.src +CMAKE_ARGS += -DAPPLY_PATCHES='OFF' + +# IGC specific +CMAKE_ARGS += -DIGC_OPTION__ARCHITECTURE_TARGET='Linux64' +CMAKE_ARGS += -DIGC_OPTION__ARCHITECTURE_HOST='Linux64' +CMAKE_ARGS += -DINSTALL_GENX_IR='ON' + +# [intel-vc-intrinsics] +BUILD_DEPENDS += cross/intel-vc-intrinsics.src +# Leaving source directory in auto-configure mode du to CMake Warning: +# Manually-specified variables were not used by the project: IGC_OPTION__VC_INTRINSICS_SOURCES_DIR +CMAKE_ARGS += -DIGC_OPTION__VC_INTRINSICS_MODE='Source' +#CMAKE_ARGS += -DIGC_OPTION__VC_INTRINSICS_SOURCES_DIR=$(WORK_DIR)/vc-intrinsics + +# [Khronos-SPIRV-Headers] +BUILD_DEPENDS += cross/Khronos-SPIRV-Headers +CMAKE_ARGS += -DIGC_OPTION__USE_PREINSTALLED_SPIRV_HEADERS='ON' +CMAKE_ARGS += -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR:PATH=$(WORK_DIR)/SPIRV-Headers + +# [Khronos-SPIRV-LLVM-Translator -> llvm-spirv] +BUILD_DEPENDS += cross/Khronos-SPIRV-LLVM-Translator-140.src +CMAKE_ARGS += -DIGC_OPTION__LINK_KHRONOS_SPIRV_TRANSLATOR='ON' +# Leave in auto-configure as otherwise fails +#CMAKE_ARGS += -DIGC_OPTION__SPIRV_TRANSLATOR_MODE='Source' +#CMAKE_ARGS += -DIGC_OPTION__SPIRV_TRANSLATOR_SOURCE_DIR=$(WORK_DIR)/SPIRV-LLVM-Translator +# Fixes IGC/VectorCompiler/lib/Driver/SPIRVWrapper.cpp +# fatal error: LLVMSPIRVLib.h: No such file or directory +# Further, have a look below at 'igc_intree_copy_llvm-spirv_include' +# for both opencl-clang and llvm-spirv (SPIRV-LLVM-Translator) +ADDITIONAL_CXXFLAGS += -I$(WORK_DIR)/SPIRV-LLVM-Translator/include + +# [Khronos-SPIRV-Tools] +# Cannot be built in-tree: +# SPIRV-Tools requires C++17 or later, but is configured for C++14 +DEPENDS += cross/Khronos-SPIRV-Tools +CMAKE_ARGS += -DIGC_OPTION__SPIRV_TOOLS_MODE='Prebuilds' +#CMAKE_ARGS += -DIGC_OPTION__SPIRV_TOOLS_MODE='Source' +#CMAKE_ARGS += -DIGC_OPTION__SPIRV_TOOLS_SOURCE_DIR=$(WORK_DIR)/SPIRV-Tools + +# [llvm] +BUILD_DEPENDS += cross/llvm-project-140.src +CMAKE_ARGS += -DIGC_OPTION__LLVM_MODE='Source' +CMAKE_ARGS += -DIGC_OPTION__LLVM_STOCK_SOURCES=ON +CMAKE_ARGS += -DIGC_OPTION__LLVM_SOURCES_DIR=$(WORK_DIR)/llvm-project +CMAKE_ARGS += -DIGC_OPTION__LLVM_PREFERRED_VERSION='$(IGC_LLVM_VER)' + +# [llvm-clang] +CMAKE_ARGS += -DIGC_OPTION__CLANG_MODE='Source' +# Has no effect when using llvm-project sources +#CMAKE_ARGS += -DIGC_OPTION__CLANG_SOURCES_DIR:PATH=$(WORK_DIR)/llvm-project/clang +CMAKE_ARGS += -DCCLANG_FROM_SYSTEM='OFF' + +# [llvm-lld] +CMAKE_ARGS += -DIGC_OPTION__LLD_MODE='Source' +# Has no effect when using llvm-project sources +#CMAKE_ARGS += -DIGC_OPTION__lld_SOURCES_DIR:PATH=$(WORK_DIR)/llvm-project/lld + +# [llvm-libunwind] +# Required to copy libunwind/include/mach-o/compact_unwind_encoding.h +CMAKE_ARGS += -DDEFAULT_IGC_LLVM_SOURCES_DIR=$(WORK_DIR)/llvm-project + +# Fails to access in NATIVE/bin/llvm-tblgen possibly due to parallel compiling +BUILD_DEPENDS += native/llvm-14.0 +CMAKE_ARGS += -DLLVM_TABLEGEN=$(abspath $(PWD)/../../native/llvm-14.0/work-native/install/usr/local/bin/llvm-tblgen) +CMAKE_ARGS += -DCLANG_TABLEGEN=$(abspath $(PWD)/../../native/llvm-14.0/work-native/install/usr/local/bin/clang-tblgen) + +include ../../mk/spksrc.cross-cmake.mk + +# Requires access to: +# CMCLTranslatorTool (during build time): IGC/Release/CMCLTranslatorTool +# llvm-tblgen, clang-tool (symlink -> clang-14), llvm-link, opt: native/llvm-14.0 +ENV += PATH=$(CMAKE_BUILD_DIR)/IGC/Release:$(abspath $(PWD)/../../native/llvm-14.0/work-native/install/usr/local/bin):$$PATH + +# Associate external projects to LLVM build, this replaces (and cannot be combined): +# -DLLVM_EXTERNAL_PROJECTS='llvm-spirv;opencl-clang' +# -DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=$(WORK_DIR)/SPIRV-LLVM-Translator +# -DLLVM_EXTERNAL_OPENCL_CLANG_SOURCE_DIR=$(WORK_DIR)/opencl-clang +# Note that vc-intrinsics is handled thru IGC, and not LLVM such as: +# -DLLVM_EXTERNAL_PROJECTS='llvm-spirv;opencl-clang;vc-intrinsics' +# -DLLVM_EXTERNAL_VC_INTRINSICS_SOURCE_DIR=$(WORK_DIR)/vc-intrinsics +igc_link_external_project: + @cd $(WORK_DIR)/llvm-project/llvm/projects && ln -sf ../../../opencl-clang opencl-clang + @cd $(WORK_DIR)/llvm-project/llvm/projects && ln -sf ../../../SPIRV-LLVM-Translator llvm-spirv + +# When built in-tree intel-opencl-clang thru IGC it can't find llvm-spirv headers +# Similarly for itself which can find the actual include directory +# Further, using the following doesn't work for these two in particular: +# ADDITIONAL_CXXFLAGS += -I$(WORK_DIR)/SPIRV-LLVM-Translator/include +igc_intree_copy_llvm-spirv_include: igc_link_external_project + @cp $(WORK_DIR)/SPIRV-LLVM-Translator/include/* $(WORK_DIR)/opencl-clang/. + @cp $(WORK_DIR)/SPIRV-LLVM-Translator/include/* $(WORK_DIR)/SPIRV-LLVM-Translator/lib/SPIRV/. + +igc_post_extract_target: igc_intree_copy_llvm-spirv_include + @cd $(WORK_DIR) && ln -sf $(PKG_DIR) $(PKG_NAME) + @cd $(WORK_DIR) && ln -sf $(PKG_NAME) igc diff --git a/cross/intel-graphics-compiler/PLIST b/cross/intel-graphics-compiler/PLIST new file mode 100644 index 00000000000..0029cadfdf1 --- /dev/null +++ b/cross/intel-graphics-compiler/PLIST @@ -0,0 +1,30 @@ +bin:bin/clinfo +bin:bin/cllayerinfo +bin:bin/GenX_IR +bin:bin/iga64 +bin:bin/lld +bin:bin/metrics_monitor +bin:bin/ocloc-24.31 +bin:bin/sample_decode +bin:bin/sample_encode +bin:bin/sample_multi_transcode +bin:bin/sample_vpp +bin:bin/system_analyzer +bin:bin/val-surface-sharing +bin:bin/vpl-inspect +bin:bin/vpl-import-export +lnk:lib/libiga64.so +lnk:lib/libiga64.so.1 +lib:lib/libiga64.so.1.0.1 +lnk:lib/libigc.so +lnk:lib/libigc.so.1 +lib:lib/libigc.so.1.0.1 +lnk:lib/libigdfcl.so +lnk:lib/libigdfcl.so.1 +lib:lib/libigdfcl.so.1.0.1 +lib:lib/libocloc.so +lib:lib/libopencl-clang.so.14 +lnk:lib/libze_intel_gpu.so.1 +lib:lib/libze_intel_gpu.so.1.3.30508 +rsc:lib/igc/NOTICES.txt +lib:lib/intel-opencl/libigdrcl.so diff --git a/cross/intel-graphics-compiler/digests b/cross/intel-graphics-compiler/digests new file mode 100644 index 00000000000..b517892d117 --- /dev/null +++ b/cross/intel-graphics-compiler/digests @@ -0,0 +1,3 @@ +igc-1.0.17537.20.tar.gz SHA1 a2a82e725a182db1ced073d67216cb0a9fa1d87c +igc-1.0.17537.20.tar.gz SHA256 44e77384ea69215d0311a08393019323f1c30217c05c972be945f2aed7fbde53 +igc-1.0.17537.20.tar.gz MD5 e9b208f22b51a5b3aa616e4dfd4668f2 diff --git a/cross/intel-level-zero/Makefile b/cross/intel-level-zero/Makefile index cbbb1adb944..5ee1e917217 100644 --- a/cross/intel-level-zero/Makefile +++ b/cross/intel-level-zero/Makefile @@ -1,5 +1,5 @@ PKG_NAME = level-zero -PKG_VERS = 1.17.6 +PKG_VERS = 1.17.42 PKG_EXT = tar.gz PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT) PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) diff --git a/cross/intel-level-zero/digests b/cross/intel-level-zero/digests index 8d62ff44c25..ccb47ee831d 100644 --- a/cross/intel-level-zero/digests +++ b/cross/intel-level-zero/digests @@ -1,3 +1,3 @@ -level-zero-1.17.6.tar.gz SHA1 c5aa89a50445682862bd24c2af9c464e9818001e -level-zero-1.17.6.tar.gz SHA256 a018923fa0732c4fb9228ff668124363de18f376a314113aa6aaf0a6b5d1ab3b -level-zero-1.17.6.tar.gz MD5 365bf6adb214d94a2b8850df46f1d017 +level-zero-1.17.42.tar.gz SHA1 417b8898993ad4f377af51a1291aa345a46f39ad +level-zero-1.17.42.tar.gz SHA256 16ba86e9fee6699c5300bb0ef09cb0852cd261e2ddd9960f88df93d4d04a4829 +level-zero-1.17.42.tar.gz MD5 f3bcc75d39006f02cf764876cc8a58cf diff --git a/cross/intel-libvpl-tools/Makefile b/cross/intel-libvpl-tools/Makefile index e752aa7f43d..13fc3a06eb8 100644 --- a/cross/intel-libvpl-tools/Makefile +++ b/cross/intel-libvpl-tools/Makefile @@ -1,5 +1,5 @@ PKG_NAME = libvpl-tools -PKG_VERS = 1.0.0 +PKG_VERS = 1.2.0 PKG_EXT = tar.gz PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT) PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) diff --git a/cross/intel-libvpl-tools/PLIST b/cross/intel-libvpl-tools/PLIST index 34e0ceee106..7a67492c24d 100644 --- a/cross/intel-libvpl-tools/PLIST +++ b/cross/intel-libvpl-tools/PLIST @@ -7,6 +7,7 @@ bin:bin/system_analyzer bin:bin/val-surface-sharing bin:bin/vpl-import-export bin:bin/vpl-inspect -lib:lib/libcttmetrics.so +lnk:lib/libcttmetrics.so +lib:lib/libcttmetrics.so.1.0.0 rsc:share/vpl-tools/licensing/third-party-programs.txt rsc:share/vpl-tools/licensing/license.txt diff --git a/cross/intel-libvpl-tools/digests b/cross/intel-libvpl-tools/digests index c653c526ece..a3850ca9ef8 100644 --- a/cross/intel-libvpl-tools/digests +++ b/cross/intel-libvpl-tools/digests @@ -1,3 +1,3 @@ -libvpl-tools-1.0.0.tar.gz SHA1 0eecfd1327cbd7126ee775457cb0bea60add8d18 -libvpl-tools-1.0.0.tar.gz SHA256 2a74f089e4e711a3ab61240ae500e54ea5e0f392c03e419d2f3e0e2c035fdf5c -libvpl-tools-1.0.0.tar.gz MD5 e83ecee5f45d83b450597d4f7b982e9a +libvpl-tools-1.2.0.tar.gz SHA1 7f6e408bf694b760e74109d41f5895003758c55c +libvpl-tools-1.2.0.tar.gz SHA256 b6768982abdef340eb14764499d9cb7201b1c74d319f93f3ffb07c980e04f7fa +libvpl-tools-1.2.0.tar.gz MD5 23c7bf86fdf16fab3f4a993d58329071 diff --git a/cross/intel-libvpl/Makefile b/cross/intel-libvpl/Makefile index 17c0f30a2a9..e55dc8cd91a 100644 --- a/cross/intel-libvpl/Makefile +++ b/cross/intel-libvpl/Makefile @@ -1,5 +1,5 @@ PKG_NAME = libvpl -PKG_VERS = 2.11.0 +PKG_VERS = 2.13.0 PKG_EXT = tar.gz PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT) PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) diff --git a/cross/intel-libvpl/PLIST b/cross/intel-libvpl/PLIST index 1f157c643b6..819f34fbe16 100644 --- a/cross/intel-libvpl/PLIST +++ b/cross/intel-libvpl/PLIST @@ -1,4 +1,4 @@ lnk:lib/libvpl.so lnk:lib/libvpl.so.2 -lib:lib/libvpl.so.2.11 +lib:lib/libvpl.so.2.13 rsc:etc/vpl/vars.sh diff --git a/cross/intel-libvpl/digests b/cross/intel-libvpl/digests index b3bea820b8e..2ae9763ef33 100644 --- a/cross/intel-libvpl/digests +++ b/cross/intel-libvpl/digests @@ -1,3 +1,3 @@ -libvpl-2.11.0.tar.gz SHA1 7b8a1758b17c1b6c2029b805e4210ea182bc4abe -libvpl-2.11.0.tar.gz SHA256 3e322ba6b3593da03e1cfdb8062f9f1545f6d9b1de39e36876de5934b26737d2 -libvpl-2.11.0.tar.gz MD5 a9984f61d0e0c3e282e56d63aaade862 +libvpl-2.13.0.tar.gz SHA1 ddd2d81851356354add31c98afe0738aadc7e9a3 +libvpl-2.13.0.tar.gz SHA256 1c740e2b58f7853f56b618bdb7d4a7e5d37f8c1a9b30105a0b79ba80873e1cbd +libvpl-2.13.0.tar.gz MD5 c423c877260dba129772d4e2059386e4 diff --git a/cross/intel-media-driver-latest/Makefile b/cross/intel-media-driver-latest/Makefile index d051ec83ab2..18823adfc94 100644 --- a/cross/intel-media-driver-latest/Makefile +++ b/cross/intel-media-driver-latest/Makefile @@ -1,5 +1,5 @@ PKG_NAME = intel-media -PKG_VERS = 24.1.5 +PKG_VERS = 24.2.5 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/intel/media-driver/archive @@ -22,6 +22,9 @@ LICENSE = MIT CMAKE_USE_DESTDIR = 0 +# Limit compile/link-time storage space (and faster build-time) +GCC_NO_DEBUG_INFO = 1 + include ../../mk/spksrc.cross-cmake.mk # intel-media-driver specific args diff --git a/cross/intel-media-driver-latest/digests b/cross/intel-media-driver-latest/digests index f9ded6b5f26..5a4fa0e5cf4 100644 --- a/cross/intel-media-driver-latest/digests +++ b/cross/intel-media-driver-latest/digests @@ -1,3 +1,3 @@ -intel-media-24.1.5.tar.gz SHA1 d6a351b9d53713942ff6dc24d6d0d1a4dc3c38d8 -intel-media-24.1.5.tar.gz SHA256 e23ea37c98d8d4b9d1a3a134b6489256d8f5a7a4ee71967b1db8ade70052654f -intel-media-24.1.5.tar.gz MD5 2b9607518f01f55e277fdf92ec1ef100 +intel-media-24.2.5.tar.gz SHA1 ba3e00e9a6a7692cef7bb2a94e5857c682d57a9c +intel-media-24.2.5.tar.gz SHA256 dec2210c1f824a721e4ea6f66f5899e300801b3e7fae232d3f8a94db38c2edd1 +intel-media-24.2.5.tar.gz MD5 c602d9a3ebebb2ad8a5239dc5951c65b diff --git a/cross/intel-mediasdk-latest/Makefile b/cross/intel-mediasdk-latest/Makefile index f8cb65635f0..9f8c46243e5 100644 --- a/cross/intel-mediasdk-latest/Makefile +++ b/cross/intel-mediasdk-latest/Makefile @@ -19,4 +19,3 @@ include ../../mk/spksrc.cross-cmake.mk CMAKE_ARGS += -DMFX_PLUGINS_DIR=$(INSTALL_PREFIX)/lib CMAKE_ARGS += -DBUILD_SAMPLES=OFF CMAKE_ARGS += -DBUILD_TUTORIALS=OFF -CMAKE_ARGS += -Wno-dev diff --git a/cross/intel-opencl-clang-140.src/Makefile b/cross/intel-opencl-clang-140.src/Makefile new file mode 100644 index 00000000000..4c4c5239fd3 --- /dev/null +++ b/cross/intel-opencl-clang-140.src/Makefile @@ -0,0 +1,32 @@ +PKG_NAME = opencl-clang +PKG_LLVM_MAJ = 14 +PKG_VERS = $(PKG_LLVM_MAJ)0 +PKG_GIT_BRANCH = ocl-open-$(PKG_VERS) +PKG_EXT = tar.gz +PKG_DIST_SITE = https://github.com/intel/opencl-clang/archive + +# ocl-open-140 branch is still receiving updates +# using latest git hash to ensure replicable builds +PKG_GIT_HASH = 470cf0018e1ef6fc92eda1356f5f31f7da452abc +PKG_DIST_NAME = $(PKG_GIT_HASH).$(PKG_EXT) +PKG_DIST_FILE = $(PKG_NAME)-git$(PKG_GIT_HASH).$(PKG_EXT) +PKG_DIR = $(PKG_NAME)-$(PKG_GIT_HASH) + +# use below for direct ocl-open-140 branch +#PKG_DIST_NAME = $(PKG_GIT_BRANCH).$(PKG_EXT) +#PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) +#PKG_DIR = $(PKG_NAME)-$(PKG_GIT_BRANCH) + +HOMEPAGE = https://github.com/intel/opencl-clang +COMMENT = opencl-clang is a thin wrapper library around clang. The library has OpenCL-oriented API and is capable to compile OpenCL C kernels to SPIR-V modules. +LICENSE = Apache License v2.0 with LLVM Exceptions + +POST_EXTRACT_TARGET = opencl-clang_post_extract_target +CONFIGURE_TARGET = nop +COMPILE_TARGET = nop +INSTALL_TARGET = nop + +include ../../mk/spksrc.cross-cmake.mk + +opencl-clang_post_extract_target: + @cd $(WORK_DIR) && ln -s $(PKG_DIR) $(PKG_NAME) diff --git a/cross/intel-opencl-clang-140.src/digests b/cross/intel-opencl-clang-140.src/digests new file mode 100644 index 00000000000..3abf556d384 --- /dev/null +++ b/cross/intel-opencl-clang-140.src/digests @@ -0,0 +1,3 @@ +opencl-clang-git470cf0018e1ef6fc92eda1356f5f31f7da452abc.tar.gz SHA1 bae7111a25145f7df3305634ccaf1e1839540d25 +opencl-clang-git470cf0018e1ef6fc92eda1356f5f31f7da452abc.tar.gz SHA256 fa410e0b4cc5b3fc3262e3b6aaace3543207a20ecd004f48dfec9a970f1fe4e2 +opencl-clang-git470cf0018e1ef6fc92eda1356f5f31f7da452abc.tar.gz MD5 eb4d8486ff13b082859ad0edec592267 diff --git a/cross/intel-opencl-clang-140/Makefile b/cross/intel-opencl-clang-140/Makefile new file mode 100644 index 00000000000..fcd0a60fd93 --- /dev/null +++ b/cross/intel-opencl-clang-140/Makefile @@ -0,0 +1,94 @@ +PKG_NAME = opencl-clang +PKG_LLVM_MAJ = 14 +PKG_VERS = $(PKG_LLVM_MAJ)0 +PKG_GIT_BRANCH = ocl-open-$(PKG_VERS) +PKG_EXT = tar.gz +PKG_DIST_SITE = https://github.com/intel/opencl-clang/archive + +# ocl-open-140 branch is still receiving updates +# using latest git hash to ensure replicable builds +PKG_GIT_HASH = 470cf0018e1ef6fc92eda1356f5f31f7da452abc +PKG_DIST_NAME = $(PKG_GIT_HASH).$(PKG_EXT) +PKG_DIST_FILE = $(PKG_NAME)-git$(PKG_GIT_HASH).$(PKG_EXT) +PKG_DIR = $(PKG_NAME)-$(PKG_GIT_HASH) + +# use below for direct ocl-open-140 branch +#PKG_DIST_NAME = $(PKG_GIT_BRANCH).$(PKG_EXT) +#PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) +#PKG_DIR = $(PKG_NAME)-$(PKG_GIT_BRANCH) + +REQUIRED_MIN_DSM = 7 +UNSUPPORTED_ARCHS = $(ARM_ARCHS) $(PPC_ARCHS) $(i686_ARCHS) + +BUILD_DEPENDS = cross/llvm-project-140.src +BUILD_DEPENDS += cross/Khronos-SPIRV-LLVM-Translator-140.src +BUILD_DEPENDS += cross/Khronos-SPIRV-Headers +BUILD_DEPENDS += cross/Khronos-OpenCL-Headers +BUILD_DEPENDS += cross/intel-vc-intrinsics.src +# Cannot be built in-tree: +# SPIRV-Tools requires C++17 or later, but is configured for C++14 +DEPENDS += cross/Khronos-SPIRV-Tools + +HOMEPAGE = https://github.com/intel/opencl-clang +COMMENT = opencl-clang is a thin wrapper library around clang. The library has OpenCL-oriented API and is capable to compile OpenCL C kernels to SPIR-V modules. +LICENSE = Apache License v2.0 with LLVM Exceptions + +POST_EXTRACT_TARGET = opencl-clang_post_extract_target + +# Does not fails but when built using Ninja and/or requires various CMP0??? such as: +# CMAKE_ARGS += -DCMAKE_POLICY_DEFAULT_CMP0116='OLD|NEW' +CMAKE_USE_NINJA = 0 + +# Suppress developer warnings +CMAKE_ARGS += -Wno-dev + +# Using various LLVM project sources needs a top-level master directory +CMAKE_BUILD_DIR = $(WORK_DIR)/opencl-clang.build +CMAKE_SOURCE_DIR = $(WORK_DIR)/llvm-project/llvm + +# Assertions are internal checks to help find bugs. +# They typically slow down LLVM and Clang when enabled +CMAKE_ARGS += -DLLVM_ENABLE_ASSERTIONS=OFF + +# BUILD_SHARED_LIBS is only recommended for use +# by LLVM developers. If you want to build LLVM +# as a shared library, you should use the +# LLVM_BUILD_LLVM_DYLIB option +CMAKE_ARGS += -DBUILD_SHARED_LIBS=OFF + +# Disable third-party benchmarks and unittest +# as not-included in build and fails +# -- +# patch needed for LLVM 14.x +# https://github.com/llvm/llvm-project/issues/54941 +CMAKE_ARGS += -DLLVM_INCLUDE_BENCHMARKS=OFF +CMAKE_ARGS += -DLLVM_INCLUDE_TESTS=OFF + +# [intel-opencl-clang-140] +CMAKE_ARGS += -DAPPLY_PATCHES='OFF' + +include ../../mk/spksrc.common.mk + +# +# https://github.com/intel/opencl-clang +# +CMAKE_ARGS += -DLLVM_TARGETS_TO_BUILD=X86 +CMAKE_ARGS += -DLLVM_ENABLE_PROJECTS='clang;lld' +CMAKE_ARGS += -DLLVM_EXTERNAL_PROJECTS='llvm-spirv;opencl-clang;vc-intrinsics' +CMAKE_ARGS += -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=$(STAGING_INSTALL_PREFIX)/include +CMAKE_ARGS += -DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=$(WORK_DIR)/SPIRV-LLVM-Translator +CMAKE_ARGS += -DLLVM_EXTERNAL_VC_INTRINSICS_SOURCE_DIR=$(WORK_DIR)/vc-intrinsics +CMAKE_ARGS += -DLLVM_EXTERNAL_OPENCL_CLANG_SOURCE_DIR=$(WORK_DIR)/$(PKG_NAME) + +# Contrary to IGC does not fail to access in NATIVE/bin/llvm-tblgen but reduces built time and size +BUILD_DEPENDS += native/llvm-14.0 +CMAKE_ARGS += -DLLVM_TABLEGEN=$(abspath $(PWD)/../../native/llvm-14.0/work-native/install/usr/local/bin/llvm-tblgen) +CMAKE_ARGS += -DCLANG_TABLEGEN=$(abspath $(PWD)/../../native/llvm-14.0/work-native/install/usr/local/bin/clang-tblgen) + +include ../../mk/spksrc.cross-cmake.mk + +# Requires access to build-time NATIVE and native/llvm-14.0 tools +ENV += PATH=$(CMAKE_BUILD_DIR)/NATIVE/bin:$(abspath $(PWD)/../../native/llvm-14.0/work-native/install/usr/local/bin):$$PATH + +opencl-clang_post_extract_target: + @cd $(WORK_DIR) && ln -s $(PKG_DIR) $(PKG_NAME) diff --git a/cross/intel-opencl-clang-140/PLIST b/cross/intel-opencl-clang-140/PLIST new file mode 100644 index 00000000000..ef1bdd2c483 --- /dev/null +++ b/cross/intel-opencl-clang-140/PLIST @@ -0,0 +1,11 @@ +lnk:lib/libclang.so +lnk:lib/libclang.so.13 +lib:lib/libclang.so.14.0.5 +lnk:lib/libclang-cpp.so +lib:lib/libclang-cpp.so.14 +lnk:lib/libLTO.so +lib:lib/libLTO.so.14 +lnk:lib/libopencl-clang.so +lib:lib/libopencl-clang.so.14 +lnk:lib/libRemarks.so +lib:lib/libRemarks.so.14 diff --git a/cross/intel-opencl-clang-140/digests b/cross/intel-opencl-clang-140/digests new file mode 100644 index 00000000000..3abf556d384 --- /dev/null +++ b/cross/intel-opencl-clang-140/digests @@ -0,0 +1,3 @@ +opencl-clang-git470cf0018e1ef6fc92eda1356f5f31f7da452abc.tar.gz SHA1 bae7111a25145f7df3305634ccaf1e1839540d25 +opencl-clang-git470cf0018e1ef6fc92eda1356f5f31f7da452abc.tar.gz SHA256 fa410e0b4cc5b3fc3262e3b6aaace3543207a20ecd004f48dfec9a970f1fe4e2 +opencl-clang-git470cf0018e1ef6fc92eda1356f5f31f7da452abc.tar.gz MD5 eb4d8486ff13b082859ad0edec592267 diff --git a/cross/intel-vaapi-driver/Makefile b/cross/intel-vaapi-driver/Makefile index 43f10fb0519..1bd01bf90c7 100644 --- a/cross/intel-vaapi-driver/Makefile +++ b/cross/intel-vaapi-driver/Makefile @@ -16,6 +16,9 @@ PRE_CONFIGURE_TARGET = intel_vaapi_driver_configure GNU_CONFIGURE = 1 +# Limit compile/link-time storage space (and faster build-time) +GCC_NO_DEBUG_INFO = 1 + include ../../mk/spksrc.cross-cc.mk # Enforce install prefix because of make install DESTDIR diff --git a/cross/intel-vc-intrinsics.src/Makefile b/cross/intel-vc-intrinsics.src/Makefile new file mode 100644 index 00000000000..b6a7bfb2cf7 --- /dev/null +++ b/cross/intel-vc-intrinsics.src/Makefile @@ -0,0 +1,23 @@ +PKG_NAME = vc-intrinsics +PKG_VERS = 0.20.0 +PKG_EXT = tar.gz +PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT) +PKG_DIST_FILE = vc-intrinsics-$(PKG_VERS).$(PKG_EXT) +PKG_DIST_SITE = https://github.com/intel/vc-intrinsics/archive/refs/tags +PKG_DIR = $(PKG_NAME)-$(PKG_VERS) + +HOMEPAGE = https://github.com/intel/vc-intrinsics +COMMENT = Contains a set of new intrinsics on top of core LLVM IR instructions that represent SIMD semantics of a program targeting GPU. +LICENSE = MIT + +CONFIGURE_TARGET = nop +COMPILE_TARGET = nop +INSTALL_TARGET = nop + +POST_EXTRACT_TARGET = vc-intrinsics_post_extract_target + +include ../../mk/spksrc.cross-cmake.mk + +.PHONY: vc-intrinsics_post_extract_target +vc-intrinsics_post_extract_target: + @cd $(WORK_DIR) && ln -s $(PKG_DIR) $(PKG_NAME) diff --git a/cross/intel-vc-intrinsics.src/digests b/cross/intel-vc-intrinsics.src/digests new file mode 100644 index 00000000000..09ebd7d4ea5 --- /dev/null +++ b/cross/intel-vc-intrinsics.src/digests @@ -0,0 +1,3 @@ +vc-intrinsics-0.20.0.tar.gz SHA1 2e8926b0ce90e0c206dd5f04f874662a90ec20cb +vc-intrinsics-0.20.0.tar.gz SHA256 2ef1e668e128e87ac9bd4c93c1fc7ee0f7fb478a9bd0c7fdd684ce93a4524f96 +vc-intrinsics-0.20.0.tar.gz MD5 4aef42825204cc35d1f115b8569a4110 diff --git a/cross/intel-vc-intrinsics/Makefile b/cross/intel-vc-intrinsics/Makefile new file mode 100644 index 00000000000..7464f520cee --- /dev/null +++ b/cross/intel-vc-intrinsics/Makefile @@ -0,0 +1,25 @@ +PKG_NAME = vc-intrinsics +PKG_VERS = 0.20.0 +PKG_EXT = tar.gz +PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT) +PKG_DIST_FILE = vc-intrinsics-$(PKG_VERS).$(PKG_EXT) +PKG_DIST_SITE = https://github.com/intel/vc-intrinsics/archive/refs/tags +PKG_DIR = $(PKG_NAME)-$(PKG_VERS) + +HOMEPAGE = https://github.com/intel/vc-intrinsics +COMMENT = Contains a set of new intrinsics on top of core LLVM IR instructions that represent SIMD semantics of a program targeting GPU. +LICENSE = MIT + +DEPENDS = cross/intel-opencl-clang-140 + +POST_EXTRACT_TARGET = vc-intrinsics_post_extract_target +USE_NATIVE_CMAKE = 1 + +# External build: To configure VC Intrinsics with prebuilt LLVM +CMAKE_ARGS += -DLLVM_DIR=$(STAGING_INSTALL_PREFIX)/lib/cmake/llvm + +include ../../mk/spksrc.cross-cmake.mk + +.PHONY: vc-intrinsics_post_extract_target +vc-intrinsics_post_extract_target: + @cd $(WORK_DIR) && ln -s $(PKG_DIR) $(PKG_NAME) diff --git a/cross/intel-vc-intrinsics/PLIST b/cross/intel-vc-intrinsics/PLIST new file mode 100644 index 00000000000..fd39116a246 --- /dev/null +++ b/cross/intel-vc-intrinsics/PLIST @@ -0,0 +1 @@ +lib:lib/libLLVMGenXIntrinsics.so diff --git a/cross/intel-vc-intrinsics/digests b/cross/intel-vc-intrinsics/digests new file mode 100644 index 00000000000..09ebd7d4ea5 --- /dev/null +++ b/cross/intel-vc-intrinsics/digests @@ -0,0 +1,3 @@ +vc-intrinsics-0.20.0.tar.gz SHA1 2e8926b0ce90e0c206dd5f04f874662a90ec20cb +vc-intrinsics-0.20.0.tar.gz SHA256 2ef1e668e128e87ac9bd4c93c1fc7ee0f7fb478a9bd0c7fdd684ce93a4524f96 +vc-intrinsics-0.20.0.tar.gz MD5 4aef42825204cc35d1f115b8569a4110 diff --git a/cross/level-zero/Makefile b/cross/level-zero/Makefile deleted file mode 100644 index d2258709111..00000000000 --- a/cross/level-zero/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -PKG_NAME = level-zero -PKG_VERS = 1.9.4 -PKG_EXT = tar.gz -PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT) -PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) -PKG_DIST_SITE = https://github.com/oneapi-src/level-zero/archive -PKG_DIR = $(PKG_NAME)-$(PKG_VERS) - -DEPENDS = cross/intel-gmmlib -UNSUPPORTED_ARCHS = $(ARM_ARCHS) $(PPC_ARCHS) $(i686_ARCHS) - -HOMEPAGE = https://github.com/oneapi-src/level-zero -COMMENT = oneAPI Level Zero API is provides direct-to-metal interfaces to offload accelerator devices -LICENSE = MIT - -include ../../mk/spksrc.cross-cmake.mk - -# intel-media-driver specific args -# for succesfull build -CMAKE_ARGS += -Wno-dev diff --git a/cross/level-zero/PLIST b/cross/level-zero/PLIST deleted file mode 100644 index cf09674d9ba..00000000000 --- a/cross/level-zero/PLIST +++ /dev/null @@ -1,9 +0,0 @@ -lnk:lib/libze_loader.so -lnk:lib/libze_loader.so.1 -lib:lib/libze_loader.so.1.9.0 -lnk:lib/libze_tracing_layer.so -lnk:lib/libze_tracing_layer.so.1 -lib:lib/libze_tracing_layer.so.1.9.0 -lnk:lib/libze_validation_layer.so -lnk:lib/libze_validation_layer.so.1 -lib:lib/libze_validation_layer.so.1.9.0 diff --git a/cross/level-zero/digests b/cross/level-zero/digests deleted file mode 100644 index 58009430019..00000000000 --- a/cross/level-zero/digests +++ /dev/null @@ -1,3 +0,0 @@ -level-zero-1.9.4.tar.gz SHA1 6ca6efd24636fe7ac866db49b58070f59d91da78 -level-zero-1.9.4.tar.gz SHA256 7f91ed993be1e643c752cf95a319a0fc64113d91ec481fbb8a2f478f433d3380 -level-zero-1.9.4.tar.gz MD5 3a9469d1a04159e5d0801b32bf42247a diff --git a/cross/libdrm/Makefile b/cross/libdrm/Makefile index 6a8274216f5..a3ab52af9ce 100644 --- a/cross/libdrm/Makefile +++ b/cross/libdrm/Makefile @@ -1,5 +1,5 @@ PKG_NAME = libdrm -PKG_VERS = 2.4.121 +PKG_VERS = 2.4.122 PKG_EXT = tar.xz PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://dri.freedesktop.org/libdrm diff --git a/cross/libdrm/digests b/cross/libdrm/digests index 8303ea6d801..5ad962074db 100644 --- a/cross/libdrm/digests +++ b/cross/libdrm/digests @@ -1,3 +1,3 @@ -libdrm-2.4.121.tar.xz SHA1 dc61485b577eb7a69ad68d76cfac3ff033af87a0 -libdrm-2.4.121.tar.xz SHA256 909084a505d7638887f590b70791b3bbd9069c710c948f5d1f1ce6d080cdfcab -libdrm-2.4.121.tar.xz MD5 9eaa82b7b7a79972c6b11dd25a4356b1 +libdrm-2.4.122.tar.xz SHA1 cab543bdcdab935854ea65a2da4e303693611ce4 +libdrm-2.4.122.tar.xz SHA256 d9f5079b777dffca9300ccc56b10a93588cdfbc9dde2fae111940dfb6292f251 +libdrm-2.4.122.tar.xz MD5 143c8df50e09cd1eeb1fb53f05ecb64a diff --git a/cross/libva-latest/Makefile b/cross/libva-latest/Makefile index cf62da3efa6..e567855442d 100644 --- a/cross/libva-latest/Makefile +++ b/cross/libva-latest/Makefile @@ -1,5 +1,5 @@ PKG_NAME = libva -PKG_VERS = 2.21.0 +PKG_VERS = 2.22.0 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/intel/libva/archive diff --git a/cross/libva-latest/PLIST b/cross/libva-latest/PLIST index d44606169c8..3a33e78a962 100644 --- a/cross/libva-latest/PLIST +++ b/cross/libva-latest/PLIST @@ -1,6 +1,6 @@ lnk:lib/libva.so lnk:lib/libva.so.2 -lib:lib/libva.so.2.2100.0 +lib:lib/libva.so.2.2200.0 lnk:lib/libva-drm.so lnk:lib/libva-drm.so.2 -lib:lib/libva-drm.so.2.2100.0 +lib:lib/libva-drm.so.2.2200.0 diff --git a/cross/libva-latest/digests b/cross/libva-latest/digests index 4e42c311037..912bc76d054 100644 --- a/cross/libva-latest/digests +++ b/cross/libva-latest/digests @@ -1,3 +1,3 @@ -libva-2.21.0.tar.gz SHA1 e100acf40e88233ad6c6aac6edcfaa079c20c011 -libva-2.21.0.tar.gz SHA256 f7c3fffef3f04eb146e036dad2587d852bfb70e4926d014bf437244915ef7425 -libva-2.21.0.tar.gz MD5 2038f5b79612c1767ecd9bc281cd4189 +libva-2.22.0.tar.gz SHA1 e300c359c146bcd8a2af831135d4e6af87282bd1 +libva-2.22.0.tar.gz SHA256 467c418c2640a178c6baad5be2e00d569842123763b80507721ab87eb7af8735 +libva-2.22.0.tar.gz MD5 8dba13313d724b5e930f06e65b7437e2 diff --git a/cross/libva-utils-latest/Makefile b/cross/libva-utils-latest/Makefile index 25d2d2f3684..993cfa21867 100644 --- a/cross/libva-utils-latest/Makefile +++ b/cross/libva-utils-latest/Makefile @@ -1,5 +1,5 @@ PKG_NAME = libva-utils -PKG_VERS = 2.21.0 +PKG_VERS = 2.22.0 PKG_EXT = tar.gz PKG_DIST_NAME = $(PKG_VERS).$(PKG_EXT) PKG_DIST_SITE = https://github.com/intel/libva-utils/archive diff --git a/cross/libva-utils-latest/digests b/cross/libva-utils-latest/digests index 8b840a53150..adaf582acf0 100644 --- a/cross/libva-utils-latest/digests +++ b/cross/libva-utils-latest/digests @@ -1,3 +1,3 @@ -libva-utils-2.21.0.tar.gz SHA1 eb1d0e5922eddaed00366b90a31c43b91bcee965 -libva-utils-2.21.0.tar.gz SHA256 15ca12bd11c7001c04af5079512754fea6ba8d79151b9f07908c99b27622714e -libva-utils-2.21.0.tar.gz MD5 93c1857af947cbb374bf54282d1feb2b +libva-utils-2.22.0.tar.gz SHA1 6735cdd29a8770192ff67b5271eaa45f30fedbcf +libva-utils-2.22.0.tar.gz SHA256 7b57615c130427ec134bb5d2b80af516ce5bb19a40e89b1dab46a0d59760d96c +libva-utils-2.22.0.tar.gz MD5 835dd31a83b24c052b9d849e9c78d367 diff --git a/cross/llvm-project-140.src/Makefile b/cross/llvm-project-140.src/Makefile new file mode 100644 index 00000000000..97d582f0739 --- /dev/null +++ b/cross/llvm-project-140.src/Makefile @@ -0,0 +1,31 @@ +PKG_NAME = llvm-project +PKG_VERS = 14.0.5 +PKG_EXT = tar.xz +PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).src.$(PKG_EXT) +PKG_DIST_SITE = https://github.com/llvm/llvm-project/releases/download/llvmorg-$(PKG_VERS) +PKG_DIR = $(PKG_NAME)-$(PKG_VERS).src + +HOMEPAGE = https://llvm.org/ +COMMENT = The LLVM Project is a collection of modular and reusable compiler and toolchain technologies +LICENSE = Apache v2.0 with LLVM Exceptions + +# Limit to only needed files to reduce disk space usage +ADDITIONAL_EXTRACTFLAGS = $(PKG_DIR)/clang +ADDITIONAL_EXTRACTFLAGS += $(PKG_DIR)/cmake +ADDITIONAL_EXTRACTFLAGS += $(PKG_DIR)/libunwind +ADDITIONAL_EXTRACTFLAGS += $(PKG_DIR)/lld +ADDITIONAL_EXTRACTFLAGS += $(PKG_DIR)/llvm +ADDITIONAL_EXTRACTFLAGS += $(PKG_DIR)/third-party +POST_EXTRACT_TARGET = clang_post_extract_target + +CONFIGURE_TARGET = nop +COMPILE_TARGET = nop +INSTALL_TARGET = nop + +PATCHES_LEVEL = 1 + +include ../../mk/spksrc.cross-cmake.mk + +.PHONY: clang_post_extract_target +clang_post_extract_target: + @cd $(WORK_DIR) && ln -s $(PKG_DIR) $(PKG_NAME) diff --git a/cross/llvm-project-140.src/digests b/cross/llvm-project-140.src/digests new file mode 100644 index 00000000000..83be324ea83 --- /dev/null +++ b/cross/llvm-project-140.src/digests @@ -0,0 +1,3 @@ +llvm-project-14.0.5.src.tar.xz SHA1 6f4fdf8bf943ab2ae362739e7c7e1524f3470c77 +llvm-project-14.0.5.src.tar.xz SHA256 c9d27903ba3883c476a83cd515e36e1e07b0585db55692835de11385d9e3c8fa +llvm-project-14.0.5.src.tar.xz MD5 8fe06cfbec46c304f725db6beba18f35 diff --git a/cross/llvm-project-140.src/patches/1000-igc-HOWTO.txt b/cross/llvm-project-140.src/patches/1000-igc-HOWTO.txt new file mode 100644 index 00000000000..24cbecfc9e8 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1000-igc-HOWTO.txt @@ -0,0 +1,11 @@ +Following patches where copied over directly from the IGC source corresponding to current LLVM: +intel-graphics-compiler-igc-1.0.16695.4/external/llvm/releases/14.0.0/patches_external/* + +Latest versions of the patches available by cloning the git repository +$ git clone https://github.com/intel/intel-graphics-compiler.git + +Change to the patch directory +$ cd intel-graphics-compiler/external/llvm/releases/14.0.0/patches_external + +Renumber the patches: +$ i=1001 && ls -1 *.patch | while read LINE; do echo $(printf "%04d" $i)-igc-$LINE; mv $LINE $(printf "%04d" $i)-igc-$LINE; let i++; done diff --git a/cross/llvm-project-140.src/patches/1001-igc-0001-ConstantFold-Use-getFltSemantics-instead-of-manually.patch b/cross/llvm-project-140.src/patches/1001-igc-0001-ConstantFold-Use-getFltSemantics-instead-of-manually.patch new file mode 100644 index 00000000000..0bfc9160d91 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1001-igc-0001-ConstantFold-Use-getFltSemantics-instead-of-manually.patch @@ -0,0 +1,69 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2024 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +/*========================== begin_copyright_notice ============================ + +Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +See https://llvm.org/LICENSE.txt for license information. +SPDX-License-Identifier: Apache-2.0 with LLVM-exception + +============================= end_copyright_notice ===========================*/ + +From 08b20f20d2854377009822dfe597c78a4bf18de8 Mon Sep 17 00:00:00 2001 +From: Benjamin Kramer +Date: Thu, 5 May 2022 15:50:33 +0200 +Subject: [PATCH] [ConstantFold] Use getFltSemantics instead of manually + checking the type + +Simplifies the code and makes fpext/fptrunc constant folding not crash +when the result is bf16. +--- + llvm/lib/IR/ConstantFold.cpp | 10 ++-------- + llvm/test/Transforms/InstSimplify/ConstProp/cast.ll | 8 ++++++++ + 2 files changed, 10 insertions(+), 8 deletions(-) + +diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp +index 9cbbe2bf5df8..b032a3fea98f 100644 +--- a/llvm/lib/IR/ConstantFold.cpp ++++ b/llvm/lib/IR/ConstantFold.cpp +@@ -435,14 +435,8 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V, + if (ConstantFP *FPC = dyn_cast(V)) { + bool ignored; + APFloat Val = FPC->getValueAPF(); +- Val.convert(DestTy->isHalfTy() ? APFloat::IEEEhalf() : +- DestTy->isFloatTy() ? APFloat::IEEEsingle() : +- DestTy->isDoubleTy() ? APFloat::IEEEdouble() : +- DestTy->isX86_FP80Ty() ? APFloat::x87DoubleExtended() : +- DestTy->isFP128Ty() ? APFloat::IEEEquad() : +- DestTy->isPPC_FP128Ty() ? APFloat::PPCDoubleDouble() : +- APFloat::Bogus(), +- APFloat::rmNearestTiesToEven, &ignored); ++ Val.convert(DestTy->getFltSemantics(), APFloat::rmNearestTiesToEven, ++ &ignored); + return ConstantFP::get(V->getContext(), Val); + } + return nullptr; // Can't fold. +diff --git a/llvm/test/Transforms/InstSimplify/ConstProp/cast.ll b/llvm/test/Transforms/InstSimplify/ConstProp/cast.ll +index 8e9fd5fbae30..14eb29e636c6 100644 +--- a/llvm/test/Transforms/InstSimplify/ConstProp/cast.ll ++++ b/llvm/test/Transforms/InstSimplify/ConstProp/cast.ll +@@ -62,3 +62,11 @@ define <3 x half> @nan_v3f64_trunc() { + %f = fptrunc <3 x double> to <3 x half> + ret <3 x half> %f + } ++ ++define bfloat @nan_bf16_trunc() { ++; CHECK-LABEL: @nan_bf16_trunc( ++; CHECK-NEXT: ret bfloat 0xR7FC0 ++; ++ %f = fptrunc double 0x7FF0000000000001 to bfloat ++ ret bfloat %f ++} +-- +2.39.1.windows.1 + diff --git a/cross/llvm-project-140.src/patches/1002-igc-0001-ScalarEvolutionStackOverflowWindows.patch b/cross/llvm-project-140.src/patches/1002-igc-0001-ScalarEvolutionStackOverflowWindows.patch new file mode 100644 index 00000000000..e081715da35 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1002-igc-0001-ScalarEvolutionStackOverflowWindows.patch @@ -0,0 +1,293 @@ +diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h +index b16aa7017719..51558a37b9f0 100644 +--- a/llvm/include/llvm/Analysis/ScalarEvolution.h ++++ b/llvm/include/llvm/Analysis/ScalarEvolution.h +@@ -1599,9 +1599,17 @@ private: + ConstantRange getRangeForUnknownRecurrence(const SCEVUnknown *U); + + /// We know that there is no SCEV for the specified value. Analyze the +- /// expression. ++ /// expression recursively. + const SCEV *createSCEV(Value *V); + ++ /// We know that there is no SCEV for the specified value. Create a new SCEV ++ /// for \p V iteratively. ++ const SCEV *createSCEVIter(Value *V); ++ /// Collect operands of \p V for which SCEV expressions should be constructed ++ /// first. Returns a SCEV directly if it can be constructed trivially for \p ++ /// V. ++ const SCEV *getOperandsToCreate(Value *V, SmallVectorImpl &Ops); ++ + /// Provide the special handling we need to analyze PHI SCEVs. + const SCEV *createNodeForPHI(PHINode *PN); + +diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp +index 977fc0911355..fc9517ebb3f6 100644 +--- a/llvm/lib/Analysis/ScalarEvolution.cpp ++++ b/llvm/lib/Analysis/ScalarEvolution.cpp +@@ -4339,33 +4339,9 @@ void ScalarEvolution::insertValueToMap(Value *V, const SCEV *S) { + const SCEV *ScalarEvolution::getSCEV(Value *V) { + assert(isSCEVable(V->getType()) && "Value is not SCEVable!"); + +- const SCEV *S = getExistingSCEV(V); +- if (S == nullptr) { +- S = createSCEV(V); +- // During PHI resolution, it is possible to create two SCEVs for the same +- // V, so it is needed to double check whether V->S is inserted into +- // ValueExprMap before insert S->{V, 0} into ExprValueMap. +- std::pair Pair = +- ValueExprMap.insert({SCEVCallbackVH(V, this), S}); +- if (Pair.second) { +- ExprValueMap[S].insert({V, nullptr}); +- +- // If S == Stripped + Offset, add Stripped -> {V, Offset} into +- // ExprValueMap. +- const SCEV *Stripped = S; +- ConstantInt *Offset = nullptr; +- std::tie(Stripped, Offset) = splitAddExpr(S); +- // If stripped is SCEVUnknown, don't bother to save +- // Stripped -> {V, offset}. It doesn't simplify and sometimes even +- // increase the complexity of the expansion code. +- // If V is GetElementPtrInst, don't save Stripped -> {V, offset} +- // because it may generate add/sub instead of GEP in SCEV expansion. +- if (Offset != nullptr && !isa(Stripped) && +- !isa(V)) +- ExprValueMap[Stripped].insert({V, Offset}); +- } +- } +- return S; ++ if (const SCEV *S = getExistingSCEV(V)) ++ return S; ++ return createSCEVIter(V); + } + + const SCEV *ScalarEvolution::getExistingSCEV(Value *V) { +@@ -7020,6 +6996,228 @@ bool ScalarEvolution::loopIsFiniteByAssumption(const Loop *L) { + return isFinite(L) || (isMustProgress(L) && loopHasNoSideEffects(L)); + } + ++const SCEV *ScalarEvolution::createSCEVIter(Value *V) { ++ // Worklist item with a Value and a bool indicating whether all operands have ++ // been visited already. ++ using PointerTy = PointerIntPair; ++ SmallVector Stack; ++ ++ Stack.emplace_back(V, true); ++ Stack.emplace_back(V, false); ++ while (!Stack.empty()) { ++ auto E = Stack.pop_back_val(); ++ Value *CurV = E.getPointer(); ++ ++ if (getExistingSCEV(CurV)) ++ continue; ++ ++ SmallVector Ops; ++ const SCEV *CreatedSCEV = nullptr; ++ // If all operands have been visited already, create the SCEV. ++ if (E.getInt()) { ++ CreatedSCEV = createSCEV(CurV); ++ } else { ++ // Otherwise get the operands we need to create SCEV's for before creating ++ // the SCEV for CurV. If the SCEV for CurV can be constructed trivially, ++ // just use it. ++ CreatedSCEV = getOperandsToCreate(CurV, Ops); ++ } ++ ++ if (CreatedSCEV) { ++ insertValueToMap(CurV, CreatedSCEV); ++ } else { ++ // Queue CurV for SCEV creation, followed by its's operands which need to ++ // be constructed first. ++ Stack.emplace_back(CurV, true); ++ for (Value *Op : Ops) ++ Stack.emplace_back(Op, false); ++ } ++ } ++ ++ return getExistingSCEV(V); ++} ++ ++const SCEV * ++ScalarEvolution::getOperandsToCreate(Value *V, SmallVectorImpl &Ops) { ++ if (!isSCEVable(V->getType())) ++ return getUnknown(V); ++ ++ if (Instruction *I = dyn_cast(V)) { ++ // Don't attempt to analyze instructions in blocks that aren't ++ // reachable. Such instructions don't matter, and they aren't required ++ // to obey basic rules for definitions dominating uses which this ++ // analysis depends on. ++ if (!DT.isReachableFromEntry(I->getParent())) ++ return getUnknown(PoisonValue::get(V->getType())); ++ } else if (ConstantInt *CI = dyn_cast(V)) ++ return getConstant(CI); ++ else if (GlobalAlias *GA = dyn_cast(V)) { ++ if (!GA->isInterposable()) { ++ Ops.push_back(GA->getAliasee()); ++ return nullptr; ++ } ++ return getUnknown(V); ++ } else if (!isa(V)) ++ return getUnknown(V); ++ ++ Operator *U = cast(V); ++ if (auto BO = MatchBinaryOp(U, DT)) { ++ bool IsConstArg = isa(BO->RHS); ++ switch (U->getOpcode()) { ++ case Instruction::Add: ++ case Instruction::Mul: { ++ // For additions and multiplications, traverse add/mul chains for which we ++ // can potentially create a single SCEV, to reduce the number of ++ // get{Add,Mul}Expr calls. ++ do { ++ if (BO->Op) { ++ if (BO->Op != V && getExistingSCEV(BO->Op)) { ++ Ops.push_back(BO->Op); ++ break; ++ } ++ } ++ Ops.push_back(BO->RHS); ++ auto NewBO = MatchBinaryOp(BO->LHS, DT); ++ if (!NewBO || ++ (U->getOpcode() == Instruction::Add && ++ (NewBO->Opcode != Instruction::Add && ++ NewBO->Opcode != Instruction::Sub)) || ++ (U->getOpcode() == Instruction::Mul && ++ NewBO->Opcode != Instruction::Mul)) { ++ Ops.push_back(BO->LHS); ++ break; ++ } ++ // CreateSCEV calls getNoWrapFlagsFromUB, which under certain conditions ++ // requires a SCEV for the LHS. ++ if (NewBO->Op && (NewBO->IsNSW || NewBO->IsNUW)) { ++ auto *I = dyn_cast(NewBO->Op); ++ if (I && programUndefinedIfPoison(I)) { ++ Ops.push_back(BO->LHS); ++ break; ++ } ++ } ++ BO = NewBO; ++ } while (true); ++ return nullptr; ++ } ++ ++ case Instruction::AShr: ++ case Instruction::Shl: ++ case Instruction::Xor: ++ if (!IsConstArg) ++ return nullptr; ++ break; ++ case Instruction::And: ++ case Instruction::Or: ++ if (!IsConstArg && BO->LHS->getType()->isIntegerTy(1)) ++ return nullptr; ++ break; ++ default: ++ break; ++ } ++ ++ Ops.push_back(BO->LHS); ++ Ops.push_back(BO->RHS); ++ return nullptr; ++ } ++ ++ switch (U->getOpcode()) { ++ case Instruction::Trunc: ++ case Instruction::ZExt: ++ case Instruction::SExt: ++ case Instruction::PtrToInt: ++ Ops.push_back(U->getOperand(0)); ++ return nullptr; ++ ++ case Instruction::BitCast: ++ if (isSCEVable(U->getType()) && isSCEVable(U->getOperand(0)->getType())) { ++ Ops.push_back(U->getOperand(0)); ++ return nullptr; ++ } ++ return getUnknown(V); ++ ++ case Instruction::SDiv: ++ case Instruction::SRem: ++ Ops.push_back(U->getOperand(0)); ++ Ops.push_back(U->getOperand(1)); ++ return nullptr; ++ ++ case Instruction::GetElementPtr: ++ assert(cast(U)->getSourceElementType()->isSized() && ++ "GEP source element type must be sized"); ++ for (Value *Index : U->operands()) ++ Ops.push_back(Index); ++ return nullptr; ++ ++ case Instruction::IntToPtr: ++ return getUnknown(V); ++ ++ case Instruction::PHI: ++ // Keep constructing SCEVs' for phis recursively for now. ++ return nullptr; ++ ++ case Instruction::Select: { ++ // Check if U is a select that can be simplified to a SCEVUnknown. ++ auto CanSimplifyToUnknown = [this, U]() { ++ if (U->getType()->isIntegerTy(1) || isa(U->getOperand(0))) ++ return false; ++ ++ auto *ICI = dyn_cast(U->getOperand(0)); ++ if (!ICI) ++ return false; ++ Value *LHS = ICI->getOperand(0); ++ Value *RHS = ICI->getOperand(1); ++ if (ICI->getPredicate() == CmpInst::ICMP_EQ || ++ ICI->getPredicate() == CmpInst::ICMP_NE) { ++ if (!(isa(RHS) && cast(RHS)->isZero())) ++ return true; ++ } else if (getTypeSizeInBits(LHS->getType()) > ++ getTypeSizeInBits(U->getType())) ++ return true; ++ return false; ++ }; ++ if (CanSimplifyToUnknown()) ++ return getUnknown(U); ++ ++ for (Value *Inc : U->operands()) ++ Ops.push_back(Inc); ++ return nullptr; ++ break; ++ } ++ case Instruction::Call: ++ case Instruction::Invoke: ++ if (Value *RV = cast(U)->getReturnedArgOperand()) { ++ Ops.push_back(RV); ++ return nullptr; ++ } ++ ++ if (auto *II = dyn_cast(U)) { ++ switch (II->getIntrinsicID()) { ++ case Intrinsic::abs: ++ Ops.push_back(II->getArgOperand(0)); ++ return nullptr; ++ case Intrinsic::umax: ++ case Intrinsic::umin: ++ case Intrinsic::smax: ++ case Intrinsic::smin: ++ case Intrinsic::usub_sat: ++ case Intrinsic::uadd_sat: ++ Ops.push_back(II->getArgOperand(0)); ++ Ops.push_back(II->getArgOperand(1)); ++ return nullptr; ++ case Intrinsic::start_loop_iterations: ++ Ops.push_back(II->getArgOperand(0)); ++ return nullptr; ++ default: ++ break; ++ } ++ } ++ break; ++ } ++ ++ return nullptr; ++} ++ + const SCEV *ScalarEvolution::createSCEV(Value *V) { + if (!isSCEVable(V->getType())) + return getUnknown(V); diff --git a/cross/llvm-project-140.src/patches/1003-igc-0002-ScalarEvolutionStackOverflowWindows.patch b/cross/llvm-project-140.src/patches/1003-igc-0002-ScalarEvolutionStackOverflowWindows.patch new file mode 100644 index 00000000000..a28397d7d7b --- /dev/null +++ b/cross/llvm-project-140.src/patches/1003-igc-0002-ScalarEvolutionStackOverflowWindows.patch @@ -0,0 +1,188 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2023-2024 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +/*========================== begin_copyright_notice ============================ + +Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +See https://llvm.org/LICENSE.txt for license information. +SPDX-License-Identifier: Apache-2.0 with LLVM-exception + +============================= end_copyright_notice ===========================*/ + +diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h +index 51558a37b..a2069980a 100644 +--- a/llvm/include/llvm/Analysis/ScalarEvolution.h ++++ b/llvm/include/llvm/Analysis/ScalarEvolution.h +@@ -1613,6 +1613,9 @@ private: + /// Provide the special handling we need to analyze PHI SCEVs. + const SCEV *createNodeForPHI(PHINode *PN); + ++ /// Helper function to get a single start and back edge value from a phi node. ++ std::pair getStartAndBackEdgeValues(PHINode *PN); ++ + /// Helper function called from createNodeForPHI. + const SCEV *createAddRecFromPHI(PHINode *PN); + +diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp +index fc9517ebb..facfe1c7d 100644 +--- a/llvm/lib/Analysis/ScalarEvolution.cpp ++++ b/llvm/lib/Analysis/ScalarEvolution.cpp +@@ -5529,10 +5529,11 @@ const SCEV *ScalarEvolution::createSimpleAffineAddRec(PHINode *PN, + return PHISCEV; + } + +-const SCEV *ScalarEvolution::createAddRecFromPHI(PHINode *PN) { ++std::pair ++ScalarEvolution::getStartAndBackEdgeValues(PHINode *PN) { + const Loop *L = LI.getLoopFor(PN->getParent()); + if (!L || L->getHeader() != PN->getParent()) +- return nullptr; ++ return {}; + + // The loop may have multiple entrances or multiple exits; we can analyze + // this phi as an addrec if it has a unique entry value and a unique +@@ -5555,10 +5556,18 @@ const SCEV *ScalarEvolution::createAddRecFromPHI(PHINode *PN) { + } + } + if (!BEValueV || !StartValueV) +- return nullptr; ++ return {}; ++ return {StartValueV, BEValueV}; ++} + +- assert(ValueExprMap.find_as(PN) == ValueExprMap.end() && +- "PHI node already processed?"); ++const SCEV *ScalarEvolution::createAddRecFromPHI(PHINode *PN) { ++ // The loop may have multiple entrances or multiple exits; we can analyze ++ // this phi as an addrec if it has a unique entry value and a unique ++ // backedge value. ++ std::pair StartAndBEValueV = getStartAndBackEdgeValues(PN); ++ Value *BEValueV = StartAndBEValueV.second, *StartValueV = StartAndBEValueV.first; ++ if (!BEValueV || !StartValueV) ++ return nullptr; + + // First, try to find AddRec expression without creating a fictituos symbolic + // value for PN. +@@ -5572,6 +5581,7 @@ const SCEV *ScalarEvolution::createAddRecFromPHI(PHINode *PN) { + // Using this symbolic name for the PHI, analyze the value coming around + // the back-edge. + const SCEV *BEValue = getSCEV(BEValueV); ++ const Loop *L = LI.getLoopFor(PN->getParent()); + + // NOTE: If BEValue is loop invariant, we know that the PHI node just + // has a special value for the first iteration of the loop. +@@ -5772,8 +5782,15 @@ static bool IsAvailableOnEntry(const Loop *L, DominatorTree &DT, const SCEV *S, + // Try to match a control flow sequence that branches out at BI and merges back + // at Merge into a "C ? LHS : RHS" select pattern. Return true on a successful + // match. +-static bool BrPHIToSelect(DominatorTree &DT, BranchInst *BI, PHINode *Merge, +- Value *&C, Value *&LHS, Value *&RHS) { ++static bool BrPHIToSelect(DominatorTree &DT, PHINode *Merge, Value *&C, ++ Value *&LHS, Value *&RHS) { ++ ++ BasicBlock *IDom = DT[Merge->getParent()]->getIDom()->getBlock(); ++ assert(IDom && "At least the entry block should dominate PN"); ++ ++ auto *BI = dyn_cast(IDom->getTerminator()); ++ if (!BI || !BI->isConditional()) ++ return false; + C = BI->getCondition(); + + BasicBlockEdge LeftEdge(BI->getParent(), BI->getSuccessor(0)); +@@ -5802,6 +5819,11 @@ static bool BrPHIToSelect(DominatorTree &DT, BranchInst *BI, PHINode *Merge, + return false; + } + ++static bool BrPHIToSelect(DominatorTree& DT, PHINode* Merge) { ++ Value *Cond = nullptr, *LHS = nullptr, *RHS = nullptr; ++ return BrPHIToSelect(DT, Merge, Cond, LHS, RHS); ++} ++ + const SCEV *ScalarEvolution::createNodeFromSelectLikePHI(PHINode *PN) { + auto IsReachable = + [&](BasicBlock *BB) { return DT.isReachableFromEntry(BB); }; +@@ -5824,18 +5846,16 @@ const SCEV *ScalarEvolution::createNodeFromSelectLikePHI(PHINode *PN) { + // V = phi [ %x, %left ], [ %y, %right ] + // + // as "select %cond, %x, %y" +- +- BasicBlock *IDom = DT[PN->getParent()]->getIDom()->getBlock(); +- assert(IDom && "At least the entry block should dominate PN"); +- +- auto *BI = dyn_cast(IDom->getTerminator()); + Value *Cond = nullptr, *LHS = nullptr, *RHS = nullptr; + +- if (BI && BI->isConditional() && +- BrPHIToSelect(DT, BI, PN, Cond, LHS, RHS) && ++ // do not run over cycled PHIs while processing createNodeFromSelectLikePHI ++ const SCEV* S = nullptr; ++ if (BrPHIToSelect(DT, PN, Cond, LHS, RHS) && + IsAvailableOnEntry(L, DT, getSCEV(LHS), PN->getParent()) && +- IsAvailableOnEntry(L, DT, getSCEV(RHS), PN->getParent())) +- return createNodeForSelectOrPHI(PN, Cond, LHS, RHS); ++ IsAvailableOnEntry(L, DT, getSCEV(RHS), PN->getParent())) { ++ S = createNodeForSelectOrPHI(PN, Cond, LHS, RHS); ++ } ++ return S; + } + + return nullptr; +@@ -7004,6 +7024,7 @@ const SCEV *ScalarEvolution::createSCEVIter(Value *V) { + + Stack.emplace_back(V, true); + Stack.emplace_back(V, false); ++ + while (!Stack.empty()) { + auto E = Stack.pop_back_val(); + Value *CurV = E.getPointer(); +@@ -7023,14 +7044,15 @@ const SCEV *ScalarEvolution::createSCEVIter(Value *V) { + CreatedSCEV = getOperandsToCreate(CurV, Ops); + } + +- if (CreatedSCEV) { ++ if (CreatedSCEV) + insertValueToMap(CurV, CreatedSCEV); +- } else { ++ else { + // Queue CurV for SCEV creation, followed by its's operands which need to + // be constructed first. + Stack.emplace_back(CurV, true); +- for (Value *Op : Ops) ++ for (Value *Op : Ops) { + Stack.emplace_back(Op, false); ++ } + } + } + +@@ -7152,9 +7174,24 @@ ScalarEvolution::getOperandsToCreate(Value *V, SmallVectorImpl &Ops) { + case Instruction::IntToPtr: + return getUnknown(V); + +- case Instruction::PHI: +- // Keep constructing SCEVs' for phis recursively for now. ++ case Instruction::PHI: { ++ PHINode *PN = cast(U); ++ ++ if (PN->getNumIncomingValues() == 2) { ++ std::pair StartAndBEValueV = ++ getStartAndBackEdgeValues(PN); ++ if (StartAndBEValueV.first && StartAndBEValueV.second) ++ // resolve recursively - may create cycles ++ return nullptr; ++ else if (BrPHIToSelect(DT, PN)) ++ // resolve iteratively - does not create cycles ++ for (auto &Op : PN->operands()) ++ Ops.push_back(Op); ++ } ++ ++ // resolve iteratively - does not create SCEV cycles (trivially resolved) + return nullptr; ++ } + + case Instruction::Select: { + // Check if U is a select that can be simplified to a SCEVUnknown. diff --git a/cross/llvm-project-140.src/patches/1004-igc-0003-ScalarEvolutionStackOverflowWindows.patch b/cross/llvm-project-140.src/patches/1004-igc-0003-ScalarEvolutionStackOverflowWindows.patch new file mode 100644 index 00000000000..ce16feecefe --- /dev/null +++ b/cross/llvm-project-140.src/patches/1004-igc-0003-ScalarEvolutionStackOverflowWindows.patch @@ -0,0 +1,127 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2023-2024 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +/*========================== begin_copyright_notice ============================ + +Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +See https://llvm.org/LICENSE.txt for license information. +SPDX-License-Identifier: Apache-2.0 with LLVM-exception + +============================= end_copyright_notice ===========================*/ + +# TODO: Once upstreamed, update with LLORG revision & adjust per community review + +diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp +index e765a4d54..8712103b5 100644 +--- a/llvm/lib/Analysis/ScalarEvolution.cpp ++++ b/llvm/lib/Analysis/ScalarEvolution.cpp +@@ -5576,12 +5576,14 @@ const SCEV *ScalarEvolution::createAddRecFromPHI(PHINode *PN) { + + // First, try to find AddRec expression without creating a fictituos symbolic + // value for PN. +- if (auto *S = createSimpleAffineAddRec(PN, BEValueV, StartValueV)) +- return S; ++ // if (auto *S = createSimpleAffineAddRec(PN, BEValueV, StartValueV)) ++ // return S; + + // Handle PHI node value symbolically. +- const SCEV *SymbolicName = getUnknown(PN); +- insertValueToMap(PN, SymbolicName); ++ // const SCEV *SymbolicName = getUnknown(PN); ++ // insertValueToMap(PN, SymbolicName); ++ const SCEV *SymbolicName = getExistingSCEV(PN); ++ assert(SymbolicName); + + // Using this symbolic name for the PHI, analyze the value coming around + // the back-edge. +@@ -5789,6 +5791,8 @@ static bool IsAvailableOnEntry(const Loop *L, DominatorTree &DT, const SCEV *S, + // match. + static bool BrPHIToSelect(DominatorTree &DT, PHINode *Merge, Value *&C, + Value *&LHS, Value *&RHS) { ++ if (Merge->getNumIncomingValues() != 2) ++ return false; + + BasicBlock *IDom = DT[Merge->getParent()]->getIDom()->getBlock(); + assert(IDom && "At least the entry block should dominate PN"); +@@ -7094,14 +7098,13 @@ const SCEV *ScalarEvolution::createSCEVIter(Value *V) { + using PointerTy = PointerIntPair; + SmallVector Stack; + +- Stack.emplace_back(V, true); + Stack.emplace_back(V, false); + + while (!Stack.empty()) { + auto E = Stack.pop_back_val(); + Value *CurV = E.getPointer(); + +- if (getExistingSCEV(CurV)) ++ if (getExistingSCEV(CurV) && !E.getInt()) + continue; + + SmallVector Ops; +@@ -7118,7 +7121,7 @@ const SCEV *ScalarEvolution::createSCEVIter(Value *V) { + + if (CreatedSCEV) + insertValueToMap(CurV, CreatedSCEV); +- else { ++ if (!Ops.empty() || !CreatedSCEV) { + // Queue CurV for SCEV creation, followed by its's operands which need to + // be constructed first. + Stack.emplace_back(CurV, true); +@@ -7249,20 +7252,43 @@ ScalarEvolution::getOperandsToCreate(Value *V, SmallVectorImpl &Ops) { + case Instruction::PHI: { + PHINode *PN = cast(U); + ++ // This phi's operands must be attached due to range computations even if it is redundant to determine its SCEV expression. ++ for (auto &Op : PN->operands()) ++ Ops.push_back(Op); ++ ++ // Check if it can be classified as a special scalar evolution expression like: ++ // * addrec, ++ // * phi-like-select. + if (PN->getNumIncomingValues() == 2) { + std::pair StartAndBEValueV = + getStartAndBackEdgeValues(PN); +- if (StartAndBEValueV.first && StartAndBEValueV.second) +- // resolve recursively - may create cycles ++ Value *BEValueV = StartAndBEValueV.second, ++ *StartValueV = StartAndBEValueV.first; ++ if (BEValueV && StartValueV) ++ // This phi instruction is initially defined as undefined and can be ++ // replaced with an addrec expression if it meets requirements. ++ // This may create cycles. ++ return getUnknown(V); ++ ++ if (BrPHIToSelect(DT, PN)) ++ // This phi instruction might be classified as a phi-like-select ++ // expression. Any initial definition cannot be applied since this ++ // pattern doesn't support such a path as dedicated to addrec ++ // expressions. + return nullptr; +- else if (BrPHIToSelect(DT, PN)) +- // resolve iteratively - does not create cycles +- for (auto &Op : PN->operands()) +- Ops.push_back(Op); + } + +- // resolve iteratively - does not create SCEV cycles (trivially resolved) +- return nullptr; ++ // This means that this phi instruction has one common input value. ++ // This cannot create cycles due to SSA properties (an usage of the value ++ // cannot be before its definition and this leads to a conclusion that it must ++ // dominate over this phi instruction to meet the initial assumptions). ++ if (Value *V = SimplifyInstruction(PN, {getDataLayout(), &TLI, &DT, &AC})) ++ if (LI.replacementPreservesLCSSAForm(PN, V)) ++ return nullptr; ++ ++ // This phi instruction is classified as undefined due to ++ // an unsupported pattern. This may create cycles. ++ return getUnknown(V); + } + + case Instruction::Select: { diff --git a/cross/llvm-project-140.src/patches/1005-igc-alter-unroll-max-upperbound-command-line-option-value.patch b/cross/llvm-project-140.src/patches/1005-igc-alter-unroll-max-upperbound-command-line-option-value.patch new file mode 100644 index 00000000000..d6ded0e4dbc --- /dev/null +++ b/cross/llvm-project-140.src/patches/1005-igc-alter-unroll-max-upperbound-command-line-option-value.patch @@ -0,0 +1,39 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2021-2023 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +/*========================== begin_copyright_notice ============================ + +Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +See https://llvm.org/LICENSE.txt for license information. +SPDX-License-Identifier: Apache-2.0 with LLVM-exception + +============================= end_copyright_notice ===========================*/ + +diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +index 9beb2281c..a3cc73ca5 100644 +--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp ++++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +@@ -968,7 +968,7 @@ bool llvm::computeUnrollCount( + // cost of exact full unrolling. As such, if we have an exact count and + // found it unprofitable, we'll never chose to bounded unroll. + if (!TripCount && MaxTripCount && (UP.UpperBound || MaxOrZero) && +- MaxTripCount <= UnrollMaxUpperBound) { ++ MaxTripCount < std::max(16U, UnrollMaxUpperBound.getValue())) { + UP.Count = MaxTripCount; + if (auto UnrollFactor = shouldFullUnroll(L, TTI, DT, SE, EphValues, + MaxTripCount, UCE, UP)) { +@@ -1042,7 +1042,8 @@ bool llvm::computeUnrollCount( + } + + // Don't unroll a small upper bound loop unless user or TTI asked to do so. +- if (MaxTripCount && !UP.Force && MaxTripCount < UnrollMaxUpperBound) { ++ if (MaxTripCount && !UP.Force && ++ MaxTripCount < std::max(16U, UnrollMaxUpperBound.getValue())) { + UP.Count = 0; + return false; + } diff --git a/cross/llvm-project-140.src/patches/1006-igc-Backport-When-creating-a-stack-space-for-inlined-byv.patch b/cross/llvm-project-140.src/patches/1006-igc-Backport-When-creating-a-stack-space-for-inlined-byv.patch new file mode 100644 index 00000000000..05ef05a870d --- /dev/null +++ b/cross/llvm-project-140.src/patches/1006-igc-Backport-When-creating-a-stack-space-for-inlined-byv.patch @@ -0,0 +1,32 @@ +From 52fc8d7dc229c68b87f7dba8be84ade0f0eb430a Mon Sep 17 00:00:00 2001 +From: Victor Mustya +Date: Mon, 31 Oct 2022 13:27:02 -0700 +Subject: =?UTF-8?q?[Backport]=20When=20creating=20a=20stack=20space=20for?= + =?UTF-8?q?=20inlined=20byval=20args,=0A=20use=20the=20same=20addrspace=20?= + =?UTF-8?q?as=20the=20original=20argument.?= + +From: Chang-Sun Lin Jr +--- + llvm/lib/Transforms/Utils/InlineFunction.cpp | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp +index 923bcc781e47..1d6dca24a4ad 100644 +--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp ++++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp +@@ -1429,6 +1429,12 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg, + Arg->getName(), &*Caller->begin()->begin()); + IFI.StaticAllocas.push_back(cast(NewAlloca)); + ++ // If the byval was in a different address space, add a cast. ++ if (DL.getAllocaAddrSpace() != Arg->getType()->getPointerAddressSpace()) { ++ NewAlloca = new AddrSpaceCastInst( ++ NewAlloca, Arg->getType(), "", ++ cast(NewAlloca)->getNextNonDebugInstruction()); ++ } + // Uses of the argument in the function should use our new alloca + // instead. + return NewAlloca; +-- +2.34.1 + diff --git a/cross/llvm-project-140.src/patches/1007-igc-BasicAA-decreaseQueryDepthOption.patch b/cross/llvm-project-140.src/patches/1007-igc-BasicAA-decreaseQueryDepthOption.patch new file mode 100644 index 00000000000..96fbd320b5c --- /dev/null +++ b/cross/llvm-project-140.src/patches/1007-igc-BasicAA-decreaseQueryDepthOption.patch @@ -0,0 +1,54 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2023 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +/*========================== begin_copyright_notice ============================ + +Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +See https://llvm.org/LICENSE.txt for license information. +SPDX-License-Identifier: Apache-2.0 with LLVM-exception + +============================= end_copyright_notice ===========================*/ + +# Description +# +# Add an option that would allow us to roll back the limit of recursive AA +# queries, and thus avoid stack overflows for LoopOpt-intensive cases. The +# patch retains the default value set within LLORG commit 1d9f4903c. +# TODO: Once upstreamed, update with LLORG revision & adjust per community review. +# A better, but heavier long-term fix would involve a complete rework of +# BasicAA iteration logic so as to avoid recursion altogether. + +diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp +index 0a0b53796..76365c38a 100644 +--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp ++++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp +@@ -69,6 +69,11 @@ using namespace llvm; + static cl::opt EnableRecPhiAnalysis("basic-aa-recphi", cl::Hidden, + cl::init(true)); + ++/// Limit depth of reqursive AA queries. The limit is set to be large enough so ++/// that it's hit very rarely, yet small enough to avoid stack overflows. ++static cl::opt AAQueryDepthLimit("basic-aa-max-query-depth", cl::Hidden, ++ cl::init(512)); ++ + /// SearchLimitReached / SearchTimes shows how often the limit of + /// to decompose GEPs is reached. It will affect the precision + /// of basic alias analysis. +@@ -1628,10 +1633,8 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size, + } + + // FIXME: If this depth limit is hit, then we may cache sub-optimal results +- // for recursive queries. For this reason, this limit is chosen to be large +- // enough to be very rarely hit, while still being small enough to avoid +- // stack overflows. +- if (AAQI.Depth >= 512) ++ // for recursive queries. ++ if (AAQI.Depth >= AAQueryDepthLimit) + return AliasResult::MayAlias; + + // Check the cache before climbing up use-def chains. This also terminates \ No newline at end of file diff --git a/cross/llvm-project-140.src/patches/1008-igc-check-for-NaN-before-folding-select-for-FP.patch b/cross/llvm-project-140.src/patches/1008-igc-check-for-NaN-before-folding-select-for-FP.patch new file mode 100644 index 00000000000..59010659803 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1008-igc-check-for-NaN-before-folding-select-for-FP.patch @@ -0,0 +1,58 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2023 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +/*========================== begin_copyright_notice ============================ + +Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +See https://llvm.org/LICENSE.txt for license information. +SPDX-License-Identifier: Apache-2.0 with LLVM-exception + +============================= end_copyright_notice ===========================*/ + +# TODO: Once upstreamed, update with LLORG revision & adjust per community review + +From a7317169c80681f9128c22f5f071e206b7617c28 Mon Sep 17 00:00:00 2001 +From: Artem Gindinson +Date: Wed, 23 Aug 2023 15:49:30 +0200 +Subject: [PATCH] [InstCombine] Check for NaN before folding `select` for FP + operators + +--- + llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +index 881b00f2a..9cdde7433 100644 +--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp ++++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +@@ -455,6 +455,12 @@ Instruction *InstCombinerImpl::foldSelectIntoOp(SelectInst &SI, Value *TrueVal, + } + + if (OpToFold) { ++ FastMathFlags FMF; ++ if (isa(&SI)) { ++ FMF = SI.getFastMathFlags(); ++ if (!FMF.noNaNs()) ++ return nullptr; ++ } + Constant *C = ConstantExpr::getBinOpIdentity(TVI->getOpcode(), + TVI->getType(), true); + Value *OOp = TVI->getOperand(2-OpToFold); +@@ -487,6 +493,12 @@ Instruction *InstCombinerImpl::foldSelectIntoOp(SelectInst &SI, Value *TrueVal, + } + + if (OpToFold) { ++ FastMathFlags FMF; ++ if (isa(&SI)) { ++ FMF = SI.getFastMathFlags(); ++ if (!FMF.noNaNs()) ++ return nullptr; ++ } + Constant *C = ConstantExpr::getBinOpIdentity(FVI->getOpcode(), + FVI->getType(), true); + Value *OOp = FVI->getOperand(2-OpToFold); diff --git a/cross/llvm-project-140.src/patches/1009-igc-Don-t-emit-bitreverse-or-bswap-intrinsics-of-illegal.patch b/cross/llvm-project-140.src/patches/1009-igc-Don-t-emit-bitreverse-or-bswap-intrinsics-of-illegal.patch new file mode 100644 index 00000000000..4247c887907 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1009-igc-Don-t-emit-bitreverse-or-bswap-intrinsics-of-illegal.patch @@ -0,0 +1,28 @@ +From bb273d139a624bfe2db3d1cd2dd1397cabdfa0e4 Mon Sep 17 00:00:00 2001 +From: Victor Mustya +Date: Tue, 22 Aug 2023 11:10:30 -0700 +Subject: [PATCH] Don't emit bitreverse or bswap intrinsics of illegal bit + width during instcombine + +--- + llvm/lib/Transforms/Utils/Local.cpp | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp +index 1c350a258..9ba4f128c 100644 +--- a/llvm/lib/Transforms/Utils/Local.cpp ++++ b/llvm/lib/Transforms/Utils/Local.cpp +@@ -3178,6 +3178,10 @@ bool llvm::recognizeBSwapOrBitReverseIdiom( + if (DemandedBW > ITy->getScalarSizeInBits()) + return false; + ++ auto &DL = I->getModule()->getDataLayout(); ++ if (DL.isIllegalInteger(DemandedBW)) ++ return false; ++ + // Now, is the bit permutation correct for a bswap or a bitreverse? We can + // only byteswap values with an even number of bytes. + APInt DemandedMask = APInt::getAllOnes(DemandedBW); +-- +2.34.1 + diff --git a/cross/llvm-project-140.src/patches/1010-igc-fix_for_llvm-as_buildbreak.patch b/cross/llvm-project-140.src/patches/1010-igc-fix_for_llvm-as_buildbreak.patch new file mode 100644 index 00000000000..ffebc6e38d4 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1010-igc-fix_for_llvm-as_buildbreak.patch @@ -0,0 +1,19 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2021 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +# Description : Fix build break for building llvm-as + +--- a/llvm/tools/llvm-as/CMakeLists.txt ++++ b/llvm/tools/llvm-as/CMakeLists.txt +@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS + AsmParser + BitWriter + Core ++ Demangle + Support + ) diff --git a/cross/llvm-project-140.src/patches/1011-igc-fix_for_llvm-link_buildbreak.patch b/cross/llvm-project-140.src/patches/1011-igc-fix_for_llvm-link_buildbreak.patch new file mode 100644 index 00000000000..6da3697f538 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1011-igc-fix_for_llvm-link_buildbreak.patch @@ -0,0 +1,20 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2021 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +# Description : Fix build break for building llvm-link + +--- a/llvm/tools/llvm-link/CMakeLists.txt ++++ b/llvm/tools/llvm-link/CMakeLists.txt +@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS + Support + TransformUtils + IPO ++ Demangle + ) + + add_llvm_tool(llvm-link diff --git a/cross/llvm-project-140.src/patches/1012-igc-fix_for_opt_buildbreak.patch b/cross/llvm-project-140.src/patches/1012-igc-fix_for_opt_buildbreak.patch new file mode 100644 index 00000000000..c9488c992e5 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1012-igc-fix_for_opt_buildbreak.patch @@ -0,0 +1,20 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2021 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +# Description : Fix build break for building opt + +--- a/llvm/tools/opt/CMakeLists.txt ++++ b/llvm/tools/opt/CMakeLists.txt +@@ -9,6 +9,7 @@ set(LLVM_LINK_COMPONENTS + CodeGen + Core + Coroutines ++ Demangle + Extensions + IPO + IRReader diff --git a/cross/llvm-project-140.src/patches/1013-igc-IndVarSimplify-Do-not-use-SCEV-expander-for-IVCount-.patch b/cross/llvm-project-140.src/patches/1013-igc-IndVarSimplify-Do-not-use-SCEV-expander-for-IVCount-.patch new file mode 100644 index 00000000000..8d0a446beae --- /dev/null +++ b/cross/llvm-project-140.src/patches/1013-igc-IndVarSimplify-Do-not-use-SCEV-expander-for-IVCount-.patch @@ -0,0 +1,142 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2021 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +From 35e218a886f4c066eabd18685240d55270bd5a6d Mon Sep 17 00:00:00 2001 +From: Aleksander Us +Date: Mon, 26 Aug 2019 15:45:47 +0300 +Subject: [PATCH] [IndVarSimplify] Do not use SCEV expander for IVCount in + LFTR when possible. + +SCEV analysis cannot properly cache instruction with poison flags +(for example, add nsw outside of loop will not be reused by expander). +This can lead to generating of additional instructions by SCEV expander. + +Example IR: + + ... + %maxval = add nuw nsw i32 %a1, %a2 + ... +for.body: + ... + %cmp22 = icmp ult i32 %ivadd, %maxval + br i1 %cmp22, label %for.body, label %for.end + ... + +SCEV expander will generate copy of %maxval in preheader but without +nuw/nsw flags. This can be avoided by explicit check that iv count +value gives the same SCEV expressions as calculated by LFTR. +--- + lib/Transforms/Scalar/IndVarSimplify.cpp | 12 +++++++++- + test/Transforms/IndVarSimplify/add_nsw.ll | 23 ++++++++++++++++++++ + test/Transforms/IndVarSimplify/lftr-reuse.ll | 9 +++----- + test/Transforms/IndVarSimplify/udiv.ll | 1 + + 4 files changed, 38 insertions(+), 7 deletions(-) + create mode 100644 test/Transforms/IndVarSimplify/add_nsw.ll + +diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +index f9fc698a4a9..5e04dac8aa6 100644 +--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp ++++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +@@ -2375,6 +2375,17 @@ static Value *genLoopLimit(PHINode *IndVar, BasicBlock *ExitingBB, + if (UsePostInc) + IVLimit = SE->getAddExpr(IVLimit, SE->getOne(IVLimit->getType())); + ++ // If computed limit is equal to old limit then do not use SCEV expander ++ // because it can lost NUW/NSW flags and create extra instructions. ++ BranchInst *BI = cast(ExitingBB->getTerminator()); ++ if (ICmpInst *Cmp = dyn_cast(BI->getOperand(0))) { ++ Value *Limit = Cmp->getOperand(0); ++ if (!L->isLoopInvariant(Limit)) ++ Limit = Cmp->getOperand(1); ++ if (SE->getSCEV(Limit) == IVLimit) ++ return Limit; ++ } ++ + // Expand the code for the iteration count. + assert(SE->isLoopInvariant(IVLimit, L) && + "Computed iteration count is not loop invariant!"); +@@ -2383,7 +2394,6 @@ static Value *genLoopLimit(PHINode *IndVar, BasicBlock *ExitingBB, + // SCEV expression (IVInit) for a pointer type IV value (IndVar). + Type *LimitTy = ExitCount->getType()->isPointerTy() ? + IndVar->getType() : ExitCount->getType(); +- BranchInst *BI = cast(ExitingBB->getTerminator()); + return Rewriter.expandCodeFor(IVLimit, LimitTy, BI); + } + } +diff --git a/llvm/test/Transforms/IndVarSimplify/add_nsw.ll b/llvm/test/Transforms/IndVarSimplify/add_nsw.ll +new file mode 100644 +index 00000000000..abd1cbb6c51 +--- /dev/null ++++ b/llvm/test/Transforms/IndVarSimplify/add_nsw.ll +@@ -0,0 +1,23 @@ ++; RUN: opt -indvars -S %s | FileCheck %s ++ ++target datalayout = "e-p:32:32-i64:64-n8:16:32" ++ ++; CHECK: for.body.preheader: ++; CHECK-NOT: add ++; CHECK: for.body: ++ ++define void @foo(i32 %a1, i32 %a2) { ++entry: ++ %maxval = add nuw nsw i32 %a1, %a2 ++ %cmp = icmp slt i32 %maxval, 1 ++ br i1 %cmp, label %for.end, label %for.body ++ ++for.body: ; preds = %entry, %for.body ++ %j.02 = phi i32 [ 0, %entry ], [ %add31, %for.body ] ++ %add31 = add nuw nsw i32 %j.02, 1 ++ %cmp22 = icmp slt i32 %add31, %maxval ++ br i1 %cmp22, label %for.body, label %for.end ++ ++for.end: ; preds = %for.body ++ ret void ++} +diff --git a/llvm/test/Transforms/IndVarSimplify/lftr-reuse.ll b/llvm/test/Transforms/IndVarSimplify/lftr-reuse.ll +index 96dd92d13..8be983cc7 100644 +--- a/llvm/test/Transforms/IndVarSimplify/lftr-reuse.ll ++++ b/llvm/test/Transforms/IndVarSimplify/lftr-reuse.ll +@@ -70,7 +70,7 @@ define void @expandOuterRecurrence(i32 %arg) nounwind { + ; CHECK-NEXT: br label [[OUTER:%.*]] + ; CHECK: outer: + ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i32 [ [[SUB1]], [[OUTER_PREHEADER]] ], [ [[INDVARS_IV_NEXT:%.*]], [[OUTER_INC:%.*]] ] +-; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_INC:%.*]], [[OUTER_INC]] ], [ 0, [[OUTER_PREHEADER]] ] ++; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_INC:%.*]], [[OUTER_INC:%.*]] ], [ 0, [[OUTER_PREHEADER]] ] + ; CHECK-NEXT: [[SUB2:%.*]] = sub nsw i32 [[ARG]], [[I]] + ; CHECK-NEXT: [[SUB3:%.*]] = sub nsw i32 [[SUB2]], 1 + ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 0, [[SUB3]] +@@ -80,13 +80,12 @@ define void @expandOuterRecurrence(i32 %arg) nounwind { + ; CHECK: inner: + ; CHECK-NEXT: [[J:%.*]] = phi i32 [ 0, [[INNER_PH]] ], [ [[J_INC:%.*]], [[INNER]] ] + ; CHECK-NEXT: [[J_INC]] = add nuw nsw i32 [[J]], 1 +-; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[J_INC]], [[INDVARS_IV]] ++; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[J_INC]], [[SUB3]] + ; CHECK-NEXT: br i1 [[EXITCOND]], label [[INNER]], label [[OUTER_INC_LOOPEXIT:%.*]] + ; CHECK: outer.inc.loopexit: + ; CHECK-NEXT: br label [[OUTER_INC]] + ; CHECK: outer.inc: + ; CHECK-NEXT: [[I_INC]] = add nuw nsw i32 [[I]], 1 +-; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add i32 [[INDVARS_IV]], -1 + ; CHECK-NEXT: [[EXITCOND1:%.*]] = icmp ne i32 [[I_INC]], [[SUB1]] + ; CHECK-NEXT: br i1 [[EXITCOND1]], label [[OUTER]], label [[EXIT_LOOPEXIT:%.*]] + ; CHECK: exit.loopexit: +diff --git a/llvm/test/Transforms/IndVarSimplify/udiv.ll b/llvm/test/Transforms/IndVarSimplify/udiv.ll +index b3f2c2a6a66..3530343ef4a 100644 +--- a/llvm/test/Transforms/IndVarSimplify/udiv.ll ++++ b/llvm/test/Transforms/IndVarSimplify/udiv.ll +@@ -133,6 +133,7 @@ declare i32 @printf(i8* nocapture, ...) nounwind + ; CHECK-LABEL: @foo( + ; CHECK: for.body.preheader: + ; CHECK-NOT: udiv ++; CHECK: for.body: + + define void @foo(double* %p, i64 %n) nounwind { + entry: +-- +2.18.0 + diff --git a/cross/llvm-project-140.src/patches/1014-igc-InstCombine-Only-fold-bitcast-fptrunc-if-destination.patch b/cross/llvm-project-140.src/patches/1014-igc-InstCombine-Only-fold-bitcast-fptrunc-if-destination.patch new file mode 100644 index 00000000000..e238f8f3d7e --- /dev/null +++ b/cross/llvm-project-140.src/patches/1014-igc-InstCombine-Only-fold-bitcast-fptrunc-if-destination.patch @@ -0,0 +1,70 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2024 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +From 16e85fd401f5e433142c516b85c3f873eaee0f4f Mon Sep 17 00:00:00 2001 +From: Victor Mustya +Date: Tue, 16 Jan 2024 14:13:05 -0800 +Subject: [InstCombine] Only fold bitcast(fptrunc) if destination type matches + fptrunc result type. (#77046) + +It's not enough to just make sure destination type is floating point, +because the following chain may be incorrectly optimized: +```LLVM + %trunc = fptrunc float %src to bfloat + %cast = bitcast bfloat %trunc to half +``` +Before the fix, the instruction sequence mentioned above used to be +translated into single fptrunc instruction as follows: +```LLVM + %trunc = fptrunc float %src to half +``` + +Such transformation was semantically incorrect. +--- + llvm/lib/IR/Instructions.cpp | 4 ++-- + llvm/test/Transforms/InstCombine/fptrunc.ll | 13 +++++++++++++ + 2 files changed, 15 insertions(+), 2 deletions(-) + +diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp +index 7798af3b19b9..b397013a21da 100644 +--- a/llvm/lib/IR/Instructions.cpp ++++ b/llvm/lib/IR/Instructions.cpp +@@ -3018,8 +3018,8 @@ unsigned CastInst::isEliminableCastPair( + return 0; + case 4: + // No-op cast in second op implies firstOp as long as the DestTy +- // is floating point. +- if (DstTy->isFloatingPointTy()) ++ // matches MidTy. ++ if (DstTy == MidTy) + return firstOp; + return 0; + case 5: +diff --git a/llvm/test/Transforms/InstCombine/fptrunc.ll b/llvm/test/Transforms/InstCombine/fptrunc.ll +index c04c4b5c66c4..197148690808 100644 +--- a/llvm/test/Transforms/InstCombine/fptrunc.ll ++++ b/llvm/test/Transforms/InstCombine/fptrunc.ll +@@ -190,3 +190,16 @@ define half @ItoFtoF_u25_f32_f16(i25 %i) { + %r = fptrunc float %x to half + ret half %r + } ++ ++; Negative test - bitcast bfloat to half is not optimized ++ ++define half @fptrunc_to_bfloat_bitcast_to_half(float %src) { ++; CHECK-LABEL: @fptrunc_to_bfloat_bitcast_to_half( ++; CHECK-NEXT: [[TRUNC:%.*]] = fptrunc float [[SRC:%.*]] to bfloat ++; CHECK-NEXT: [[CAST:%.*]] = bitcast bfloat [[TRUNC]] to half ++; CHECK-NEXT: ret half [[CAST]] ++; ++ %trunc = fptrunc float %src to bfloat ++ %cast = bitcast bfloat %trunc to half ++ ret half %cast ++} +-- +2.34.1 diff --git a/cross/llvm-project-140.src/patches/1015-igc-InstCombine-Only-fold-trunc-ext-pairs-to-bitcast-if-.patch b/cross/llvm-project-140.src/patches/1015-igc-InstCombine-Only-fold-trunc-ext-pairs-to-bitcast-if-.patch new file mode 100644 index 00000000000..e827dc47591 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1015-igc-InstCombine-Only-fold-trunc-ext-pairs-to-bitcast-if-.patch @@ -0,0 +1,70 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2023 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +From 6d6c78dd486c0ed1995bab48ac8cd7ecf1d926b8 Mon Sep 17 00:00:00 2001 +From: Benjamin Kramer +Date: Mon, 13 Jun 2022 14:31:43 +0200 +Subject: [InstCombine] Only fold trunc(ext) pairs to bitcast if the source and + destination types are the same + +This used to be always the case, but the addition of bfloat to the type +matrix makes this invalid. +--- + llvm/lib/IR/Instructions.cpp | 10 ++++++---- + llvm/test/Transforms/InstCombine/fpextend.ll | 11 +++++++++++ + 2 files changed, 17 insertions(+), 4 deletions(-) + +diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp +index 7798af3b19b9..2f68807bb8bc 100644 +--- a/llvm/lib/IR/Instructions.cpp ++++ b/llvm/lib/IR/Instructions.cpp +@@ -3060,16 +3060,18 @@ unsigned CastInst::isEliminableCastPair( + return 0; + } + case 8: { +- // ext, trunc -> bitcast, if the SrcTy and DstTy are same size ++ // ext, trunc -> bitcast, if the SrcTy and DstTy are the same + // ext, trunc -> ext, if sizeof(SrcTy) < sizeof(DstTy) + // ext, trunc -> trunc, if sizeof(SrcTy) > sizeof(DstTy) + unsigned SrcSize = SrcTy->getScalarSizeInBits(); + unsigned DstSize = DstTy->getScalarSizeInBits(); +- if (SrcSize == DstSize) ++ if (SrcTy == DstTy) + return Instruction::BitCast; +- else if (SrcSize < DstSize) ++ if (SrcSize < DstSize) + return firstOp; +- return secondOp; ++ if (SrcSize > DstSize) ++ return secondOp; ++ return 0; + } + case 9: + // zext, sext -> zext, because sext can't sign extend after zext +diff --git a/llvm/test/Transforms/InstCombine/fpextend.ll b/llvm/test/Transforms/InstCombine/fpextend.ll +index 9fe85e983fb7..6b8fe928ff8a 100644 +--- a/llvm/test/Transforms/InstCombine/fpextend.ll ++++ b/llvm/test/Transforms/InstCombine/fpextend.ll +@@ -429,3 +429,14 @@ define double @FtoItoFtoF_f32_su32_f32_f64(float %f) { + %r = fpext float %x to double + ret double %r + } ++ ++define half @bf16_to_f32_to_f16(bfloat %a) nounwind { ++; CHECK-LABEL: @bf16_to_f32_to_f16( ++; CHECK-NEXT: [[Y:%.*]] = fpext bfloat [[A:%.*]] to float ++; CHECK-NEXT: [[Z:%.*]] = fptrunc float [[Y]] to half ++; CHECK-NEXT: ret half [[Z]] ++; ++ %y = fpext bfloat %a to float ++ %z = fptrunc float %y to half ++ ret half %z ++} +-- +2.34.1 + diff --git a/cross/llvm-project-140.src/patches/1016-igc-IterativelyComputeRangesForDeeplyNested.patch b/cross/llvm-project-140.src/patches/1016-igc-IterativelyComputeRangesForDeeplyNested.patch new file mode 100644 index 00000000000..0e2f7aaa9db --- /dev/null +++ b/cross/llvm-project-140.src/patches/1016-igc-IterativelyComputeRangesForDeeplyNested.patch @@ -0,0 +1,361 @@ +From 5dad4c67882a5eac2485f722e8e4109642155058 Mon Sep 17 00:00:00 2001 +From: Florian Hahn +Date: Mon, 21 Nov 2022 21:56:14 +0000 +Subject: [PATCH] [SCEV] Iteratively compute ranges for deeply nested + expressions. + +At the moment, getRangeRef may overflow the stack for very deeply nested +expressions. + +This patch introduces a new getRangeRefIter function, which first builds +a worklist of N-ary expressions and phi nodes, followed by their +operands iteratively. + +getRangeRef has been extended to also take a Depth argument and it +switches to use getRangeRefIter once the depth reaches a certain +threshold. + +This ensures compile-time is not impacted in general. Note that +the iterative algorithm may lead to a slightly different evaluation +order, which could result in slightly worse ranges for cyclic phis. + +https://llvm-compile-time-tracker.com/compare.php?from=23c3eb7cdf3478c9db86f6cb5115821a8f0f5f40&to=e0e09fa338e77e53242bfc846e1484350ad79773&stat=instructions + +Fixes #49579. + +Reviewed By: mkazantsev + +Differential Revision: https://reviews.llvm.org/D130728 +--- + llvm/include/llvm/Analysis/ScalarEvolution.h | 10 +- + llvm/lib/Analysis/ScalarEvolution.cpp | 110 +++++++++++++++--- + llvm/test/Analysis/ScalarEvolution/ranges.ll | 1 + + .../IndVarSimplify/range-iter-threshold.ll | 73 ++++++++++++ + 4 files changed, 174 insertions(+), 20 deletions(-) + create mode 100644 llvm/test/Transforms/IndVarSimplify/range-iter-threshold.ll + +diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h +index 580fef9f7a5d656..49f8ae84f46f5ee 100644 +--- a/llvm/include/llvm/Analysis/ScalarEvolution.h ++++ b/llvm/include/llvm/Analysis/ScalarEvolution.h +@@ -1283,6 +1283,9 @@ class ScalarEvolution { + /// Mark SCEVUnknown Phis currently being processed by getRangeRef. + SmallPtrSet PendingPhiRanges; + ++ /// Mark SCEVUnknown Phis currently being processed by getRangeRefIter. ++ SmallPtrSet PendingPhiRangesIter; ++ + // Mark SCEVUnknown Phis currently being processed by isImpliedViaMerge. + SmallPtrSet PendingMerges; + +@@ -1560,7 +1563,12 @@ class ScalarEvolution { + /// Determine the range for a particular SCEV. + /// NOTE: This returns a reference to an entry in a cache. It must be + /// copied if its needed for longer. +- const ConstantRange &getRangeRef(const SCEV *S, RangeSignHint Hint); ++ const ConstantRange &getRangeRef(const SCEV *S, RangeSignHint Hint, ++ unsigned Depth = 0); ++ ++ /// Determine the range for a particular SCEV, but evaluates ranges for ++ /// operands iteratively first. ++ const ConstantRange &getRangeRefIter(const SCEV *S, RangeSignHint Hint); + + /// Determines the range for the affine SCEVAddRecExpr {\p Start,+,\p Step}. + /// Helper for \c getRange. +diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp +index e2dd015bc57159e..b7766992590f81e 100644 +--- a/llvm/lib/Analysis/ScalarEvolution.cpp ++++ b/llvm/lib/Analysis/ScalarEvolution.cpp +@@ -220,6 +220,11 @@ static cl::opt + cl::desc("Size of the expression which is considered huge"), + cl::init(4096)); + ++static cl::opt RangeIterThreshold( ++ "scev-range-iter-threshold", cl::Hidden, ++ cl::desc("Threshold for switching to iteratively computing SCEV ranges"), ++ cl::init(32)); ++ + static cl::opt + ClassifyExpressions("scalar-evolution-classify-expressions", + cl::Hidden, cl::init(true), +@@ -6425,18 +6430,78 @@ getRangeForUnknownRecurrence(const SCEVUnknown *U) { + return FullSet; + } + ++const ConstantRange & ++ScalarEvolution::getRangeRefIter(const SCEV *S, ++ ScalarEvolution::RangeSignHint SignHint) { ++ DenseMap &Cache = ++ SignHint == ScalarEvolution::HINT_RANGE_UNSIGNED ? UnsignedRanges ++ : SignedRanges; ++ SmallVector WorkList; ++ SmallPtrSet Seen; ++ ++ // Add Expr to the worklist, if Expr is either an N-ary expression or a ++ // SCEVUnknown PHI node. ++ auto AddToWorklist = [&WorkList, &Seen, &Cache](const SCEV *Expr) { ++ if (!Seen.insert(Expr).second) ++ return; ++ if (Cache.find(Expr) != Cache.end()) ++ return; ++ if (isa(Expr) || isa(Expr)) ++ WorkList.push_back(Expr); ++ else if (auto *UnknownS = dyn_cast(Expr)) ++ if (isa(UnknownS->getValue())) ++ WorkList.push_back(Expr); ++ }; ++ AddToWorklist(S); ++ ++ // Build worklist by queuing operands of N-ary expressions and phi nodes. ++ for (unsigned I = 0; I != WorkList.size(); ++I) { ++ const SCEV *P = WorkList[I]; ++ if (auto *NaryS = dyn_cast(P)) { ++ for (const SCEV *Op : NaryS->operands()) ++ AddToWorklist(Op); ++ } else if (auto *UDiv = dyn_cast(P)) { ++ AddToWorklist(UDiv->getLHS()); ++ AddToWorklist(UDiv->getRHS()); ++ } else { ++ auto *UnknownS = cast(P); ++ if (const PHINode *P = dyn_cast(UnknownS->getValue())) { ++ if (!PendingPhiRangesIter.insert(P).second) ++ continue; ++ for (auto &Op : reverse(P->operands())) ++ AddToWorklist(getSCEV(Op)); ++ } ++ } ++ } ++ ++ if (!WorkList.empty()) { ++ // Use getRangeRef to compute ranges for items in the worklist in reverse ++ // order. This will force ranges for earlier operands to be computed before ++ // their users in most cases. ++ for (const SCEV *P : ++ reverse(make_range(WorkList.begin() + 1, WorkList.end()))) { ++ getRangeRef(P, SignHint); ++ ++ if (auto *UnknownS = dyn_cast(P)) ++ if (const PHINode *P = dyn_cast(UnknownS->getValue())) ++ PendingPhiRangesIter.erase(P); ++ } ++ } ++ ++ return getRangeRef(S, SignHint, 0); ++} ++ + /// Determine the range for a particular SCEV. If SignHint is + /// HINT_RANGE_UNSIGNED (resp. HINT_RANGE_SIGNED) then getRange prefers ranges + /// with a "cleaner" unsigned (resp. signed) representation. +-const ConstantRange & +-ScalarEvolution::getRangeRef(const SCEV *S, +- ScalarEvolution::RangeSignHint SignHint) { ++const ConstantRange &ScalarEvolution::getRangeRef( ++ const SCEV *S, ScalarEvolution::RangeSignHint SignHint, unsigned Depth) { + DenseMap &Cache = + SignHint == ScalarEvolution::HINT_RANGE_UNSIGNED ? UnsignedRanges + : SignedRanges; + ConstantRange::PreferredRangeType RangeType = +- SignHint == ScalarEvolution::HINT_RANGE_UNSIGNED +- ? ConstantRange::Unsigned : ConstantRange::Signed; ++ SignHint == ScalarEvolution::HINT_RANGE_UNSIGNED ? ConstantRange::Unsigned ++ : ConstantRange::Signed; + + // See if we've computed this range already. + DenseMap::iterator I = Cache.find(S); +@@ -6446,6 +6511,11 @@ ScalarEvolution::getRangeRef(const SCEV *S, + if (const SCEVConstant *C = dyn_cast(S)) + return setRange(C, SignHint, ConstantRange(C->getAPInt())); + ++ // Switch to iteratively computing the range for S, if it is part of a deeply ++ // nested expression. ++ if (Depth > RangeIterThreshold) ++ return getRangeRefIter(S, SignHint); ++ + unsigned BitWidth = getTypeSizeInBits(S->getType()); + ConstantRange ConservativeResult(BitWidth, /*isFullSet=*/true); + using OBO = OverflowingBinaryOperator; +@@ -6465,23 +6535,23 @@ ScalarEvolution::getRangeRef(const SCEV *S, + } + + if (const SCEVAddExpr *Add = dyn_cast(S)) { +- ConstantRange X = getRangeRef(Add->getOperand(0), SignHint); ++ ConstantRange X = getRangeRef(Add->getOperand(0), SignHint, Depth + 1); + unsigned WrapType = OBO::AnyWrap; + if (Add->hasNoSignedWrap()) + WrapType |= OBO::NoSignedWrap; + if (Add->hasNoUnsignedWrap()) + WrapType |= OBO::NoUnsignedWrap; + for (unsigned i = 1, e = Add->getNumOperands(); i != e; ++i) +- X = X.addWithNoWrap(getRangeRef(Add->getOperand(i), SignHint), ++ X = X.addWithNoWrap(getRangeRef(Add->getOperand(i), SignHint, Depth + 1), + WrapType, RangeType); + return setRange(Add, SignHint, + ConservativeResult.intersectWith(X, RangeType)); + } + + if (const SCEVMulExpr *Mul = dyn_cast(S)) { +- ConstantRange X = getRangeRef(Mul->getOperand(0), SignHint); ++ ConstantRange X = getRangeRef(Mul->getOperand(0), SignHint, Depth + 1); + for (unsigned i = 1, e = Mul->getNumOperands(); i != e; ++i) +- X = X.multiply(getRangeRef(Mul->getOperand(i), SignHint)); ++ X = X.multiply(getRangeRef(Mul->getOperand(i), SignHint, Depth + 1)); + return setRange(Mul, SignHint, + ConservativeResult.intersectWith(X, RangeType)); + } +@@ -6507,41 +6577,42 @@ ScalarEvolution::getRangeRef(const SCEV *S, + } + + const auto *NAry = cast(S); +- ConstantRange X = getRangeRef(NAry->getOperand(0), SignHint); ++ ConstantRange X = getRangeRef(NAry->getOperand(0), SignHint, Depth + 1); + for (unsigned i = 1, e = NAry->getNumOperands(); i != e; ++i) +- X = X.intrinsic(ID, {X, getRangeRef(NAry->getOperand(i), SignHint)}); ++ X = X.intrinsic( ++ ID, {X, getRangeRef(NAry->getOperand(i), SignHint, Depth + 1)}); + return setRange(S, SignHint, + ConservativeResult.intersectWith(X, RangeType)); + } + + if (const SCEVUDivExpr *UDiv = dyn_cast(S)) { +- ConstantRange X = getRangeRef(UDiv->getLHS(), SignHint); +- ConstantRange Y = getRangeRef(UDiv->getRHS(), SignHint); ++ ConstantRange X = getRangeRef(UDiv->getLHS(), SignHint, Depth + 1); ++ ConstantRange Y = getRangeRef(UDiv->getRHS(), SignHint, Depth + 1); + return setRange(UDiv, SignHint, + ConservativeResult.intersectWith(X.udiv(Y), RangeType)); + } + + if (const SCEVZeroExtendExpr *ZExt = dyn_cast(S)) { +- ConstantRange X = getRangeRef(ZExt->getOperand(), SignHint); ++ ConstantRange X = getRangeRef(ZExt->getOperand(), SignHint, Depth + 1); + return setRange(ZExt, SignHint, + ConservativeResult.intersectWith(X.zeroExtend(BitWidth), + RangeType)); + } + + if (const SCEVSignExtendExpr *SExt = dyn_cast(S)) { +- ConstantRange X = getRangeRef(SExt->getOperand(), SignHint); ++ ConstantRange X = getRangeRef(SExt->getOperand(), SignHint, Depth + 1); + return setRange(SExt, SignHint, + ConservativeResult.intersectWith(X.signExtend(BitWidth), + RangeType)); + } + + if (const SCEVPtrToIntExpr *PtrToInt = dyn_cast(S)) { +- ConstantRange X = getRangeRef(PtrToInt->getOperand(), SignHint); ++ ConstantRange X = getRangeRef(PtrToInt->getOperand(), SignHint, Depth + 1); + return setRange(PtrToInt, SignHint, X); + } + + if (const SCEVTruncateExpr *Trunc = dyn_cast(S)) { +- ConstantRange X = getRangeRef(Trunc->getOperand(), SignHint); ++ ConstantRange X = getRangeRef(Trunc->getOperand(), SignHint, Depth + 1); + return setRange(Trunc, SignHint, + ConservativeResult.intersectWith(X.truncate(BitWidth), + RangeType)); +@@ -6671,12 +6742,13 @@ ScalarEvolution::getRangeRef(const SCEV *S, + RangeType); + + // A range of Phi is a subset of union of all ranges of its input. +- if (const PHINode *Phi = dyn_cast(U->getValue())) { ++ if (PHINode *Phi = dyn_cast(U->getValue())) { + // Make sure that we do not run over cycled Phis. + if (PendingPhiRanges.insert(Phi).second) { + ConstantRange RangeFromOps(BitWidth, /*isFullSet=*/false); ++ + for (auto &Op : Phi->operands()) { +- auto OpRange = getRangeRef(getSCEV(Op), SignHint); ++ auto OpRange = getRangeRef(getSCEV(Op), SignHint, Depth + 1); + RangeFromOps = RangeFromOps.unionWith(OpRange); + // No point to continue if we already have a full set. + if (RangeFromOps.isFullSet()) +diff --git a/llvm/test/Analysis/ScalarEvolution/ranges.ll b/llvm/test/Analysis/ScalarEvolution/ranges.ll +index f5583d091f148d2..1a72f10cdd3df7a 100644 +--- a/llvm/test/Analysis/ScalarEvolution/ranges.ll ++++ b/llvm/test/Analysis/ScalarEvolution/ranges.ll +@@ -1,5 +1,6 @@ + ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py + ; RUN: opt < %s -disable-output "-passes=print" 2>&1 | FileCheck %s ++ ; RUN: opt < %s -disable-output "-passes=print" -scev-range-iter-threshold=1 2>&1 | FileCheck %s + + target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" + +diff --git a/llvm/test/Transforms/IndVarSimplify/range-iter-threshold.ll b/llvm/test/Transforms/IndVarSimplify/range-iter-threshold.ll +new file mode 100644 +index 000000000000000..9b27d01f8eee0f9 +--- /dev/null ++++ b/llvm/test/Transforms/IndVarSimplify/range-iter-threshold.ll +@@ -0,0 +1,73 @@ ++; RUN: opt -passes=indvars -S %s | FileCheck --check-prefix=COMMON --check-prefix=DEFAULT %s ++; RUN: opt -passes=indvars -scev-range-iter-threshold=1 -S %s | FileCheck --check-prefix=COMMON --check-prefix=LIMIT %s ++ ++target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" ++ ++define i32 @test(i1 %c.0, i32 %m) { ++; COMMON-LABEL: @test( ++; COMMON-NEXT: entry: ++; COMMON-NEXT: br label [[OUTER_HEADER:%.*]] ++; COMMON: outer.header: ++; DEFAULT-NEXT: [[INDVARS_IV:%.*]] = phi i32 [ [[INDVARS_IV_NEXT:%.*]], [[OUTER_LATCH:%.*]] ], [ 2, [[ENTRY:%.*]] ] ++; COMMON-NEXT: [[IV_1:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_1_NEXT:%.*]], [[OUTER_LATCH:%.*]] ] ++; COMMON-NEXT: [[MAX_0:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[MAX_1:%.*]], [[OUTER_LATCH]] ] ++; COMMON-NEXT: [[TMP0:%.*]] = sext i32 [[IV_1]] to i64 ++; COMMON-NEXT: br label [[INNER_1:%.*]] ++; COMMON: inner.1: ++; COMMON-NEXT: [[C_1:%.*]] = icmp slt i64 0, [[TMP0]] ++; COMMON-NEXT: br i1 [[C_1]], label [[INNER_1]], label [[INNER_2_HEADER_PREHEADER:%.*]] ++; COMMON: inner.2.header.preheader: ++; COMMON-NEXT: br label [[INNER_2_HEADER:%.*]] ++; COMMON: inner.2.header: ++; COMMON-NEXT: [[IV_3:%.*]] = phi i32 [ [[IV_3_NEXT:%.*]], [[INNER_2_LATCH:%.*]] ], [ 0, [[INNER_2_HEADER_PREHEADER]] ] ++; COMMON-NEXT: br i1 [[C_0:%.*]], label [[OUTER_LATCH]], label [[INNER_2_LATCH]] ++; COMMON: inner.2.latch: ++; COMMON-NEXT: [[IV_3_NEXT]] = add i32 [[IV_3]], 1 ++; DEFAULT-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[IV_3_NEXT]], [[INDVARS_IV]] ++; LIMIT-NEXT: [[EXITCOND:%.*]] = icmp ugt i32 [[IV_3]], [[IV_1]] ++; COMMON-NEXT: br i1 [[EXITCOND]], label [[OUTER_LATCH]], label [[INNER_2_HEADER]] ++; COMMON: outer.latch: ++; COMMON-NEXT: [[MAX_1]] = phi i32 [ [[M:%.*]], [[INNER_2_LATCH]] ], [ 0, [[INNER_2_HEADER]] ] ++; COMMON-NEXT: [[IV_1_NEXT]] = add nuw i32 [[IV_1]], 1 ++; COMMON-NEXT: [[C_3:%.*]] = icmp ugt i32 [[IV_1]], [[MAX_0]] ++; DEFAULT-NEXT: [[INDVARS_IV_NEXT]] = add i32 [[INDVARS_IV]], 1 ++; COMMON-NEXT: br i1 [[C_3]], label [[EXIT:%.*]], label [[OUTER_HEADER]], !llvm.loop [[LOOP0:![0-9]+]] ++; COMMON: exit: ++; COMMON-NEXT: ret i32 0 ++; ++entry: ++ br label %outer.header ++ ++outer.header: ++ %iv.1 = phi i32 [ 0, %entry ], [ %iv.1.next, %outer.latch ] ++ %iv.2 = phi i32 [ 0, %entry ], [ %iv.2.next , %outer.latch ] ++ %max.0 = phi i32 [ 0, %entry ], [ %max.1, %outer.latch ] ++ %0 = sext i32 %iv.1 to i64 ++ br label %inner.1 ++ ++inner.1: ++ %c.1 = icmp slt i64 0, %0 ++ br i1 %c.1, label %inner.1, label %inner.2.header ++ ++inner.2.header: ++ %iv.3 = phi i32 [ 0, %inner.1 ], [ %iv.3.next, %inner.2.latch ] ++ br i1 %c.0, label %outer.latch, label %inner.2.latch ++ ++inner.2.latch: ++ %iv.3.next = add i32 %iv.3, 1 ++ %c.2 = icmp ugt i32 %iv.3, %iv.2 ++ br i1 %c.2, label %outer.latch, label %inner.2.header ++ ++outer.latch: ++ %max.1 = phi i32 [ %m, %inner.2.latch ], [ %iv.3, %inner.2.header ] ++ %iv.1.next = add i32 %iv.1, 1 ++ %iv.2.next = add i32 %iv.2, 1 ++ %c.3 = icmp ugt i32 %iv.2, %max.0 ++ br i1 %c.3, label %exit, label %outer.header, !llvm.loop !0 ++ ++exit: ++ ret i32 0 ++} ++ ++!0 = distinct !{!0, !1} ++!1 = !{!"llvm.loop.mustprogress"} diff --git a/cross/llvm-project-140.src/patches/1017-igc-LowerSwitch-RemoveUnreachableBBs.patch b/cross/llvm-project-140.src/patches/1017-igc-LowerSwitch-RemoveUnreachableBBs.patch new file mode 100644 index 00000000000..4c1154bf120 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1017-igc-LowerSwitch-RemoveUnreachableBBs.patch @@ -0,0 +1,42 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2024 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ +/*========================== begin_copyright_notice ============================ + +Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +See https://llvm.org/LICENSE.txt for license information. +SPDX-License-Identifier: Apache-2.0 with LLVM-exception + +============================= end_copyright_notice ===========================*/ +The reason for removing unreachable blocks is this change in the LLVM repo: +https://github.com/llvm/llvm-project/commit/1065f3439bad59323f16e7c8ee568c7d94dcd952 +LowerSwitchPass can leave phi instructions with nodes from unreachable basic blocks +which is a disallowed state for DomTree. + +diff --git a/llvm/lib/Transforms/Utils/LowerSwitch.cpp b/llvm/lib/Transforms/Utils/LowerSwitch.cpp +index aff9d1311..b38de0a7a 100644 +--- a/llvm/lib/Transforms/Utils/LowerSwitch.cpp ++++ b/llvm/lib/Transforms/Utils/LowerSwitch.cpp +@@ -38,6 +38,7 @@ + #include "llvm/Support/raw_ostream.h" + #include "llvm/Transforms/Utils.h" + #include "llvm/Transforms/Utils/BasicBlockUtils.h" ++#include "llvm/Transforms/Utils/Local.h" + #include + #include + #include +@@ -542,6 +543,10 @@ bool LowerSwitch(Function &F, LazyValueInfo *LVI, AssumptionCache *AC) { + DeleteDeadBlock(BB); + } + ++ if (!DeleteList.empty()) { ++ removeUnreachableBlocks(F); ++ } ++ + return Changed; + } + diff --git a/cross/llvm-project-140.src/patches/1018-igc-no-extra-BBs-in-JumpThreading-pass.patch b/cross/llvm-project-140.src/patches/1018-igc-no-extra-BBs-in-JumpThreading-pass.patch new file mode 100644 index 00000000000..184faf2eef1 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1018-igc-no-extra-BBs-in-JumpThreading-pass.patch @@ -0,0 +1,46 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2024 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +/*========================== begin_copyright_notice ============================ + +Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +See https://llvm.org/LICENSE.txt for license information. +SPDX-License-Identifier: Apache-2.0 with LLVM-exception + +============================= end_copyright_notice ===========================*/ + +# Description: +# The thread through two basic blocks functionality leads to extra basic block construction +# that is suboptimal from the performance point of view. +# Adding `jump-threading-through-two-bbs` option to control it. +diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp +index a3efad104..b31bbbe67 100644 +--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp ++++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp +@@ -116,6 +116,10 @@ static cl::opt ThreadAcrossLoopHeaders( + cl::desc("Allow JumpThreading to thread across loop headers, for testing"), + cl::init(false), cl::Hidden); + ++static cl::opt ThreadThroughTwoBBs( ++ "jump-threading-through-two-bbs", ++ cl::desc("Allow JumpThreading to thread through two basic blocks"), ++ cl::init(false), cl::Hidden); + + namespace { + +@@ -2131,6 +2135,10 @@ bool JumpThreadingPass::maybethreadThroughTwoBasicBlocks(BasicBlock *BB, + // edges (say, PredBB1 and PredBB2), we know the value of %var in each copy of + // PredBB. Then we can thread edges PredBB1->BB and PredBB2->BB through BB. + ++ // Check that threading through two BBs is allowed ++ if (!ThreadThroughTwoBBs) ++ return false; ++ + // Require that BB end with a Branch for simplicity. + BranchInst *CondBr = dyn_cast(BB->getTerminator()); + if (!CondBr) diff --git a/cross/llvm-project-140.src/patches/1019-igc-no-instcombine-code-sinking.patch b/cross/llvm-project-140.src/patches/1019-igc-no-instcombine-code-sinking.patch new file mode 100644 index 00000000000..1fa30ec66d9 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1019-igc-no-instcombine-code-sinking.patch @@ -0,0 +1,22 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2020-2023 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +# Description : disabling instcombine-code-sinking by default +diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +index 3091905ca..1f24e7886 100644 +--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp ++++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +@@ -138,7 +138,7 @@ static constexpr unsigned InstCombineDefaultInfiniteLoopThreshold = 1000; + + static cl::opt + EnableCodeSinking("instcombine-code-sinking", cl::desc("Enable code sinking"), +- cl::init(true)); ++ cl::init(false)); + + static cl::opt LimitMaxIterations( + "instcombine-max-iterations", diff --git a/cross/llvm-project-140.src/patches/1020-igc-Remove-too-strict-restrictions-in-LICM-pass.patch b/cross/llvm-project-140.src/patches/1020-igc-Remove-too-strict-restrictions-in-LICM-pass.patch new file mode 100644 index 00000000000..7a9c84488a1 --- /dev/null +++ b/cross/llvm-project-140.src/patches/1020-igc-Remove-too-strict-restrictions-in-LICM-pass.patch @@ -0,0 +1,53 @@ +/*========================== begin_copyright_notice ============================ + +Copyright (C) 2023 Intel Corporation + +SPDX-License-Identifier: MIT + +============================= end_copyright_notice ===========================*/ + +From 8b66a82ac8c802cc67b4c73667acb6a1d769ae5f Mon Sep 17 00:00:00 2001 +From: Marcin Naczk +Date: Wed, 22 Feb 2023 15:33:37 +0100 +Subject: [PATCH] Remove too strict restrictions in LICM pass. + +The reason for removal of below condition was that it took a very strict +approach to the Convergent attribute, which caused missed optimization +opportunities in cases where it was safe to do so. +The decision is based on the discussion in LLVM RFC +https://reviews.llvm.org/D90361?id=303195 +This patch should be considered obsolete if LICM introduces a more +advanced approach to the Convergent attribute in the future version of +LLVM. +--- + llvm/lib/Transforms/Scalar/LICM.cpp | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp +index 6372ce19f..39d11d7b2 100644 +--- a/llvm/lib/Transforms/Scalar/LICM.cpp ++++ b/llvm/lib/Transforms/Scalar/LICM.cpp +@@ -1196,8 +1196,18 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT, + // inter-thread communication which results are implicitly affected by the + // enclosing control flows. It is not safe to hoist or sink such operations + // across control flow. +- if (CI->isConvergent()) +- return false; ++ ++ // The reason for removal of below condition was that it took a very strict ++ // approach to the Convergent attribute, which caused missed optimization ++ // opportunities in cases where it was safe to do so. ++ // The decision is based on the discussion in LLVM RFC ++ // https://reviews.llvm.org/D90361?id=303195 ++ // This patch should be considered obsolete if LICM introduces a more ++ // advanced approach to the Convergent attribute in the future version of ++ // LLVM. ++ ++ //if (CI->isConvergent()) ++ // return false; + + using namespace PatternMatch; + if (match(CI, m_Intrinsic())) +-- +2.33.0.windows.1 + diff --git a/cross/llvm-project-140.src/patches/2000-ocl-HOWTO.txt b/cross/llvm-project-140.src/patches/2000-ocl-HOWTO.txt new file mode 100644 index 00000000000..05443449c49 --- /dev/null +++ b/cross/llvm-project-140.src/patches/2000-ocl-HOWTO.txt @@ -0,0 +1,17 @@ +Following patches where copied over directly from the IGC source corresponding to current LLVM: +opencl-clang-ocl-open-140/patches/clang + +Latest versions of the patches available by cloning the git repository +$ git clone https://github.com/intel/opencl-clang.git + +Checkout the ocl-open-140 branch +$ cd opencl-clang +$ git checkout ocl-open-140 +Branch 'ocl-open-140' set up to track remote branch 'ocl-open-140' from 'origin'. +Switched to a new branch 'ocl-open-140' + +Change to the patch directory +$ cd patches/clang + +Renumber the patches: +$ i=2001 && ls -1 *.patch | while read LINE; do echo $(printf "%04d" $i)-igc-$LINE; mv $LINE $(printf "%04d" $i)-ocl-$LINE; let i++; done diff --git a/cross/llvm-project-140.src/patches/2001-ocl-0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch b/cross/llvm-project-140.src/patches/2001-ocl-0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch new file mode 100644 index 00000000000..e1c850a1c41 --- /dev/null +++ b/cross/llvm-project-140.src/patches/2001-ocl-0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch @@ -0,0 +1,61 @@ +From 1ca45b5f5725a447ded14c0096df39f2751c4e9a Mon Sep 17 00:00:00 2001 +From: Haonan Yang +Date: Fri, 25 Feb 2022 10:36:57 +0800 +Subject: [PATCH] Remove __IMAGE_SUPPORT__ macro for SPIR + +Signed-off-by: Haonan Yang +--- + clang/lib/Frontend/InitPreprocessor.cpp | 3 --- + clang/test/Preprocessor/predefined-macros.c | 4 ---- + 2 files changed, 7 deletions(-) + +diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp +index e259ab47c558..0bfdd62f17a2 100644 +--- a/clang/lib/Frontend/InitPreprocessor.cpp ++++ b/clang/lib/Frontend/InitPreprocessor.cpp +@@ -1234,9 +1234,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI, + // OpenCL definitions. + if (LangOpts.OpenCL) { + InitializeOpenCLFeatureTestMacros(TI, LangOpts, Builder); +- +- if (TI.getTriple().isSPIR() || TI.getTriple().isSPIRV()) +- Builder.defineMacro("__IMAGE_SUPPORT__"); + } + + if (TI.hasInt128Type() && LangOpts.CPlusPlus && LangOpts.GNUMode) { +diff --git a/clang/test/Preprocessor/predefined-macros.c b/clang/test/Preprocessor/predefined-macros.c +index 0b67cbe233ca..aad4a6f05563 100644 +--- a/clang/test/Preprocessor/predefined-macros.c ++++ b/clang/test/Preprocessor/predefined-macros.c +@@ -207,28 +207,24 @@ + + // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir-unknown-unknown \ + // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR +-// CHECK-SPIR-DAG: #define __IMAGE_SUPPORT__ 1 + // CHECK-SPIR-DAG: #define __SPIR__ 1 + // CHECK-SPIR-DAG: #define __SPIR32__ 1 + // CHECK-SPIR-NOT: #define __SPIR64__ 1 + + // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir64-unknown-unknown \ + // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR64 +-// CHECK-SPIR64-DAG: #define __IMAGE_SUPPORT__ 1 + // CHECK-SPIR64-DAG: #define __SPIR__ 1 + // CHECK-SPIR64-DAG: #define __SPIR64__ 1 + // CHECK-SPIR64-NOT: #define __SPIR32__ 1 + + // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spirv32-unknown-unknown \ + // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIRV32 +-// CHECK-SPIRV32-DAG: #define __IMAGE_SUPPORT__ 1 + // CHECK-SPIRV32-DAG: #define __SPIRV__ 1 + // CHECK-SPIRV32-DAG: #define __SPIRV32__ 1 + // CHECK-SPIRV32-NOT: #define __SPIRV64__ 1 + + // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spirv64-unknown-unknown \ + // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIRV64 +-// CHECK-SPIRV64-DAG: #define __IMAGE_SUPPORT__ 1 + // CHECK-SPIRV64-DAG: #define __SPIRV__ 1 + // CHECK-SPIRV64-DAG: #define __SPIRV64__ 1 + // CHECK-SPIRV64-NOT: #define __SPIRV32__ 1 +-- +2.29.2 + diff --git a/cross/llvm-project-140.src/patches/2002-ocl-0002-Remove-wrong-check-of-__opencl_c_images-feature-macr.patch b/cross/llvm-project-140.src/patches/2002-ocl-0002-Remove-wrong-check-of-__opencl_c_images-feature-macr.patch new file mode 100644 index 00000000000..eb34a4be097 --- /dev/null +++ b/cross/llvm-project-140.src/patches/2002-ocl-0002-Remove-wrong-check-of-__opencl_c_images-feature-macr.patch @@ -0,0 +1,37 @@ +From 9780cc0e044c73dcd549c67a1278a4ff7daf3b01 Mon Sep 17 00:00:00 2001 +From: Marcin Naczk +Date: Fri, 4 Nov 2022 15:41:16 +0100 +Subject: [PATCH] Remove wrong check of __opencl_c_images feature macro + +Deleted mechanism that wrongly assumes that +all functions that use image types must be under +__opencl_c_images feature macro +Mechanism added by https://reviews.llvm.org/D103911 +More info on github issue: +https://github.com/llvm/llvm-project/issues/58017 +--- + clang/lib/Sema/SemaType.cpp | 8 +------- + 1 file changed, 1 insertion(+), 7 deletions(-) + +diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp +index ab47e9f03eaf..f72c2fb57ddd 100644 +--- a/clang/lib/Sema/SemaType.cpp ++++ b/clang/lib/Sema/SemaType.cpp +@@ -1741,13 +1741,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { + // __opencl_c_3d_image_writes feature. OpenCL C v3.0 API s4.2 - For devices + // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when and + // only when the optional feature is supported +- if ((Result->isImageType() || Result->isSamplerT()) && +- (IsOpenCLC30Compatible && +- !OpenCLOptions.isSupported("__opencl_c_images", S.getLangOpts()))) { +- S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension) +- << 0 << Result << "__opencl_c_images"; +- declarator.setInvalidType(); +- } else if (Result->isOCLImage3dWOType() && ++ if (Result->isOCLImage3dWOType() && + !OpenCLOptions.isSupported("cl_khr_3d_image_writes", + S.getLangOpts())) { + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension) +-- +2.33.0.windows.1 + diff --git a/cross/llvm-project-140.src/patches/2003-ocl-0003-Fix-checking-mechanism-for-read_write-Image-type.patch b/cross/llvm-project-140.src/patches/2003-ocl-0003-Fix-checking-mechanism-for-read_write-Image-type.patch new file mode 100644 index 00000000000..4c934087a76 --- /dev/null +++ b/cross/llvm-project-140.src/patches/2003-ocl-0003-Fix-checking-mechanism-for-read_write-Image-type.patch @@ -0,0 +1,34 @@ +From bb5e22800857f7dda9a2491a4f2fc7387d4205b0 Mon Sep 17 00:00:00 2001 +From: Marcin Naczk +Date: Fri, 4 Nov 2022 15:45:17 +0100 +Subject: [PATCH] Fix checking mechanism for read_write Image type + +The commit +https://github.com/llvm/llvm-project/commit/91a0b464a853821734db8b1c521df03f8e2e56e7 +Enabled opencl feature macro __opencl_c_read_write_images +by default for the SPIR and SPIR-V targets +therefore the mechanism of checking read_write image type +should take into account if the target is SPIR or SPIR-V +--- + clang/lib/Sema/SemaDeclAttr.cpp | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp +index e76e7c608e0c..2d60d2b03169 100644 +--- a/clang/lib/Sema/SemaDeclAttr.cpp ++++ b/clang/lib/Sema/SemaDeclAttr.cpp +@@ -7823,8 +7823,9 @@ static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL) { + bool ReadWriteImagesUnsupported = + (S.getLangOpts().getOpenCLCompatibleVersion() < 200) || + (S.getLangOpts().getOpenCLCompatibleVersion() == 300 && +- !S.getOpenCLOptions().isSupported("__opencl_c_read_write_images", +- S.getLangOpts())); ++ !S.getOpenCLOptions().isSupported("__opencl_c_read_write_images", S.getLangOpts()) && ++ !S.getASTContext().getTargetInfo().getTriple().isSPIR() && ++ !S.getASTContext().getTargetInfo().getTriple().isSPIRV()); + if (ReadWriteImagesUnsupported || DeclTy->isPipeType()) { + S.Diag(AL.getLoc(), diag::err_opencl_invalid_read_write) + << AL << PDecl->getType() << DeclTy->isImageType(); +-- +2.33.0.windows.1 + diff --git a/cross/llvm-project-140.src/patches/2004-ocl-0004-OpenCL-Allow-undefining-header-only-macros.patch b/cross/llvm-project-140.src/patches/2004-ocl-0004-OpenCL-Allow-undefining-header-only-macros.patch new file mode 100644 index 00000000000..77fec15655f --- /dev/null +++ b/cross/llvm-project-140.src/patches/2004-ocl-0004-OpenCL-Allow-undefining-header-only-macros.patch @@ -0,0 +1,104 @@ +From a60b8f468119065f8a6cb4a16598263cb00de0b5 Mon Sep 17 00:00:00 2001 +From: Sven van Haastregt +Date: Mon, 16 Jan 2023 11:32:12 +0000 +Subject: [PATCH] [OpenCL] Allow undefining header-only features + +`opencl-c-base.h` always defines 5 particular feature macros for +SPIR-V, making it impossible to disable those features. + +To allow disabling any of those features, let the header recognize +`__undef_` macros. The user can then pass the +`-D__undef_` flag on the command line to disable a specific +feature. The __undef macro could potentially also be set from +`-cl-ext=-feature`, but for now only change the header and only +provide __undef macros for the 5 features that are always enabled in +`opencl-c-base.h`. + +Differential Revision: https://reviews.llvm.org/D141297 +--- + clang/lib/Headers/opencl-c-base.h | 19 ++++++++++++++++ + clang/test/SemaOpenCL/features.cl | 37 ++++++++++++++++++++++--------- + 2 files changed, 45 insertions(+), 11 deletions(-) + +diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h +index c433b4f7eb1af..fad2f9c0272bf 100644 +--- a/clang/lib/Headers/opencl-c-base.h ++++ b/clang/lib/Headers/opencl-c-base.h +@@ -74,6 +74,25 @@ + #define __opencl_c_atomic_scope_all_devices 1 + #define __opencl_c_read_write_images 1 + #endif // defined(__SPIR__) ++ ++// Undefine any feature macros that have been explicitly disabled using ++// an __undef_ macro. ++#ifdef __undef___opencl_c_work_group_collective_functions ++#undef __opencl_c_work_group_collective_functions ++#endif ++#ifdef __undef___opencl_c_atomic_order_seq_cst ++#undef __opencl_c_atomic_order_seq_cst ++#endif ++#ifdef __undef___opencl_c_atomic_scope_device ++#undef __opencl_c_atomic_scope_device ++#endif ++#ifdef __undef___opencl_c_atomic_scope_all_devices ++#undef __opencl_c_atomic_scope_all_devices ++#endif ++#ifdef __undef___opencl_c_read_write_images ++#undef __opencl_c_read_write_images ++#endif ++ + #endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) + + #if !defined(__opencl_c_generic_address_space) +diff --git a/clang/test/SemaOpenCL/features.cl b/clang/test/SemaOpenCL/features.cl +index af058b5e69828..3f59b4ea3b5ae 100644 +--- a/clang/test/SemaOpenCL/features.cl ++++ b/clang/test/SemaOpenCL/features.cl +@@ -26,6 +26,15 @@ + // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++1.0 \ + // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES + ++// For OpenCL C 3.0, header-only features can be disabled using macros. ++// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -fdeclare-opencl-builtins -finclude-default-header \ ++// RUN: -D__undef___opencl_c_work_group_collective_functions=1 \ ++// RUN: -D__undef___opencl_c_atomic_order_seq_cst=1 \ ++// RUN: -D__undef___opencl_c_atomic_scope_device=1 \ ++// RUN: -D__undef___opencl_c_atomic_scope_all_devices=1 \ ++// RUN: -D__undef___opencl_c_read_write_images=1 \ ++// RUN: | FileCheck %s --check-prefix=NO-HEADERONLY-FEATURES ++ + // Note that __opencl_c_int64 is always defined assuming + // always compiling for FULL OpenCL profile + +@@ -43,14 +52,20 @@ + // FEATURES: #define __opencl_c_subgroups 1 + + // NO-FEATURES: #define __opencl_c_int64 1 +-// NO-FEATURES-NOT: __opencl_c_3d_image_writes +-// NO-FEATURES-NOT: __opencl_c_atomic_order_acq_rel +-// NO-FEATURES-NOT: __opencl_c_atomic_order_seq_cst +-// NO-FEATURES-NOT: __opencl_c_device_enqueue +-// NO-FEATURES-NOT: __opencl_c_fp64 +-// NO-FEATURES-NOT: __opencl_c_generic_address_space +-// NO-FEATURES-NOT: __opencl_c_images +-// NO-FEATURES-NOT: __opencl_c_pipes +-// NO-FEATURES-NOT: __opencl_c_program_scope_global_variables +-// NO-FEATURES-NOT: __opencl_c_read_write_images +-// NO-FEATURES-NOT: __opencl_c_subgroups ++// NO-FEATURES-NOT: #define __opencl_c_3d_image_writes ++// NO-FEATURES-NOT: #define __opencl_c_atomic_order_acq_rel ++// NO-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst ++// NO-FEATURES-NOT: #define __opencl_c_device_enqueue ++// NO-FEATURES-NOT: #define __opencl_c_fp64 ++// NO-FEATURES-NOT: #define __opencl_c_generic_address_space ++// NO-FEATURES-NOT: #define __opencl_c_images ++// NO-FEATURES-NOT: #define __opencl_c_pipes ++// NO-FEATURES-NOT: #define __opencl_c_program_scope_global_variables ++// NO-FEATURES-NOT: #define __opencl_c_read_write_images ++// NO-FEATURES-NOT: #define __opencl_c_subgroups ++ ++// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_work_group_collective_functions ++// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst ++// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_scope_device ++// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_scope_all_devices ++// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_read_write_images diff --git a/cross/llvm-project-140.src/patches/2005-ocl-0005-Enable-use-of-GNU-C-extension.patch b/cross/llvm-project-140.src/patches/2005-ocl-0005-Enable-use-of-GNU-C-extension.patch new file mode 100644 index 00000000000..f4f7030bab8 --- /dev/null +++ b/cross/llvm-project-140.src/patches/2005-ocl-0005-Enable-use-of-GNU-C-extension.patch @@ -0,0 +1,37 @@ +From 62267fec4a0d74472bc64695597f2477cc8c11df Mon Sep 17 00:00:00 2001 +From: FirstName LastName +Date: Wed, 5 Apr 2023 17:02:38 +0200 +Subject: [PATCH] Enable use of GNU C extension - const statement expression as array size + +This patch partially reverts the commit: +llvm/llvm-project@6781fee + +For backward compatibility, we still need to support the +expressions like: +``` +const int size = ({ false; }) ? 0 : 1; +float array[size]; +``` +https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html + +--- + clang/lib/Sema/SemaType.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp +index ab47e9f03..8cb26be44 100644 +--- a/clang/lib/Sema/SemaType.cpp ++++ b/clang/lib/Sema/SemaType.cpp +@@ -2330,7 +2330,8 @@ static ExprResult checkArraySize(Sema &S, Expr *&ArraySize, + } Diagnoser(VLADiag, VLAIsError); + + ExprResult R = +- S.VerifyIntegerConstantExpression(ArraySize, &SizeVal, Diagnoser); ++ S.VerifyIntegerConstantExpression(ArraySize, &SizeVal, Diagnoser, ++ S.LangOpts.OpenCL ? Sema::AllowFold : Sema::NoFold); + if (Diagnoser.IsVLA) + return ExprResult(); + return R; +-- +2.34.1 + diff --git a/cross/llvm-project-140.src/patches/2006-ocl-0006-Make-globals-used-for-array-initialization-codegen-c.patch b/cross/llvm-project-140.src/patches/2006-ocl-0006-Make-globals-used-for-array-initialization-codegen-c.patch new file mode 100644 index 00000000000..8dd4ea9284e --- /dev/null +++ b/cross/llvm-project-140.src/patches/2006-ocl-0006-Make-globals-used-for-array-initialization-codegen-c.patch @@ -0,0 +1,268 @@ +From e9e2434697c3a28f151ce179dd88f0ba73f0f0a0 Mon Sep 17 00:00:00 2001 +From: Haonan Yang +Date: Tue, 30 May 2023 09:37:00 +0800 +Subject: [PATCH] Make globals used for array initialization codegen constant + +This combines https://reviews.llvm.org/D146211 and https://reviews.llvm.org/D145369 +1. Emit const globals with constexpr destructor as constant LLVM values +This follows 2b4fa53 which made Clang not emit destructor calls for such +objects. However, they would still not get emitted as constants since +CodeGenModule::isTypeConstant() returns false if the destructor is +constexpr. This change adds a param to make isTypeConstant() ignore the +dtor, allowing the caller to check it instead. +2. Make globals used for array initialization codegen constant +As pointed out in D133835 these globals will never be written to +(they're only used for trivially copyable types), so they can always be +constant. +--- + clang/lib/CodeGen/CGDecl.cpp | 12 ++++++++---- + clang/lib/CodeGen/CGDeclCXX.cpp | 4 +++- + clang/lib/CodeGen/CGExpr.cpp | 2 +- + clang/lib/CodeGen/CGExprAgg.cpp | 4 ++-- + clang/lib/CodeGen/CGExprConstant.cpp | 12 ++++++------ + clang/lib/CodeGen/CodeGenModule.cpp | 16 +++++++++------- + clang/lib/CodeGen/CodeGenModule.h | 2 +- + clang/lib/CodeGen/TargetInfo.cpp | 2 +- + clang/test/CodeGen/init.c | 2 +- + clang/test/CodeGen/label-array-aggregate-init.c | 2 +- + clang/test/CodeGenCXX/const-init-cxx2a.cpp | 4 ++-- + 11 files changed, 35 insertions(+), 27 deletions(-) + +diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp +index 18d658436086..372f392402cf 100644 +--- a/clang/lib/CodeGen/CGDecl.cpp ++++ b/clang/lib/CodeGen/CGDecl.cpp +@@ -379,13 +379,15 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D, + OldGV->eraseFromParent(); + } + +- GV->setConstant(CGM.isTypeConstant(D.getType(), true)); ++ bool NeedsDtor = ++ D.needsDestruction(getContext()) == QualType::DK_cxx_destructor; ++ ++ GV->setConstant(CGM.isTypeConstant(D.getType(), true, !NeedsDtor)); + GV->setInitializer(Init); + + emitter.finalize(GV); + +- if (D.needsDestruction(getContext()) == QualType::DK_cxx_destructor && +- HaveInsertPoint()) { ++ if (NeedsDtor && HaveInsertPoint()) { + // We have a constant initializer, but a nontrivial destructor. We still + // need to perform a guarded "initialization" in order to register the + // destructor. +@@ -1470,10 +1472,12 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) { + // emit it as a global instead. + // Exception is if a variable is located in non-constant address space + // in OpenCL. ++ bool NeedsDtor = ++ D.needsDestruction(getContext()) == QualType::DK_cxx_destructor; + if ((!getLangOpts().OpenCL || + Ty.getAddressSpace() == LangAS::opencl_constant) && + (CGM.getCodeGenOpts().MergeAllConstants && !NRVO && +- !isEscapingByRef && CGM.isTypeConstant(Ty, true))) { ++ !isEscapingByRef && CGM.isTypeConstant(Ty, true, !NeedsDtor))) { + EmitStaticVarDecl(D, llvm::GlobalValue::InternalLinkage); + + // Signal this condition to later callbacks. +diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp +index 7b880c1354e1..3dfffdbed8eb 100644 +--- a/clang/lib/CodeGen/CGDeclCXX.cpp ++++ b/clang/lib/CodeGen/CGDeclCXX.cpp +@@ -213,9 +213,11 @@ void CodeGenFunction::EmitCXXGlobalVarDeclInit(const VarDecl &D, + &D, DeclAddr, D.getAttr()->getLocation(), + PerformInit, this); + } ++ bool NeedsDtor = ++ D.needsDestruction(getContext()) == QualType::DK_cxx_destructor; + if (PerformInit) + EmitDeclInit(*this, D, DeclAddr); +- if (CGM.isTypeConstant(D.getType(), true)) ++ if (CGM.isTypeConstant(D.getType(), true, !NeedsDtor)) + EmitDeclInvariant(*this, D, DeclPtr); + else + EmitDeclDestroy(*this, D, DeclAddr); +diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp +index 2a9b108c31bc..86ed8b1892ea 100644 +--- a/clang/lib/CodeGen/CGExpr.cpp ++++ b/clang/lib/CodeGen/CGExpr.cpp +@@ -390,7 +390,7 @@ static Address createReferenceTemporary(CodeGenFunction &CGF, + QualType Ty = Inner->getType(); + if (CGF.CGM.getCodeGenOpts().MergeAllConstants && + (Ty->isArrayType() || Ty->isRecordType()) && +- CGF.CGM.isTypeConstant(Ty, true)) ++ CGF.CGM.isTypeConstant(Ty, true, false)) + if (auto Init = ConstantEmitter(CGF).tryEmitAbstract(Inner, Ty)) { + auto AS = CGF.CGM.GetGlobalConstantAddressSpace(); + auto *GV = new llvm::GlobalVariable( +diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp +index 73b05690537d..4f5b5b4cdef3 100644 +--- a/clang/lib/CodeGen/CGExprAgg.cpp ++++ b/clang/lib/CodeGen/CGExprAgg.cpp +@@ -506,8 +506,8 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType, + if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) { + auto GV = new llvm::GlobalVariable( + CGM.getModule(), C->getType(), +- CGM.isTypeConstant(ArrayQTy, /* ExcludeCtorDtor= */ true), +- llvm::GlobalValue::PrivateLinkage, C, "constinit", ++ /* isConstant= */ true, llvm::GlobalValue::PrivateLinkage, C, ++ "constinit", + /* InsertBefore= */ nullptr, llvm::GlobalVariable::NotThreadLocal, + CGM.getContext().getTargetAddressSpace(AS)); + Emitter.finalize(GV); +diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp +index ac4b4d1308ab..64129b64e272 100644 +--- a/clang/lib/CodeGen/CGExprConstant.cpp ++++ b/clang/lib/CodeGen/CGExprConstant.cpp +@@ -913,12 +913,12 @@ static ConstantAddress tryEmitGlobalCompoundLiteral(CodeGenModule &CGM, + return ConstantAddress::invalid(); + } + +- auto GV = new llvm::GlobalVariable(CGM.getModule(), C->getType(), +- CGM.isTypeConstant(E->getType(), true), +- llvm::GlobalValue::InternalLinkage, +- C, ".compoundliteral", nullptr, +- llvm::GlobalVariable::NotThreadLocal, +- CGM.getContext().getTargetAddressSpace(addressSpace)); ++ auto GV = new llvm::GlobalVariable( ++ CGM.getModule(), C->getType(), ++ CGM.isTypeConstant(E->getType(), true, false), ++ llvm::GlobalValue::InternalLinkage, C, ".compoundliteral", nullptr, ++ llvm::GlobalVariable::NotThreadLocal, ++ CGM.getContext().getTargetAddressSpace(addressSpace)); + emitter.finalize(GV); + GV->setAlignment(Align.getAsAlign()); + CGM.setAddrOfConstantCompoundLiteral(E, GV); +diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp +index 2777fc22600d..c88228090c17 100644 +--- a/clang/lib/CodeGen/CodeGenModule.cpp ++++ b/clang/lib/CodeGen/CodeGenModule.cpp +@@ -2826,7 +2826,7 @@ bool CodeGenModule::MayBeEmittedEagerly(const ValueDecl *Global) { + // codegen for global variables, because they may be marked as threadprivate. + if (LangOpts.OpenMP && LangOpts.OpenMPUseTLS && + getContext().getTargetInfo().isTLSSupported() && isa(Global) && +- !isTypeConstant(Global->getType(), false) && ++ !isTypeConstant(Global->getType(), false, false) && + !OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(Global)) + return false; + +@@ -3988,8 +3988,9 @@ CodeGenModule::CreateRuntimeFunction(llvm::FunctionType *FTy, StringRef Name, + /// + /// If ExcludeCtor is true, the duration when the object's constructor runs + /// will not be considered. The caller will need to verify that the object is +-/// not written to during its construction. +-bool CodeGenModule::isTypeConstant(QualType Ty, bool ExcludeCtor) { ++/// not written to during its construction. ExcludeDtor works similarly. ++bool CodeGenModule::isTypeConstant(QualType Ty, bool ExcludeCtor, ++ bool ExcludeDtor) { + if (!Ty.isConstant(Context) && !Ty->isReferenceType()) + return false; + +@@ -3997,7 +3998,7 @@ bool CodeGenModule::isTypeConstant(QualType Ty, bool ExcludeCtor) { + if (const CXXRecordDecl *Record + = Context.getBaseElementType(Ty)->getAsCXXRecordDecl()) + return ExcludeCtor && !Record->hasMutableFields() && +- Record->hasTrivialDestructor(); ++ (Record->hasTrivialDestructor() || ExcludeDtor); + } + + return true; +@@ -4108,7 +4109,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty, + + // FIXME: This code is overly simple and should be merged with other global + // handling. +- GV->setConstant(isTypeConstant(D->getType(), false)); ++ GV->setConstant(isTypeConstant(D->getType(), false, false)); + + GV->setAlignment(getContext().getDeclAlign(D).getAsAlign()); + +@@ -4642,7 +4643,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, + + // If it is safe to mark the global 'constant', do so now. + GV->setConstant(!NeedsGlobalCtor && !NeedsGlobalDtor && +- isTypeConstant(D->getType(), true)); ++ isTypeConstant(D->getType(), true, true)); + + // If it is in a read-only section, mark it 'constant'. + if (const SectionAttr *SA = D->getAttr()) { +@@ -5703,7 +5704,8 @@ ConstantAddress CodeGenModule::GetAddrOfGlobalTemporary( + emitter.emplace(*this); + InitialValue = emitter->emitForInitializer(*Value, AddrSpace, + MaterializedType); +- Constant = isTypeConstant(MaterializedType, /*ExcludeCtor*/Value); ++ Constant = isTypeConstant(MaterializedType, /*ExcludeCtor*/ Value, ++ /*ExcludeDtor*/ false); + Type = InitialValue->getType(); + } else { + // No initializer, the initialization will be provided when we +diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h +index a8a63c8da57f..28ea927c448d 100644 +--- a/clang/lib/CodeGen/CodeGenModule.h ++++ b/clang/lib/CodeGen/CodeGenModule.h +@@ -765,7 +765,7 @@ public: + return getTBAAAccessInfo(AccessType); + } + +- bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor); ++ bool isTypeConstant(QualType QTy, bool ExcludeCtor, bool ExcludeDtor); + + bool isPaddedAtomicType(QualType type); + bool isPaddedAtomicType(const AtomicType *type); +diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp +index d83bc9e529a6..672ca38c6803 100644 +--- a/clang/lib/CodeGen/TargetInfo.cpp ++++ b/clang/lib/CodeGen/TargetInfo.cpp +@@ -9440,7 +9440,7 @@ AMDGPUTargetCodeGenInfo::getGlobalVarAddressSpace(CodeGenModule &CGM, + return AddrSpace; + + // Only promote to address space 4 if VarDecl has constant initialization. +- if (CGM.isTypeConstant(D->getType(), false) && ++ if (CGM.isTypeConstant(D->getType(), false, false) && + D->hasConstantInitialization()) { + if (auto ConstAS = CGM.getTarget().getConstantAddressSpace()) + return ConstAS.getValue(); +diff --git a/clang/test/CodeGen/init.c b/clang/test/CodeGen/init.c +index a21b5f4c09f5..93859924349b 100644 +--- a/clang/test/CodeGen/init.c ++++ b/clang/test/CodeGen/init.c +@@ -10,7 +10,7 @@ unsigned v2[2][3] = {[0 ... 1][0 ... 1] = 2222, 3333}; + + // CHECK-DAG: [1 x %struct.M] [%struct.M { [2 x %struct.I] [%struct.I { [3 x i32] [i32 4, i32 4, i32 0] }, %struct.I { [3 x i32] [i32 4, i32 4, i32 5] }] }], + // CHECK-DAG: [2 x [3 x i32]] {{[[][[]}}3 x i32] [i32 2222, i32 2222, i32 0], [3 x i32] [i32 2222, i32 2222, i32 3333]], +-// CHECK-DAG: [[INIT14:.*]] = private global [16 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 17, i32 17, i32 17, i32 17, i32 17, i32 17, i32 17, i32 0, i32 0, i32 0, i32 0], align 4 ++// CHECK-DAG: [[INIT14:.*]] = private constant [16 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 17, i32 17, i32 17, i32 17, i32 17, i32 17, i32 17, i32 0, i32 0, i32 0, i32 0], align 4 + + void f1() { + // Scalars in braces. +diff --git a/clang/test/CodeGen/label-array-aggregate-init.c b/clang/test/CodeGen/label-array-aggregate-init.c +index 5cefd8d270c0..3175c2a6a292 100644 +--- a/clang/test/CodeGen/label-array-aggregate-init.c ++++ b/clang/test/CodeGen/label-array-aggregate-init.c +@@ -1,6 +1,6 @@ + // RUN: %clang -cc1 -triple x86_64-windows-msvc -emit-llvm %s -o - | FileCheck %s + +-// CHECK: @constinit = private global [3 x i8*] [i8* blockaddress(@main, %L), i8* null, i8* null] ++// CHECK: @constinit = private constant [3 x i8*] [i8* blockaddress(@main, %L), i8* null, i8* null] + + void receivePtrs(void **); + +diff --git a/clang/test/CodeGenCXX/const-init-cxx2a.cpp b/clang/test/CodeGenCXX/const-init-cxx2a.cpp +index 3eafef094387..3c83a9c94ade 100644 +--- a/clang/test/CodeGenCXX/const-init-cxx2a.cpp ++++ b/clang/test/CodeGenCXX/const-init-cxx2a.cpp +@@ -11,10 +11,10 @@ struct B { + constexpr ~B() { n *= 5; } + int n = 123; + }; +-// CHECK: @b ={{.*}} global {{.*}} i32 123 ++// CHECK: @b ={{.*}} constant {{.*}} i32 123 + extern constexpr B b = B(); + +-// CHECK: @_ZL1c = internal global {{.*}} i32 123 ++// CHECK: @_ZL1c = internal constant {{.*}} i32 123 + const B c; + int use_c() { return c.n; } + +-- +2.31.1 + diff --git a/cross/llvm-project-140.src/patches/2007-ocl-0007-clang-Sema-check-default-argument-promotions-for-pri.patch b/cross/llvm-project-140.src/patches/2007-ocl-0007-clang-Sema-check-default-argument-promotions-for-pri.patch new file mode 100644 index 00000000000..94305a80753 --- /dev/null +++ b/cross/llvm-project-140.src/patches/2007-ocl-0007-clang-Sema-check-default-argument-promotions-for-pri.patch @@ -0,0 +1,509 @@ +From f72d0efc9f42802ccf0e3ffcd6ae26ba4dfc8529 Mon Sep 17 00:00:00 2001 +From: "Yang, Haonan" +Date: Thu, 6 Jun 2024 10:15:54 +0800 +Subject: [PATCH] [clang][Sema] check default argument promotions for printf + +cherry pick https://github.com/llvm/llvm-project/commit/e3bd67eddf65b20956513e91715b1f997dae2690 + +The main focus of this patch is to make ArgType::matchesType check for +possible default parameter promotions when the argType is not a pointer. +If so, no warning will be given for `int`, `unsigned int` types as +corresponding arguments to %hhd and %hd. However, the usage of %hhd +corresponding to short is relatively rare, and it is more likely to be a +misuse. This patch keeps the original behavior of clang like this as +much as possible, while making it more convenient to consider the +default arguments promotion. + +Fixes https://github.com/llvm/llvm-project/issues/57102 + +Reviewed By: aaron.ballman, nickdesaulniers, #clang-language-wg + +Differential Revision: https://reviews.llvm.org/D132568 + +cherry pick https://github.com/llvm/llvm-project/commit/04e6178ae932c9a1d939dcfe3ef1189f4bbb21aa + +[Sema] tolerate more promotion matches in format string checking +It's been reported that when using __attribute__((format)) on non-variadic +functions, certain values that normally get promoted when passed as variadic +arguments now unconditionally emit a diagnostic: + +```c +void foo(const char *fmt, float f) __attribute__((format(printf, 1, 2))); +void bar(void) { + foo("%g", 123.f); + // ^ format specifies type 'double' but the argument has type 'float' +} +``` + +This is normally not an issue because float values get promoted to doubles when +passed as variadic arguments, but needless to say, variadic argument promotion +does not apply to non-variadic arguments. + +While this can be fixed by adjusting the prototype of `foo`, this is sometimes +undesirable in C (for instance, if `foo` is ABI). In C++, using variadic +templates, this might instead require call-site fixing, which is tedious and +arguably needless work: + +```c++ +template +void foo(const char *fmt, Args &&...args) __attribute__((format(printf, 1, 2))); +void bar(void) { + foo("%g", 123.f); + // ^ format specifies type 'double' but the argument has type 'float' +} +``` + +To address this issue, we teach FormatString about a few promotions that have +always been around but that have never been exercised in the direction that +FormatString checks for: + +* `char`, `unsigned char` -> `int`, `unsigned` +* `half`, `float16`, `float` -> `double` + +This addresses issue https://github.com/llvm/llvm-project/issues/59824 +--- + clang/docs/ReleaseNotes.rst | 10 ++ + clang/include/clang/AST/FormatString.h | 8 +- + clang/lib/AST/FormatString.cpp | 121 +++++++++++++++++++---- + clang/lib/Sema/SemaChecking.cpp | 44 ++++++--- + clang/test/Sema/format-strings-freebsd.c | 4 +- + clang/test/Sema/format-strings-scanf.c | 52 ++++++++++ + clang/test/Sema/format-strings.c | 54 ++++++++++ + 7 files changed, 259 insertions(+), 34 deletions(-) + +diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst +index 0c50e168bf48..a46949dcdc76 100644 +--- a/clang/docs/ReleaseNotes.rst ++++ b/clang/docs/ReleaseNotes.rst +@@ -173,6 +173,13 @@ New Pragmas in Clang + Attribute Changes in Clang + -------------------------- + ++- When a non-variadic function is decorated with the ``format`` attribute, ++ Clang now checks that the format string would match the function's parameters' ++ types after default argument promotion. As a result, it's no longer an ++ automatic diagnostic to use parameters of types that the format style ++ supports but that are never the result of default argument promotion, such as ++ ``float``. (`#59824: `_) ++ + - Attributes loaded as clang plugins which are sensitive to LangOpts must + now override ``acceptsLangOpts`` instead of ``diagLangOpts``. + Returning false will produce a generic "attribute ignored" diagnostic, as +@@ -223,6 +230,9 @@ Windows Support + + C Language Changes in Clang + --------------------------- ++- Adjusted ``-Wformat`` warnings according to `WG14 N2562 `_. ++ Clang will now consider default argument promotions in printf, and remove unnecessary warnings. ++ Especially ``int`` argument with specifier ``%hhd`` and ``%hd``. + + - The value of ``__STDC_VERSION__`` has been bumped to ``202000L`` when passing + ``-std=c2x`` so that it can be distinguished from C17 mode. This value is +diff --git a/clang/include/clang/AST/FormatString.h b/clang/include/clang/AST/FormatString.h +index d7933382f13d..60849bd7f9d3 100644 +--- a/clang/include/clang/AST/FormatString.h ++++ b/clang/include/clang/AST/FormatString.h +@@ -257,8 +257,14 @@ public: + /// instance, "%d" and float. + NoMatch = 0, + /// The conversion specifier and the argument type are compatible. For +- /// instance, "%d" and _Bool. ++ /// instance, "%d" and int. + Match = 1, ++ /// The conversion specifier and the argument type are compatible because of ++ /// default argument promotions. For instance, "%hhd" and int. ++ MatchPromotion, ++ /// The conversion specifier and the argument type are compatible but still ++ /// seems likely to be an error. For instanace, "%hhd" and short. ++ NoMatchPromotionTypeConfusion, + /// The conversion specifier and the argument type are disallowed by the C + /// standard, but are in practice harmless. For instance, "%p" and int*. + NoMatchPedantic, +diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp +index 102bcca96a38..df7917b15810 100644 +--- a/clang/lib/AST/FormatString.cpp ++++ b/clang/lib/AST/FormatString.cpp +@@ -342,7 +342,7 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { + return Match; + + case AnyCharTy: { +- if (const EnumType *ETy = argTy->getAs()) { ++ if (const auto *ETy = argTy->getAs()) { + // If the enum is incomplete we know nothing about the underlying type. + // Assume that it's 'int'. + if (!ETy->getDecl()->isComplete()) +@@ -350,17 +350,34 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { + argTy = ETy->getDecl()->getIntegerType(); + } + +- if (const BuiltinType *BT = argTy->getAs()) ++ if (const auto *BT = argTy->getAs()) { ++ // The types are perfectly matched? + switch (BT->getKind()) { ++ default: ++ break; ++ case BuiltinType::Char_S: ++ case BuiltinType::SChar: ++ case BuiltinType::UChar: ++ case BuiltinType::Char_U: ++ case BuiltinType::Bool: ++ return Match; ++ } ++ // "Partially matched" because of promotions? ++ if (!Ptr) { ++ switch (BT->getKind()) { + default: + break; +- case BuiltinType::Char_S: +- case BuiltinType::SChar: +- case BuiltinType::UChar: +- case BuiltinType::Char_U: +- case BuiltinType::Bool: +- return Match; ++ case BuiltinType::Int: ++ case BuiltinType::UInt: ++ return MatchPromotion; ++ case BuiltinType::Short: ++ case BuiltinType::UShort: ++ case BuiltinType::WChar_S: ++ case BuiltinType::WChar_U: ++ return NoMatchPromotionTypeConfusion; ++ } + } ++ } + return NoMatch; + } + +@@ -377,8 +394,9 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { + + if (T == argTy) + return Match; +- // Check for "compatible types". +- if (const BuiltinType *BT = argTy->getAs()) ++ if (const auto *BT = argTy->getAs()) { ++ // Check if the only difference between them is signed vs unsigned ++ // if true, we consider they are compatible. + switch (BT->getKind()) { + default: + break; +@@ -389,25 +407,88 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { + case BuiltinType::Bool: + if (T == C.UnsignedShortTy || T == C.ShortTy) + return NoMatchTypeConfusion; +- return T == C.UnsignedCharTy || T == C.SignedCharTy ? Match +- : NoMatch; ++ if (T == C.UnsignedCharTy || T == C.SignedCharTy) ++ return Match; ++ break; + case BuiltinType::Short: +- return T == C.UnsignedShortTy ? Match : NoMatch; ++ if (T == C.UnsignedShortTy) ++ return Match; ++ break; + case BuiltinType::UShort: +- return T == C.ShortTy ? Match : NoMatch; ++ if (T == C.ShortTy) ++ return Match; ++ break; + case BuiltinType::Int: +- return T == C.UnsignedIntTy ? Match : NoMatch; ++ if (T == C.UnsignedIntTy) ++ return Match; ++ break; + case BuiltinType::UInt: +- return T == C.IntTy ? Match : NoMatch; ++ if (T == C.IntTy) ++ return Match; ++ break; + case BuiltinType::Long: +- return T == C.UnsignedLongTy ? Match : NoMatch; ++ if (T == C.UnsignedLongTy) ++ return Match; ++ break; + case BuiltinType::ULong: +- return T == C.LongTy ? Match : NoMatch; ++ if (T == C.LongTy) ++ return Match; ++ break; + case BuiltinType::LongLong: +- return T == C.UnsignedLongLongTy ? Match : NoMatch; ++ if (T == C.UnsignedLongLongTy) ++ return Match; ++ break; + case BuiltinType::ULongLong: +- return T == C.LongLongTy ? Match : NoMatch; ++ if (T == C.LongLongTy) ++ return Match; ++ break; + } ++ // "Partially matched" because of promotions? ++ if (!Ptr) { ++ switch (BT->getKind()) { ++ default: ++ break; ++ case BuiltinType::Bool: ++ if (T == C.IntTy || T == C.UnsignedIntTy) ++ return MatchPromotion; ++ break; ++ case BuiltinType::Int: ++ case BuiltinType::UInt: ++ if (T == C.SignedCharTy || T == C.UnsignedCharTy || ++ T == C.ShortTy || T == C.UnsignedShortTy || T == C.WCharTy || ++ T == C.WideCharTy) ++ return MatchPromotion; ++ break; ++ case BuiltinType::Char_U: ++ if (T == C.UnsignedIntTy) ++ return MatchPromotion; ++ if (T == C.UnsignedShortTy) ++ return NoMatchPromotionTypeConfusion; ++ break; ++ case BuiltinType::Char_S: ++ if (T == C.IntTy) ++ return MatchPromotion; ++ if (T == C.ShortTy) ++ return NoMatchPromotionTypeConfusion; ++ break; ++ case BuiltinType::Half: ++ case BuiltinType::Float16: ++ case BuiltinType::Float: ++ if (T == C.DoubleTy) ++ return MatchPromotion; ++ break; ++ case BuiltinType::Short: ++ case BuiltinType::UShort: ++ if (T == C.SignedCharTy || T == C.UnsignedCharTy) ++ return NoMatchPromotionTypeConfusion; ++ break; ++ case BuiltinType::WChar_U: ++ case BuiltinType::WChar_S: ++ if (T != C.WCharTy && T != C.WideCharTy) ++ return NoMatchPromotionTypeConfusion; ++ } ++ } ++ } + return NoMatch; + } + +diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp +index 69dcc3aaaaf3..1ed01cb7dd9a 100644 +--- a/clang/lib/Sema/SemaChecking.cpp ++++ b/clang/lib/Sema/SemaChecking.cpp +@@ -9557,10 +9557,14 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, + return true; + } + +- analyze_printf::ArgType::MatchKind Match = AT.matchesType(S.Context, ExprTy); +- if (Match == analyze_printf::ArgType::Match) ++ ArgType::MatchKind ImplicitMatch = ArgType::NoMatch; ++ ArgType::MatchKind Match = AT.matchesType(S.Context, ExprTy); ++ if (Match == ArgType::Match) + return true; + ++ // NoMatchPromotionTypeConfusion should be only returned in ImplictCastExpr ++ assert(Match != ArgType::NoMatchPromotionTypeConfusion); ++ + // Look through argument promotions for our error message's reported type. + // This includes the integral and floating promotions, but excludes array + // and function pointer decay (seeing that an argument intended to be a +@@ -9577,13 +9581,9 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, + if (ICE->getType() == S.Context.IntTy || + ICE->getType() == S.Context.UnsignedIntTy) { + // All further checking is done on the subexpression +- const analyze_printf::ArgType::MatchKind ImplicitMatch = +- AT.matchesType(S.Context, ExprTy); +- if (ImplicitMatch == analyze_printf::ArgType::Match) ++ ImplicitMatch = AT.matchesType(S.Context, ExprTy); ++ if (ImplicitMatch == ArgType::Match) + return true; +- if (ImplicitMatch == ArgType::NoMatchPedantic || +- ImplicitMatch == ArgType::NoMatchTypeConfusion) +- Match = ImplicitMatch; + } + } + } else if (const CharacterLiteral *CL = dyn_cast(E)) { +@@ -9594,10 +9594,29 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, + // modifier is provided. + if (ExprTy == S.Context.IntTy && + FS.getLengthModifier().getKind() != LengthModifier::AsChar) +- if (llvm::isUIntN(S.Context.getCharWidth(), CL->getValue())) ++ if (llvm::isUIntN(S.Context.getCharWidth(), CL->getValue())) { + ExprTy = S.Context.CharTy; ++ // To improve check results, we consider a character literal in C ++ // to be a 'char' rather than an 'int'. 'printf("%hd", 'a');' is ++ // more likely a type confusion situation, so we will suggest to ++ // use '%hhd' instead by discarding the MatchPromotion. ++ if (Match == ArgType::MatchPromotion) ++ Match = ArgType::NoMatch; ++ } + } +- ++ if (Match == ArgType::MatchPromotion) { ++ // WG14 N2562 only clarified promotions in *printf ++ // For NSLog in ObjC, just preserve -Wformat behavior ++ if (!S.getLangOpts().ObjC && ++ ImplicitMatch != ArgType::NoMatchPromotionTypeConfusion && ++ ImplicitMatch != ArgType::NoMatchTypeConfusion) ++ return true; ++ Match = ArgType::NoMatch; ++ } ++ if (ImplicitMatch == ArgType::NoMatchPedantic || ++ ImplicitMatch == ArgType::NoMatchTypeConfusion) ++ Match = ImplicitMatch; ++ assert(Match != ArgType::MatchPromotion); + // Look through enums to their underlying type. + bool IsEnum = false; + if (auto EnumTy = ExprTy->getAs()) { +@@ -9670,7 +9689,10 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, + if (IntendedTy == ExprTy && !ShouldNotPrintDirectly) { + unsigned Diag; + switch (Match) { +- case ArgType::Match: llvm_unreachable("expected non-matching"); ++ case ArgType::Match: ++ case ArgType::MatchPromotion: ++ case ArgType::NoMatchPromotionTypeConfusion: ++ llvm_unreachable("expected non-matching"); + case ArgType::NoMatchPedantic: + Diag = diag::warn_format_conversion_argument_type_mismatch_pedantic; + break; +diff --git a/clang/test/Sema/format-strings-freebsd.c b/clang/test/Sema/format-strings-freebsd.c +index 965d7c287be6..f49dea00c876 100644 +--- a/clang/test/Sema/format-strings-freebsd.c ++++ b/clang/test/Sema/format-strings-freebsd.c +@@ -34,9 +34,9 @@ void check_freebsd_kernel_extensions(int i, long l, char *s, short h) + freebsd_kernel_printf("%lr", l); // no-warning + + // h modifier expects a short +- freebsd_kernel_printf("%hr", i); // expected-warning{{format specifies type 'short' but the argument has type 'int'}} ++ freebsd_kernel_printf("%hr", i); // no-warning + freebsd_kernel_printf("%hr", h); // no-warning +- freebsd_kernel_printf("%hy", i); // expected-warning{{format specifies type 'short' but the argument has type 'int'}} ++ freebsd_kernel_printf("%hy", i); // no-warning + freebsd_kernel_printf("%hy", h); // no-warning + + // %y expects an int +diff --git a/clang/test/Sema/format-strings-scanf.c b/clang/test/Sema/format-strings-scanf.c +index b7cdd7dd4a9a..61d20b482c38 100644 +--- a/clang/test/Sema/format-strings-scanf.c ++++ b/clang/test/Sema/format-strings-scanf.c +@@ -241,3 +241,55 @@ void check_conditional_literal(char *s, int *i) { + scanf(i ? "%d" : "%d", i, s); // expected-warning{{data argument not used}} + scanf(i ? "%s" : "%d", s); // expected-warning{{format specifies type 'int *'}} + } ++ ++void test_promotion(void) { ++ // No promotions for *scanf pointers clarified in N2562 ++ // https://github.com/llvm/llvm-project/issues/57102 ++ // N2562: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2562.pdf ++ int i; ++ signed char sc; ++ unsigned char uc; ++ short ss; ++ unsigned short us; ++ ++ // pointers could not be "promoted" ++ scanf("%hhd", &i); // expected-warning{{format specifies type 'char *' but the argument has type 'int *'}} ++ scanf("%hd", &i); // expected-warning{{format specifies type 'short *' but the argument has type 'int *'}} ++ scanf("%d", &i); // no-warning ++ // char & uchar ++ scanf("%hhd", &sc); // no-warning ++ scanf("%hhd", &uc); // no-warning ++ scanf("%hd", &sc); // expected-warning{{format specifies type 'short *' but the argument has type 'signed char *'}} ++ scanf("%hd", &uc); // expected-warning{{format specifies type 'short *' but the argument has type 'unsigned char *'}} ++ scanf("%d", &sc); // expected-warning{{format specifies type 'int *' but the argument has type 'signed char *'}} ++ scanf("%d", &uc); // expected-warning{{format specifies type 'int *' but the argument has type 'unsigned char *'}} ++ // short & ushort ++ scanf("%hhd", &ss); // expected-warning{{format specifies type 'char *' but the argument has type 'short *'}} ++ scanf("%hhd", &us); // expected-warning{{format specifies type 'char *' but the argument has type 'unsigned short *'}} ++ scanf("%hd", &ss); // no-warning ++ scanf("%hd", &us); // no-warning ++ scanf("%d", &ss); // expected-warning{{format specifies type 'int *' but the argument has type 'short *'}} ++ scanf("%d", &us); // expected-warning{{format specifies type 'int *' but the argument has type 'unsigned short *'}} ++ ++ // long types ++ scanf("%ld", &i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}} ++ scanf("%lld", &i); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}} ++ scanf("%ld", &sc); // expected-warning{{format specifies type 'long *' but the argument has type 'signed char *'}} ++ scanf("%lld", &sc); // expected-warning{{format specifies type 'long long *' but the argument has type 'signed char *'}} ++ scanf("%ld", &uc); // expected-warning{{format specifies type 'long *' but the argument has type 'unsigned char *'}} ++ scanf("%lld", &uc); // expected-warning{{format specifies type 'long long *' but the argument has type 'unsigned char *'}} ++ scanf("%llx", &i); // expected-warning{{format specifies type 'unsigned long long *' but the argument has type 'int *'}} ++ ++ // ill-formed floats ++ scanf("%hf", // expected-warning{{length modifier 'h' results in undefined behavior or no effect with 'f' conversion specifier}} ++ &sc); ++ ++ // pointers in scanf ++ scanf("%s", i); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} ++ ++ // FIXME: does this match what the C committee allows or should it be pedantically warned on? ++ char c; ++ void *vp; ++ scanf("%hhd", &c); // Pedantic warning? ++ scanf("%hhd", vp); // expected-warning{{format specifies type 'char *' but the argument has type 'void *'}} ++} +diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c +index bb5c4c4d1de7..d9154b6d30f9 100644 +--- a/clang/test/Sema/format-strings.c ++++ b/clang/test/Sema/format-strings.c +@@ -823,3 +823,57 @@ void test_block() { + printf_arg2("foo", "%s string %i\n", "aaa", 123); + printf_arg2("%s string\n", "foo", "bar"); // expected-warning{{data argument not used by format string}} + } ++ ++void test_promotion(void) { ++ // Default argument promotions for *printf in N2562 ++ // https://github.com/llvm/llvm-project/issues/57102 ++ // N2562: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2562.pdf ++ int i; ++ signed char sc; ++ unsigned char uc; ++ char c; ++ short ss; ++ unsigned short us; ++ ++ printf("%hhd %hd %d %hhd %hd %d", i, i, i, sc, sc, sc); // no-warning ++ printf("%hhd %hd %d %hhd %hd %d", uc, uc, uc, c, c, c); // no-warning ++ ++ // %ld %lld %llx ++ printf("%ld", i); // expected-warning{{format specifies type 'long' but the argument has type 'int'}} ++ printf("%lld", i); // expected-warning{{format specifies type 'long long' but the argument has type 'int'}} ++ printf("%ld", sc); // expected-warning{{format specifies type 'long' but the argument has type 'signed char'}} ++ printf("%lld", sc); // expected-warning{{format specifies type 'long long' but the argument has type 'signed char'}} ++ printf("%ld", uc); // expected-warning{{format specifies type 'long' but the argument has type 'unsigned char'}} ++ printf("%lld", uc); // expected-warning{{format specifies type 'long long' but the argument has type 'unsigned char'}} ++ printf("%llx", i); // expected-warning{{format specifies type 'unsigned long long' but the argument has type 'int'}} ++ ++ // ill formed spec for floats ++ printf("%hf", // expected-warning{{length modifier 'h' results in undefined behavior or no effect with 'f' conversion specifier}} ++ sc); // expected-warning{{format specifies type 'double' but the argument has type 'signed char'}} ++ ++ // for %hhd and `short` they are compatible by promotions but more likely misuse ++ printf("%hd", ss); // no-warning ++ printf("%hhd", ss); // expected-warning{{format specifies type 'char' but the argument has type 'short'}} ++ printf("%hu", us); // no-warning ++ printf("%hhu", ss); // expected-warning{{format specifies type 'unsigned char' but the argument has type 'short'}} ++ ++ // floats & integers are not compatible ++ printf("%f", i); // expected-warning{{format specifies type 'double' but the argument has type 'int'}} ++ printf("%f", sc); // expected-warning{{format specifies type 'double' but the argument has type 'signed char'}} ++ printf("%f", uc); // expected-warning{{format specifies type 'double' but the argument has type 'unsigned char'}} ++ printf("%f", c); // expected-warning{{format specifies type 'double' but the argument has type 'char'}} ++ printf("%f", ss); // expected-warning{{format specifies type 'double' but the argument has type 'short'}} ++ printf("%f", us); // expected-warning{{format specifies type 'double' but the argument has type 'unsigned short'}} ++ ++ // character literals ++ // In C language engineering practice, printing a character literal with %hhd or %d is common, but %hd may be misuse. ++ printf("%hhu", 'a'); // no-warning ++ printf("%hhd", 'a'); // no-warning ++ printf("%hd", 'a'); // expected-warning{{format specifies type 'short' but the argument has type 'char'}} ++ printf("%hu", 'a'); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'char'}} ++ printf("%d", 'a'); // no-warning ++ printf("%u", 'a'); // no-warning ++ ++ // pointers ++ printf("%s", i); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} ++} +-- +2.31.1 + diff --git a/cross/ocl-icd/Makefile b/cross/ocl-icd/Makefile new file mode 100644 index 00000000000..b9557dfa023 --- /dev/null +++ b/cross/ocl-icd/Makefile @@ -0,0 +1,25 @@ +PKG_NAME = ocl-icd +PKG_VERS = 2.3.2 +PKG_EXT = tar.gz +PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT) +PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) +PKG_DIST_SITE = https://github.com/OCL-dev/ocl-icd/archive/refs/tags +PKG_DIR = $(PKG_NAME)-$(PKG_VERS) + +HOMEPAGE = https://github.com/OCL-dev/ocl-icd +COMMENT = Open Source alternative to vendor specific OpenCL ICD loaders. +LICENSE = BSD 2-Clause "Simplified" License + +# [Khronos-OpenCL-Headers] +BUILD_DEPENDS += cross/Khronos-OpenCL-Headers + +GNU_CONFIGURE = 1 +PRE_CONFIGURE_TARGET = ocl-icd_pre_configure +CONFIGURE_ARGS = --enable-custom-vendordir=$(INSTALL_PREFIX)/etc/OpenCL/vendors +CONFIGURE_ARGS += --enable-custom-layerdir=$(INSTALL_PREFIX)/etc/OpenCL/layers + +include ../../mk/spksrc.cross-cc.mk + +.PHONY: ocl-icd_pre_configure +ocl-icd_pre_configure: + $(RUN) autoreconf -fiv diff --git a/cross/ocl-icd/PLIST b/cross/ocl-icd/PLIST new file mode 100644 index 00000000000..1cfef3d0e57 --- /dev/null +++ b/cross/ocl-icd/PLIST @@ -0,0 +1,4 @@ +bin:bin/cllayerinfo +lnk:lib/libOpenCL.so +lnk:lib/libOpenCL.so.1 +lib:lib/libOpenCL.so.1.0.0 diff --git a/cross/ocl-icd/digests b/cross/ocl-icd/digests new file mode 100644 index 00000000000..a2a75edc10e --- /dev/null +++ b/cross/ocl-icd/digests @@ -0,0 +1,3 @@ +ocl-icd-2.3.2.tar.gz SHA1 19e5d5013e9ba2c6cda5e2cad42693c9201d056d +ocl-icd-2.3.2.tar.gz SHA256 ec47d7dcd961ea06695b067e8b7edb82e420ddce03e0081a908c62fd0b8535c5 +ocl-icd-2.3.2.tar.gz MD5 e711262803e68de3d32620789942f209 diff --git a/cross/tvheadend/Makefile b/cross/tvheadend/Makefile index ac5c14d40e1..a6665dcb1da 100644 --- a/cross/tvheadend/Makefile +++ b/cross/tvheadend/Makefile @@ -2,34 +2,46 @@ PKG_NAME = tvheadend PKG_VERS = 4.3 PKG_EXT = tar.gz # no official release since v4.2.8 (Jan 12, 2019) -# git hash from June 23rd 2024 -PKG_GIT_HASH = 128d6861fac67ea6638c2956d092a46e23eb8988 +# git hash from Sept 4th 2024 +PKG_GIT_HASH = 9ac57a0c1a4551012260008cfca6bfc2386f6dcf PKG_DIST_NAME = $(PKG_GIT_HASH).$(PKG_EXT) PKG_DIST_SITE = https://github.com/tvheadend/tvheadend/archive PKG_DIST_FILE = $(PKG_NAME)-git$(PKG_GIT_HASH).$(PKG_EXT) PKG_DIR = $(PKG_NAME)-$(PKG_GIT_HASH) +HOMEPAGE = https://tvheadend.org/ +COMMENT = Tvheadend is a TV streaming server and recorder for Linux, FreeBSD and Android supporting DVB-S, DVB-S2, DVB-C, DVB-T, ATSC, ISDB-T, IPTV, SAT IP and HDHomeRun as input sources. Tvheadend offers HTTP, HTSP and SAT IP streaming. +LICENSE = GPLv3 + +# PPC archs except qoriq are not supported +# https://tvheadend.org/issues/5060 +UNSUPPORTED_ARCHS = $(OLD_PPC_ARCHS) + +OPTIONAL_DEPENDS += cross/ffmpeg6 +OPTIONAL_DEPENDS += cross/fdk-aac +OPTIONAL_DEPENDS += cross/fontconfig +OPTIONAL_DEPENDS += cross/opus +OPTIONAL_DEPENDS += cross/pcre2 +OPTIONAL_DEPENDS += cross/libtheora +OPTIONAL_DEPENDS += cross/libvorbis +OPTIONAL_DEPENDS += cross/libvpx +OPTIONAL_DEPENDS += cross/x264 +OPTIONAL_DEPENDS += cross/x265 + # WARNING: pngquant will fail when built after cross/zlib (i.e. cross/libpng) # with prebuilt ffmpeg this is not a problem # without prebuilt ffmpeg the "DEPENDS += cross/ffmpeg*" must be defined below DEPENDS = cross/pngquant DEPENDS += cross/openssl3 cross/gnutls -DEPENDS += cross/uriparser cross/pcre2 cross/libiconv cross/fontconfig -DEPENDS += cross/libhdhomerun cross/libdvbcsa cross/dvb-apps +DEPENDS += cross/uriparser cross/libiconv +DEPENDS += cross/libdvbcsa cross/dvb-apps +DEPENDS += cross/libhdhomerun DEPENDS += cross/curl # curl build needs additional configuration for gnutls and libssh2 export BUILD_CURL_WITH="gnutls libssh2 zstd" -# PPC archs except qoriq are not supported -# https://tvheadend.org/issues/5060 -UNSUPPORTED_ARCHS = $(OLD_PPC_ARCHS) - -HOMEPAGE = https://tvheadend.org/ -COMMENT = Tvheadend is a TV streaming server and recorder for Linux, FreeBSD and Android supporting DVB-S, DVB-S2, DVB-C, DVB-T, ATSC, ISDB-T, IPTV, SAT IP and HDHomeRun as input sources. Tvheadend offers HTTP, HTSP and SAT IP streaming. -LICENSE = GPLv3 - GNU_CONFIGURE = 1 PRE_CONFIGURE_TARGET = tvheadend_pre_configure POST_INSTALL_TARGET = tvheadend_post_install @@ -40,7 +52,7 @@ CONFIGURE_ARGS += --disable-bintray_cache --disable-avahi CONFIGURE_ARGS += --enable-dvbcsa --enable-pngquant CONFIGURE_ARGS += --disable-hdhomerun_static --enable-hdhomerun_client -# Enable all libraries incoming from FFMPEG +# Enable media libraries incoming from FFMPEG CONFIGURE_ARGS += --disable-libfdkaac_static --enable-libfdkaac CONFIGURE_ARGS += --disable-libopus_static --enable-libopus CONFIGURE_ARGS += --disable-libtheora_static --enable-libtheora @@ -48,31 +60,54 @@ CONFIGURE_ARGS += --disable-libvorbis_static --enable-libvorbis CONFIGURE_ARGS += --disable-libvpx_static --enable-libvpx CONFIGURE_ARGS += --disable-libx264_static --enable-libx264 CONFIGURE_ARGS += --disable-libx265_static --enable-libx265 -ifeq ($(wildcard $(FFMPEG_DIR)),) -DEPENDS += cross/fdk-aac cross/opus cross/libtheora cross/libvorbis cross/libvpx cross/x264 cross/x265 -endif - CONFIGURE_ARGS += --disable-ffmpeg_static --enable-libav -ifeq ($(wildcard $(FFMPEG_DIR)),) -DEPENDS += cross/ffmpeg$(FFMPEG_VERSION) -endif - -ifeq ($(call version_ge, ${TCVERSION}, 7.0),1) -ADDITIONAL_CFLAGS += -std=gnu11 -else -CONFIGURE_ARGS += --nowerror -ADDITIONAL_CFLAGS += -std=gnu99 -endif include ../../mk/spksrc.common.mk ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH)) CONFIGURE_ARGS += --enable-vaapi -ifeq ($(wildcard $(FFMPEG_DIR)),) +endif + +# Use media and other libraries through FFMPEG package shared libraries +ifneq ($(wildcard $(FFMPEG_PACKAGE_ROOT)),) +MEDIA_LIBS = fdk-aac.pc +MEDIA_LIBS += fontconfig.pc +MEDIA_LIBS += ogg.pc +MEDIA_LIBS += opus.pc +MEDIA_LIBS += libpcre2-8.pc +MEDIA_LIBS += libpcre2-32.pc +MEDIA_LIBS += libpcre2-posix.pc +MEDIA_LIBS += theoradec.pc +MEDIA_LIBS += theoraenc.pc +MEDIA_LIBS += theora.pc +MEDIA_LIBS += vorbisenc.pc +MEDIA_LIBS += vorbisfile.pc +MEDIA_LIBS += vorbis.pc +MEDIA_LIBS += vpx.pc +MEDIA_LIBS += x264.pc +MEDIA_LIBS += x265.pc + +else +DEPENDS += cross/ffmpeg6 +DEPENDS += cross/fdk-aac +DEPENDS += cross/fontconfig +DEPENDS += cross/opus +DEPENDS += cross/pcre2 +DEPENDS += cross/libtheora +DEPENDS += cross/libvorbis +DEPENDS += cross/libvpx +DEPENDS += cross/x264 +DEPENDS += cross/x265 +ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH)) DEPENDS += cross/libva endif endif +ifeq ($(call version_lt, ${TC_GCC}, 5.0),1) +CONFIGURE_ARGS += --nowerror +ADDITIONAL_CFLAGS += -std=gnu99 +endif + include ../../mk/spksrc.cross-cc.mk .PHONY: tvheadend_pre_configure diff --git a/cross/tvheadend/digests b/cross/tvheadend/digests index 7cda1420fe6..40bb8e71cb6 100644 --- a/cross/tvheadend/digests +++ b/cross/tvheadend/digests @@ -1,3 +1,3 @@ -tvheadend-git128d6861fac67ea6638c2956d092a46e23eb8988.tar.gz SHA1 42755a15dd68f78450e128bbb3d1899aa802b175 -tvheadend-git128d6861fac67ea6638c2956d092a46e23eb8988.tar.gz SHA256 53515bc5bb5553ef9c6ba0545d75b01d8943658168597965b59c365b6e1f2031 -tvheadend-git128d6861fac67ea6638c2956d092a46e23eb8988.tar.gz MD5 b02f718f776b0a593170227633a66c11 +tvheadend-git9ac57a0c1a4551012260008cfca6bfc2386f6dcf.tar.gz SHA1 cb665528384577cec48d1b835ab04deb7a12f186 +tvheadend-git9ac57a0c1a4551012260008cfca6bfc2386f6dcf.tar.gz SHA256 67d56eecbea9cc769bc189709528f90815218fea9e9970141890ad3e4222c1d0 +tvheadend-git9ac57a0c1a4551012260008cfca6bfc2386f6dcf.tar.gz MD5 5b5a8a0b937041c8f212928dab496dba diff --git a/mk/spksrc.cross-cmake.mk b/mk/spksrc.cross-cmake.mk index 273e28ec2db..de6cb19bb32 100644 --- a/mk/spksrc.cross-cmake.mk +++ b/mk/spksrc.cross-cmake.mk @@ -55,6 +55,13 @@ endif ifeq ($(strip $(INSTALL_TARGET)),) INSTALL_TARGET = cmake_install_target endif + +# post-install +ifeq ($(strip $(GCC_NO_DEBUG_INFO)),1) +ifeq ($(strip $(POST_INSTALL_TARGET)),) +POST_INSTALL_TARGET = cmake_post_install_target +endif +endif endif ifeq ($(strip $(CMAKE_USE_TOOLCHAIN_FILE)),ON) @@ -168,6 +175,14 @@ else $(RUN) DESTDIR=$(CMAKE_DESTDIR) cmake --install $(CMAKE_BUILD_DIR) endif +.PHONY: cmake_post_install_target + +# default post-install: clean +# only called when GCC_NO_DEBUG_INFO=1 +cmake_post_install_target: + @$(MSG) - CMake post-install \(clean\) + $(RUN) cmake --build $(CMAKE_BUILD_DIR) --target clean + ### For arch-* and all- include ../../mk/spksrc.supported.mk diff --git a/mk/spksrc.cross-env.mk b/mk/spksrc.cross-env.mk index 78fa3cb1a2c..ee694fbb78d 100644 --- a/mk/spksrc.cross-env.mk +++ b/mk/spksrc.cross-env.mk @@ -28,6 +28,23 @@ ADDITIONAL_CPPFLAGS := $(patsubst -O%,,$(ADDITIONAL_CPPFLAGS)) $(GCC_DEBUG_FLAGS ADDITIONAL_CXXFLAGS := $(patsubst -O%,,$(ADDITIONAL_CXXFLAGS)) $(GCC_DEBUG_FLAGS) endif +# gcc: +# -g0 deactivates debug information generation +# -Os enable some optimizations while avoiding those that increases space +# -flto enable optimization at link time (Link Time Optimization) +# -ffunction-sections -fdata-sections allows placing functions in their own ELF section +# ld: +# -Wl,--gc-sections allows removing unused functions set previously (-f*-sections) +# -w omits the DWARF symbol table removing debugging information +# -s strips the symbol table and debug information from the binary +ifeq ($(strip $(GCC_NO_DEBUG_INFO)),1) +GCC_NO_DEBUG_FLAGS = -g0 -Os -ffunction-sections -fdata-sections -fvisibility=hidden +ADDITIONAL_CFLAGS := $(patsubst -O%,,$(ADDITIONAL_CFLAGS)) $(GCC_NO_DEBUG_FLAGS) +ADDITIONAL_CPPFLAGS := $(patsubst -O%,,$(ADDITIONAL_CPPFLAGS)) $(GCC_NO_DEBUG_FLAGS) +ADDITIONAL_CXXFLAGS := $(patsubst -O%,,$(ADDITIONAL_CXXFLAGS)) $(GCC_NO_DEBUG_FLAGS) +ADDITIONAL_LDFLAGS := $(ADDITIONAL_LDFLAGS) -w -s -Wl,--gc-sections +endif + ifneq ($(strip $(TC)),) TC_VARS_MK = $(WORK_DIR)/tc_vars.mk TC_VARS_CMAKE = $(WORK_DIR)/tc_vars.cmake diff --git a/mk/spksrc.cross-ninja.mk b/mk/spksrc.cross-ninja.mk index faef27a3f00..5c85e3bca7e 100644 --- a/mk/spksrc.cross-ninja.mk +++ b/mk/spksrc.cross-ninja.mk @@ -51,6 +51,13 @@ ifeq ($(strip $(INSTALL_TARGET)),) INSTALL_TARGET = ninja_install_target endif +# post-install +ifeq ($(strip $(GCC_NO_DEBUG_INFO)),1) +ifeq ($(strip $(POST_INSTALL_TARGET)),) +POST_INSTALL_TARGET = ninja_post_install_target +endif +endif + ### .PHONY: ninja_compile_target @@ -76,3 +83,12 @@ ifeq ($(strip $(NINJA_USE_DESTDIR)),0) else $(RUN) DESTDIR=$(NINJA_DESTDIR) ninja -C $(NINJA_BUILD_DIR) install endif + +.PHONY: ninja_post_install_target + +# default ninja post-install: clean +ninja_post_install_target: + @$(MSG) - Ninja post-install \(clean\) + $(RUN) ninja -C $(NINJA_BUILD_DIR) clean + $(RUN) rm -f $(NINJA_BUILD_DIR)/build.ninja + $(RUN) rm -f $(NINJA_BUILD_DIR)/compile_commands.json diff --git a/mk/spksrc.extract.mk b/mk/spksrc.extract.mk index 1e17af8c371..e593aed2ee4 100644 --- a/mk/spksrc.extract.mk +++ b/mk/spksrc.extract.mk @@ -6,21 +6,23 @@ # pre_extract_target (override with PRE_EXTRACT_TARGET) # extract_target (override with EXTRACT_TARGET) # post_extract_target (override with POST_EXTRACT_TARGET) +# Variables: +# ADDITIONAL_EXTRACTFLAGS Additional extract flags being passed EXTRACT_PATH ?= $(WORK_DIR) # Extract commands (optionally use TAR_CMD="fakeroot tar" as workaround on OSX) TAR_CMD ?= tar ifeq ($(strip $(EXTRACT_CMD.$(DIST_EXT))),) -EXTRACT_CMD.tgz = $(TAR_CMD) -xzpf $(DIST_FILE) -C $(EXTRACT_PATH) -EXTRACT_CMD.txz = $(TAR_CMD) -xpf $(DIST_FILE) -C $(EXTRACT_PATH) -EXTRACT_CMD.tar.gz = $(TAR_CMD) -xzpf $(DIST_FILE) -C $(EXTRACT_PATH) -EXTRACT_CMD.tar.bz2 = $(TAR_CMD) -xjpf $(DIST_FILE) -C $(EXTRACT_PATH) -EXTRACT_CMD.tbz = $(TAR_CMD) -xjpf $(DIST_FILE) -C $(EXTRACT_PATH) -EXTRACT_CMD.tar.xz = $(TAR_CMD) -xJpf $(DIST_FILE) -C $(EXTRACT_PATH) -EXTRACT_CMD.tar.lzma = $(TAR_CMD) --lzma -xpf $(DIST_FILE) -C $(EXTRACT_PATH) -EXTRACT_CMD.tar.lz = $(TAR_CMD) --lzip -xpf $(DIST_FILE) -C $(EXTRACT_PATH) -EXTRACT_CMD.zip = unzip $(DIST_FILE) -d $(EXTRACT_PATH) -EXTRACT_CMD.deb = dpkg-deb -R $(DIST_FILE) $(EXTRACT_PATH) +EXTRACT_CMD.tgz = $(TAR_CMD) -xzpf $(DIST_FILE) -C $(EXTRACT_PATH) $(ADDITIONAL_EXTRACTFLAGS) +EXTRACT_CMD.txz = $(TAR_CMD) -xpf $(DIST_FILE) -C $(EXTRACT_PATH) $(ADDITIONAL_EXTRACTFLAGS) +EXTRACT_CMD.tar.gz = $(TAR_CMD) -xzpf $(DIST_FILE) -C $(EXTRACT_PATH) $(ADDITIONAL_EXTRACTFLAGS) +EXTRACT_CMD.tar.bz2 = $(TAR_CMD) -xjpf $(DIST_FILE) -C $(EXTRACT_PATH) $(ADDITIONAL_EXTRACTFLAGS) +EXTRACT_CMD.tbz = $(TAR_CMD) -xjpf $(DIST_FILE) -C $(EXTRACT_PATH) $(ADDITIONAL_EXTRACTFLAGS) +EXTRACT_CMD.tar.xz = $(TAR_CMD) -xJpf $(DIST_FILE) -C $(EXTRACT_PATH) $(ADDITIONAL_EXTRACTFLAGS) +EXTRACT_CMD.tar.lzma = $(TAR_CMD) --lzma -xpf $(DIST_FILE) -C $(EXTRACT_PATH) $(ADDITIONAL_EXTRACTFLAGS) +EXTRACT_CMD.tar.lz = $(TAR_CMD) --lzip -xpf $(DIST_FILE) -C $(EXTRACT_PATH) $(ADDITIONAL_EXTRACTFLAGS) +EXTRACT_CMD.zip = unzip $(DIST_FILE) -d $(EXTRACT_PATH) $(ADDITIONAL_EXTRACTFLAGS) +EXTRACT_CMD.deb = dpkg-deb -R $(DIST_FILE) $(EXTRACT_PATH) $(ADDITIONAL_EXTRACTFLAGS) endif ifeq ($(strip $(EXTRACT_CMD)),) diff --git a/mk/spksrc.ffmpeg.mk b/mk/spksrc.ffmpeg.mk new file mode 100644 index 00000000000..e9e604edf06 --- /dev/null +++ b/mk/spksrc.ffmpeg.mk @@ -0,0 +1,68 @@ +### +### Reuse videodriver libraries +### +# Variables: +# FFMPEG_PACKAGE Must be set to the ffmpeg spk folder (ffmpeg5, ffmpeg6, ...) + +# Set videodriver package name +ifeq ($(strip $(FFMPEG_PACKAGE)),) +export FFMPEG_PACKAGE = ffmpeg6 +endif + +# set default spk/synocli-videodriver path to use +export FFMPEG_PACKAGE_ROOT = $(realpath $(CURDIR)/../../spk/$(FFMPEG_PACKAGE)/work-$(ARCH)-$(TCVERSION)) + +include ../../mk/spksrc.archs.mk + +ifneq ($(wildcard $(FFMPEG_PACKAGE_ROOT)),) + +# Set videodriver installtion prefix directory variables +ifeq ($(strip $(FFMPEG_STAGING_PREFIX)),) +export FFMPEG_PREFIX = /var/packages/$(FFMPEG_PACKAGE)/target +export FFMPEG_STAGING_PREFIX = $(realpath $(FFMPEG_PACKAGE_ROOT)/install/$(FFMPEG_PREFIX)) +endif + +# set build flags including ld to rewrite for the library path +# used to access ffmpeg package provide libraries at destination +ifneq ($(strip $(FFMPEG_STAGING_PREFIX)),) +export ADDITIONAL_CFLAGS += -I$(FFMPEG_STAGING_PREFIX)/include +export ADDITIONAL_CPPFLAGS += -I$(FFMPEG_STAGING_PREFIX)/include +export ADDITIONAL_CXXFLAGS += -I$(FFMPEG_STAGING_PREFIX)/include +export ADDITIONAL_LDFLAGS += -L$(FFMPEG_STAGING_PREFIX)/lib +export ADDITIONAL_LDFLAGS += -Wl,--rpath-link,$(FFMPEG_STAGING_PREFIX)/lib -Wl,--rpath,$(FFMPEG_PREFIX)/lib + +# Re-use all default ffmpeg mandatory libraries +FFMPEG_LIBS = libavcodec.pc +FFMPEG_LIBS += libavfilter.pc +FFMPEG_LIBS += libavformat.pc +FFMPEG_LIBS += libpostproc.pc +FFMPEG_LIBS += libavutil.pc +FFMPEG_LIBS += libswresample.pc +FFMPEG_LIBS += libswscale.pc +endif + +# call-up pre-depend to prepare the shared ffmpeg build environment +PRE_DEPEND_TARGET = ffmpeg_pre_depend + +else +BUILD_DEPENDS += cross/$(PYTHON_PACKAGE) +CMAKE_RPATH = +endif + +include ../../mk/spksrc.videodriver.mk + +.PHONY: ffmpeg_pre_depend + +ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH)) +# Also call-up videodriver pre-depend for remaining dependencies +ffmpeg_pre_depend: videodrv_pre_depend +else +ffmpeg_pre_depend: +endif + @$(MSG) "*****************************************************" + @$(MSG) "*** Use existing shared objects from ffmpeg $(FFMPEG_VERSION)" + @$(MSG) "*** PATH: $(FFMPEG_PACKAGE_ROOT)" + @$(MSG) "*****************************************************" + @mkdir -p $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/ + @$(foreach lib,$(FFMPEG_LIBS),ln -sf $(FFMPEG_STAGING_PREFIX)/lib/pkgconfig/$(lib) $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/ ;) + @$(foreach lib,$(MEDIA_LIBS),ln -sf $(FFMPEG_STAGING_PREFIX)/lib/pkgconfig/$(lib) $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/ ;) diff --git a/mk/spksrc.install.mk b/mk/spksrc.install.mk index 5cead824890..980344c7f99 100644 --- a/mk/spksrc.install.mk +++ b/mk/spksrc.install.mk @@ -71,6 +71,9 @@ install_target: $(PRE_INSTALL_TARGET) $(RUN) $(MAKE) $(INSTALL_MAKE_OPTIONS) post_install_target: $(INSTALL_TARGET) +ifeq ($(strip $(GCC_NO_DEBUG_INFO)),1) + $(RUN) $(MAKE) distclean +endif $(INSTALL_PLIST): find $(PLIST_SEARCH_PATH)/ \! -type d -printf '%P\n' | sed 's?^target/??g' | sort | \ diff --git a/mk/spksrc.tc.mk b/mk/spksrc.tc.mk index 2ae3ae4d169..b380edb7413 100644 --- a/mk/spksrc.tc.mk +++ b/mk/spksrc.tc.mk @@ -94,6 +94,9 @@ ifeq ($(findstring $(ARCH),$(ARM_ARCHS)),$(ARCH)) else ifeq ($(findstring $(ARCH),$(i686_ARCHS) $(x64_ARCHS)),$(ARCH)) @echo "set(ARCH $(CMAKE_ARCH))" endif + @echo + @echo "# Disable developer warnings" ; \ + echo 'set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS ON CACHE BOOL "Disable developer warnings")' @echo @echo "# define toolchain location (used with CMAKE_TOOLCHAIN_PKG)" ; \ echo "set(_CMAKE_TOOLCHAIN_LOCATION $(_CMAKE_TOOLCHAIN_LOCATION))" ; \ diff --git a/mk/spksrc.videodriver.mk b/mk/spksrc.videodriver.mk new file mode 100644 index 00000000000..46f2cfb5c8c --- /dev/null +++ b/mk/spksrc.videodriver.mk @@ -0,0 +1,58 @@ +### +### Reuse videodriver libraries +### + +# Set videodriver package name +ifeq ($(strip $(VIDEODRV_PACKAGE)),) +export VIDEODRV_PACKAGE = synocli-videodriver +endif + +# set default spk/synocli-videodriver path to use +VIDEODRV_PACKAGE_ROOT = $(realpath $(CURDIR)/../../spk/$(VIDEODRV_PACKAGE)/work-$(ARCH)-$(TCVERSION)) + +include ../../mk/spksrc.archs.mk + +ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH)) + +# Set videodriver installtion prefix directory variables +ifeq ($(strip $(VIDEODRV_STAGING_PREFIX)),) +export VIDEODRV_PREFIX = /var/packages/$(VIDEODRV_PACKAGE)/target +export VIDEODRV_STAGING_PREFIX = $(realpath $(VIDEODRV_PACKAGE_ROOT)/install/$(VIDEODRV_PREFIX)) +endif + +# set build flags including ld to rewrite for the library path +# used to access videodrv package provide libraries at destination +ifneq ($(strip $(VIDEODRV_STAGING_PREFIX)),) +export ADDITIONAL_CFLAGS += -I$(VIDEODRV_STAGING_PREFIX)/include +export ADDITIONAL_CPPFLAGS += -I$(VIDEODRV_STAGING_PREFIX)/include +export ADDITIONAL_CXXFLAGS += -I$(VIDEODRV_STAGING_PREFIX)/include +export ADDITIONAL_LDFLAGS += -L$(VIDEODRV_STAGING_PREFIX)/lib +export ADDITIONAL_LDFLAGS += -Wl,--rpath-link,$(VIDEODRV_STAGING_PREFIX)/lib -Wl,--rpath,$(VIDEODRV_PREFIX)/lib + +# Re-use all default videodrv mandatory libraries +VIDEODRV_LIBS := $(wildcard $(VIDEODRV_STAGING_PREFIX)/lib/pkgconfig/*.pc) +endif + +# Re-use all videodrv dependencies and mark as already done +VIDEODRV_DEPENDS := $(foreach cross,$(foreach pkg_name,$(shell $(MAKE) dependency-list -C $(realpath $(VIDEODRV_PACKAGE_ROOT)/../) 2>/dev/null | grep ^$(VIDEODRV_PACKAGE) | cut -f2 -d:),$(shell sed -n 's/^PKG_NAME = \(.*\)/\1/p' $(realpath $(CURDIR)/../../$(pkg_name)/Makefile))),$(wildcard $(VIDEODRV_PACKAGE_ROOT)/.$(cross)-*_done)) + +# call-up pre-depend to prepare the shared videodrv build environment + +ifeq ($(strip $(PRE_DEPEND_TARGET)),) +PRE_DEPEND_TARGET = videodrv_pre_depend +endif + +# end ifeq $(x64_ARCHS) +endif + +include ../../mk/spksrc.spk.mk + +.PHONY: videodrv_pre_depend +videodrv_pre_depend: + @$(MSG) "*****************************************************" + @$(MSG) "*** Use existing shared objects from videodrv $(VIDEODRV_VERSION)" + @$(MSG) "*** PATH: $(VIDEODRV_PACKAGE_ROOT)" + @$(MSG) "*****************************************************" + @mkdir -p $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/ + @$(foreach lib,$(VIDEODRV_LIBS),ln -sf $(lib) $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/ ;) + @$(foreach _done,$(VIDEODRV_DEPENDS), ln -sf $(_done) $(WORK_DIR) ;) diff --git a/native/llvm-14.0-build/Makefile b/native/llvm-14.0-build/Makefile index 1fa5a0244a1..c358c8e1776 100644 --- a/native/llvm-14.0-build/Makefile +++ b/native/llvm-14.0-build/Makefile @@ -15,13 +15,12 @@ PKG_DIR = $(PKG_NAME)-project-$(PKG_VERS).src # # The main reason to build llvm from source is, that other prebuilt packages # do not contain the binary "clang-tblgen" that is mandatory to build cross/llvm-14.0. -# DEPENDS = HOMEPAGE = https://llvm.org/ COMMENT = The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. -LICENSE = Apache v2.0 with LLVM Exceptions +LICENSE = Apache License v2.0 with LLVM Exceptions POST_INSTALL_TARGET = llvm_post_install CMAKE_USE_NINJA = 1 diff --git a/spk/chromaprint/Makefile b/spk/chromaprint/Makefile index 4130791e8c3..46b83541ccc 100644 --- a/spk/chromaprint/Makefile +++ b/spk/chromaprint/Makefile @@ -3,39 +3,20 @@ SPK_VERS = 1.5.2 SPK_REV = 21 SPK_ICON = src/chromaprint.png +FFMPEG_PACKAGE = ffmpeg6 DEPENDS = cross/$(SPK_NAME) +SPK_DEPENDS = $(FFMPEG_PACKAGE) STARTABLE = no MAINTAINER = ymartin59 DESCRIPTION = Chromaprint is the core component of the AcoustID project. It\'s a client-side library that implements a custom algorithm for extracting fingerprints from any audio source. DISPLAY_NAME = Chromaprint -CHANGELOG = "1. Update to latest git hash 1.5.2 (aa67c95)
2. Update to using ffmpeg5 version 5.1.5" +CHANGELOG = "1. Version 1.5.1 + Arch Linux compatibility patches
2. 2. Update to FFMPEG 6.0.1 using new synocli-videodriver package" HOMEPAGE = https://acoustid.org/chromaprint LICENSE = LGPL2.1+ -# Reuse FFmpeg libraries -export FFMPEG_VERSION = 5 -export FFMPEG_DIR = $(realpath $(shell pwd)/../ffmpeg$(FFMPEG_VERSION)/work-$(ARCH)-$(TCVERSION)/install/var/packages/ffmpeg$(subst 4,,$(FFMPEG_VERSION))/target) - -ifneq ($(wildcard $(FFMPEG_DIR)),) -export ADDITIONAL_LDFLAGS = -Wl,--rpath-link,$(FFMPEG_DIR)/lib -Wl,--rpath,/var/packages/ffmpeg$(subst 4,,$(FFMPEG_VERSION))/target/lib -PRE_DEPEND_TARGET = chromaprint_pre_depend -SPK_DEPENDS := "ffmpeg$(subst 4,,$(FFMPEG_VERSION))>$(shell sed -n 's/^SPK_VERS = \(.*\)/\1/p' $(shell pwd)/../ffmpeg$(FFMPEG_VERSION)/Makefile | cut -c -3)" -endif - SPK_COMMANDS = bin/fpcalc -include ../../mk/spksrc.spk.mk - -.PHONY: chromaprint_pre_depend - -# From library detection at cmake/modules/FindFFmpeg.cmake -FFMPEG_LIBS = libavcodec.pc -FFMPEG_LIBS += libavformat.pc -FFMPEG_LIBS += libavutil.pc - -chromaprint_pre_depend: - mkdir -p $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/ - $(foreach lib,$(FFMPEG_LIBS),ln -sf $(FFMPEG_DIR)/lib/pkgconfig/$(lib) $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/ ;) +include ../../mk/spksrc.ffmpeg.mk diff --git a/spk/comskip/Makefile b/spk/comskip/Makefile index 18fa5076a3e..3029cf522cd 100644 --- a/spk/comskip/Makefile +++ b/spk/comskip/Makefile @@ -1,16 +1,18 @@ SPK_NAME = comskip SPK_VERS = 0.82.010 -SPK_REV = 11 +SPK_REV = 12 SPK_ICON = src/comskip.png +FFMPEG_PACKAGE = ffmpeg5 DEPENDS = cross/$(SPK_NAME) +SPK_DEPENDS = $(FFMPEG_PACKAGE) STARTABLE = no MAINTAINER = SynoCommunity DESCRIPTION = Comskip is a free mpeg commercial detector. Read the wiki on how to use and configure it. DISPLAY_NAME = Comskip -CHANGELOG = "1. Update to latest git hash from June 7th 2024
2. Migrate to using ffmpeg5 version 5.1.5" +CHANGELOG = "1. Update to latest git hash from June 7th 2024
2. Migrate to using ffmpeg5 version 5.1.5 using new synocli-videodriver package" HOMEPAGE = https://www.kaashoek.com/comskip/ LICENSE = LGPL @@ -20,29 +22,9 @@ SPK_COMMANDS = bin/comskip POST_STRIP_TARGET = comskip_extra_install -# Reuse FFmpeg libraries -export FFMPEG_VERSION = 5 -export FFMPEG_DIR = $(realpath $(shell pwd)/../ffmpeg$(FFMPEG_VERSION)/work-$(ARCH)-$(TCVERSION)/install/var/packages/ffmpeg$(subst 4,,$(FFMPEG_VERSION))/target) +include ../../mk/spksrc.ffmpeg.mk -ifneq ($(wildcard $(FFMPEG_DIR)),) -export ADDITIONAL_LDFLAGS = -Wl,--rpath-link,$(FFMPEG_DIR)/lib -Wl,--rpath,/var/packages/ffmpeg/target$(subst 4,,$(FFMPEG_VERSION))/lib -PRE_DEPEND_TARGET = comskip_pre_depend -SPK_DEPENDS := "ffmpeg$(subst 4,,$(FFMPEG_VERSION))>$(shell sed -n 's/^SPK_VERS = \(.*\)/\1/p' $(shell pwd)/../ffmpeg$(FFMPEG_VERSION)/Makefile | cut -c -3)" -endif - -include ../../mk/spksrc.spk.mk - -.PHONY: comskip_pre_depend comskip_extra_install - -FFMPEG_LIBS = libswresample.pc -FFMPEG_LIBS += libavutil.pc -FFMPEG_LIBS += libavformat.pc -FFMPEG_LIBS += libavcodec.pc -FFMPEG_LIBS += libswscale.pc - -comskip_pre_depend: - mkdir -p $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/ - $(foreach lib,$(FFMPEG_LIBS),ln -sf $(FFMPEG_DIR)/lib/pkgconfig/$(lib) $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/ ;) +.PHONY: comskip_extra_install comskip_extra_install: install -m 755 -d $(STAGING_DIR)/var diff --git a/spk/ffmpeg5/Makefile b/spk/ffmpeg5/Makefile index da14e9c26c4..8b4025b99e8 100644 --- a/spk/ffmpeg5/Makefile +++ b/spk/ffmpeg5/Makefile @@ -2,8 +2,9 @@ SPK_NAME = ffmpeg5 SPK_VERS = 5.1.5 SPK_REV = 4 SPK_ICON = src/ffmpeg.png -CHANGELOG = "1. Update to version 5.1.5
2. Update Intel Media Driver 2024Q1 Release (DSM7 only)
3. Update jellyfin and libsvtav1 patches along with multiple dependencies
4. Update to latest version of x264 (fix for \#6176) - rev4 UNRELEASED" +CHANGELOG = "1. Update to version 5.1.5
2. Update Jellyfin upstream patches
3. Update Intel Media Driver 2024Q2 Release (DSM7 only)
4. Enable OpenCL on Intel platforms (DSM7 only)
5. Update to latest version of x264 (fix for \#6176)
6. Now using new synocli-videodriver package" +SPK_DEPENDS = "synocli-videodriver" DEPENDS = cross/$(SPK_NAME) MAINTAINER = th0ma7 @@ -32,7 +33,7 @@ SERVICE_SETUP = src/service-setup.sh SPK_COMMANDS += bin/vainfo endif -include ../../mk/spksrc.spk.mk +include ../../mk/spksrc.videodriver.mk .PHONY: $(SPK_NAME)_extra_install $(SPK_NAME)_extra_install: diff --git a/spk/ffmpeg5/TODO b/spk/ffmpeg5/TODO index e11f7da6182..2212c43c610 100644 --- a/spk/ffmpeg5/TODO +++ b/spk/ffmpeg5/TODO @@ -31,6 +31,5 @@ Not to be enabled: --enable-libjack --enable-libpulse --enable-openal - --enable-opencl --enable-opengl --enable-sdl2 diff --git a/spk/ffmpeg6/Makefile b/spk/ffmpeg6/Makefile index f872a3d9637..1567fef887d 100644 --- a/spk/ffmpeg6/Makefile +++ b/spk/ffmpeg6/Makefile @@ -2,8 +2,9 @@ SPK_NAME = ffmpeg6 SPK_VERS = 6.0.1 SPK_REV = 4 SPK_ICON = src/ffmpeg.png -CHANGELOG = "1. Update to version 6.0.1
2. Update Jellyfin upstream patches
3. Update Intel Media Driver 2024Q1 Release (DSM7 only)
4. Migrate DSM7 from MFX to Intel Video Processing Library (Intel-VPL)
5. Update to latest version of x264 (fix for \#6176) - rev4 UNRELEASED" +CHANGELOG = "1. Update to version 6.0.1
2. Update Jellyfin upstream patches
3. Update Intel Media Driver 2024Q2 Release (DSM7 only)
4. Revert DSM7 to MFX intead of Intel Video Processing Library (Intel-VPL) as unsupported by Jellyfin
5. Enable OpenCL on Intel platforms (DSM7 only)
6. Update to latest version of x264 (fix for \#6176)
6. Now using new synocli-videodriver package" +SPK_DEPENDS = "synocli-videodriver" DEPENDS = cross/$(SPK_NAME) MAINTAINER = th0ma7 @@ -32,7 +33,7 @@ SERVICE_SETUP = src/service-setup.sh SPK_COMMANDS += bin/vainfo endif -include ../../mk/spksrc.spk.mk +include ../../mk/spksrc.videodriver.mk .PHONY: $(SPK_NAME)_extra_install $(SPK_NAME)_extra_install: diff --git a/spk/ffmpeg6/TODO b/spk/ffmpeg6/TODO index e11f7da6182..2212c43c610 100644 --- a/spk/ffmpeg6/TODO +++ b/spk/ffmpeg6/TODO @@ -31,6 +31,5 @@ Not to be enabled: --enable-libjack --enable-libpulse --enable-openal - --enable-opencl --enable-opengl --enable-sdl2 diff --git a/spk/synocli-videodriver/Makefile b/spk/synocli-videodriver/Makefile new file mode 100644 index 00000000000..6490068a0f8 --- /dev/null +++ b/spk/synocli-videodriver/Makefile @@ -0,0 +1,48 @@ +SPK_NAME = synocli-videodriver +SPK_VERS = 1.0 +SPK_REV = 1 +SPK_ICON = src/SynoPackagegreen-videodriver.png +CHANGELOG = "Initial version providing Intel Media Driver 2024Q2 Release" + +MAINTAINER = th0ma7 +DESCRIPTION = "Provides video driver support for Intel GPU acceleration including OpenCL \(DSM7\)." +DISPLAY_NAME = SynoCli Video Drivers +STARTABLE = no + +HOMEPAGE = https://github.com/intel/compute-runtime +LICENSE = MIT license + +REQUIRED_MIN_DSM = 6.2.4 +UNSUPPORTED_ARCHS = $(ARM_ARCHS) $(PPC_ARCHS) $(i686_ARCHS) + +SERVICE_USER = auto +VIDEODRIVER = on + +SPK_COMMANDS = bin/vainfo +SPK_COMMANDS = bin/clinfo + +DEPENDS = cross/libva cross/libva-utils +DEPENDS += cross/intel-vaapi-driver +DEPENDS += cross/intel-media-driver cross/intel-mediasdk + +include ../../mk/spksrc.common.mk + +# Enable OpenCL only on DSM >= 7.1 +ifeq ($(call version_ge, ${TCVERSION}, 7.1),1) +CHANGELOG += "Intel Level-Zero 1.17.42, Intel Graphics Compiler \(IGC\) 1.0.17537.20, Intel Compute Runtime 24.31.30508.7" +DEPENDS += cross/intel-level-zero +DEPENDS += cross/intel-graphics-compiler +DEPENDS += cross/intel-compute-runtime +DEPENDS += cross/ocl-icd +DEPENDS += cross/clinfo +endif + +# Enable Intel libVPL only on DSM >= 7.1 +# -->> can not use libmfx and libvpl together in ffmpeg +# Jellyfin requires QSV provided by libmfx +ifeq ($(call version_ge, ${TCVERSION}, 7),1) +CHANGELOG += " and Intel Video Processing Library \(Intel VPL\) 2.13.0" +DEPENDS += cross/intel-libvpl cross/intel-libvpl-tools +endif + +include ../../mk/spksrc.spk.mk diff --git a/spk/synocli-videodriver/src/SynoPackagegreen-videodriver.png b/spk/synocli-videodriver/src/SynoPackagegreen-videodriver.png new file mode 100644 index 00000000000..32325d7824e Binary files /dev/null and b/spk/synocli-videodriver/src/SynoPackagegreen-videodriver.png differ diff --git a/spk/synocli-videodriver/src/SynoPackagegreen-videodriver.svg b/spk/synocli-videodriver/src/SynoPackagegreen-videodriver.svg new file mode 100644 index 00000000000..16e2a711d78 --- /dev/null +++ b/spk/synocli-videodriver/src/SynoPackagegreen-videodriver.svg @@ -0,0 +1,227 @@ + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + video drivers diff --git a/spk/tvheadend/Makefile b/spk/tvheadend/Makefile index 3915b74bf9f..adf5aee1974 100644 --- a/spk/tvheadend/Makefile +++ b/spk/tvheadend/Makefile @@ -1,10 +1,10 @@ SPK_NAME = tvheadend SPK_SHORT_VERS = 4.3 -SPK_GIT_HASH = 128d686 -SPK_GIT_DATE = 20240623 +SPK_GIT_HASH = 9ac57a0 +SPK_GIT_DATE = 20240904 SPK_VERS = $(SPK_SHORT_VERS).$(SPK_GIT_DATE) TVH_VERS = $(SPK_SHORT_VERS)~$(SPK_GIT_HASH) -SPK_REV = 37 +SPK_REV = 38 SPK_ICON = src/tvheadend.png DSM_UI_DIR = app @@ -13,7 +13,8 @@ DSM_UI_DIR = app # 000-fix-version.patch from cross/tvheadend export TVH_VERS -SPK_DEPENDS = 'python311>=3.11.4-7' +FFMPEG_PACKAGE = ffmpeg6 +SPK_DEPENDS = 'python311>=3.11.4-7:$(FFMPEG_PACKAGE)' WHEELS = src/requirements-pure.txt @@ -26,7 +27,7 @@ DESCRIPTION = Tvheadend is a TV streaming server and recorder for Linux, FreeBSD DESCRIPTION_FRE = Tvheadend est un serveur de streaming et enregistreur TV pour Linux, FreeBSD et Android prenant en charge DVB-S, DVB-S2, DVB-C, DVB-T, ATSC, ISDB-T, IPTV, SAT IP et HDHomeRun comme sources d\'entrée. Tvheadend offre le streaming HTTP, HTSP et SAT IP. DISPLAY_NAME = Tvheadend STARTABLE = yes -CHANGELOG = "1. Update to latest git version 128d686 as of June 23rd 2024
2. Update to FFMPEG 6.0.1
3. Update libhdhomerun to version 20231214
4. Migrate to using python 3.11 and openssl 3.
5. Update pngquant to v3.0.3." +CHANGELOG = "1. Update to latest git version 9ac57a0 as of Sept. 4th 2024
2. Update to FFMPEG 6.0.1 using new synocli-videodriver package" HOMEPAGE = https://tvheadend.org/ LICENSE = GPL v3 @@ -47,54 +48,4 @@ SERVICE_PORT_TITLE = Tvheadend(HTTP) # Admin link ADMIN_PORT = ${SERVICE_PORT} -# Reuse ffmpeg libraries -export FFMPEG_VERSION = 6 -export FFMPEG_DIR = $(realpath $(shell pwd)/../ffmpeg$(FFMPEG_VERSION)/work-$(ARCH)-$(TCVERSION)/install/var/packages/ffmpeg$(subst 4,,$(FFMPEG_VERSION))/target) - -ifneq ($(wildcard $(FFMPEG_DIR)),) -export ADDITIONAL_LDFLAGS = -Wl,--rpath-link,$(FFMPEG_DIR)/lib -Wl,--rpath,/var/packages/ffmpeg$(subst 4,,$(FFMPEG_VERSION))/target/lib -PRE_DEPEND_TARGET = tvheadend_pre_depend -SPK_DEPENDS := $(SPK_DEPENDS)':ffmpeg$(subst 4,,$(FFMPEG_VERSION))>$(shell sed -n 's/^SPK_VERS = \(.*\)/\1/p' $(shell pwd)/../ffmpeg$(FFMPEG_VERSION)/Makefile | cut -c -3)' -endif - -include ../../mk/spksrc.spk.mk - -.PHONY: tvheadend_pre_depend tvheadend_extra_install - -# Use FFMPEG package shared libraries -FFMPEG_LIBS = libavfilter.pc -FFMPEG_LIBS += libpostproc.pc -FFMPEG_LIBS += libswresample.pc -FFMPEG_LIBS += libswscale.pc -FFMPEG_LIBS += libavutil.pc -FFMPEG_LIBS += libavformat.pc -FFMPEG_LIBS += libavcodec.pc - -# Use other media libraries through FFMPEG package shared libraries -MEDIA_LIBS = fdk-aac.pc -MEDIA_LIBS += ogg.pc -MEDIA_LIBS += opus.pc -MEDIA_LIBS += theoradec.pc -MEDIA_LIBS += theoraenc.pc -MEDIA_LIBS += theora.pc -MEDIA_LIBS += vorbisenc.pc -MEDIA_LIBS += vorbisfile.pc -MEDIA_LIBS += vorbis.pc -MEDIA_LIBS += vpx.pc -MEDIA_LIBS += x264.pc -MEDIA_LIBS += x265.pc - -# Add Intel VAAPI libraries on Intel platforms -ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH)) -VAAPI_LIBS = libdrm.pc -VAAPI_LIBS += libdrm_intel.pc -VAAPI_LIBS += libva.pc -VAAPI_LIBS += libva-drm.pc -VAAPI_LIBS += pciaccess.pc -endif - -tvheadend_pre_depend: - mkdir -p $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/ - $(foreach lib,$(FFMPEG_LIBS),ln -sfT $(FFMPEG_DIR)/lib/pkgconfig/$(lib) $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/$(lib) ;) - $(foreach lib,$(MEDIA_LIBS),ln -sfT $(FFMPEG_DIR)/lib/pkgconfig/$(lib) $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/$(lib) ;) - $(foreach lib,$(VAAPI_LIBS),ln -sfT $(FFMPEG_DIR)/lib/pkgconfig/$(lib) $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/$(lib) ;) +include ../../mk/spksrc.ffmpeg.mk