diff --git a/CMakeLists.txt b/CMakeLists.txt index 3380529627ea..38ef6d9b9404 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,6 @@ include(CheckCXXSymbolExists) # Make our custom helpers available throughout the project via include(). list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) -include(BundleStatic) include(HalideFeatures) include(HalideGeneratorHelpers) include(HalidePackageConfigHelpers) @@ -223,14 +222,9 @@ find_package(PNG) ## # Optional features. These settings are defined early so that subdirectories see a consistent view -Halide_feature(Halide_BUNDLE_STATIC "Bundle Halide's static dependencies" OFF ADVANCED - DEPENDS NOT BUILD_SHARED_LIBS) - Halide_feature(Halide_ENABLE_EXCEPTIONS "Enable exceptions in Halide" ON) Halide_feature(Halide_ENABLE_RTTI "Enable RTTI in Halide" ON DEPENDS LLVM_ENABLE_RTTI) -Halide_feature(Halide_BUNDLE_STATIC "Bundle Halide's static dependencies" OFF ADVANCED - DEPENDS NOT BUILD_SHARED_LIBS) Halide_feature(WITH_AUTOSCHEDULERS "Build the Halide autoschedulers" ON DEPENDS BUILD_SHARED_LIBS) diff --git a/CMakePresets.json b/CMakePresets.json index dc96931dcedb..9104a9d2729f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -212,7 +212,7 @@ } }, { - "name": "package-unix-shared", + "name": "package-unix", "inherits": "package", "displayName": "Package UNIX shared libs", "description": "Build for packaging UNIX shared libraries.", @@ -221,17 +221,6 @@ "BUILD_SHARED_LIBS": "YES" } }, - { - "name": "package-unix-static", - "inherits": "package", - "displayName": "Package UNIX static libs", - "description": "Build for packaging UNIX static libraries.", - "binaryDir": "static-Release", - "cacheVariables": { - "BUILD_SHARED_LIBS": "NO", - "Halide_BUNDLE_STATIC": "YES" - } - }, { "name": "linux-x64-asan", "inherits": "ci", diff --git a/README.md b/README.md index ddd4428c2373..2c73deaf3aed 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Halide is a programming language designed to make it easier to write high-performance image and array processing code on modern machines. Halide currently targets: -- CPU architectures: X86, ARM, Hexagon, PowerPC, RISC-V +- CPU architectures: X86, ARM, Hexagon, PowerPC, RISC-V, WebAssembly - Operating systems: Linux, Windows, macOS, Android, iOS, Qualcomm QuRT - GPU Compute APIs: CUDA, OpenCL, Apple Metal, Microsoft Direct X 12, Vulkan @@ -86,7 +86,7 @@ need to adjust compiler options accordingly if you're using an older XCode which does not default to libc++. We use a recent Ubuntu LTS to build the Linux releases; if your distribution is -too old, it might not have the requisite glibc. +too old, it might not have the requisite glibc. Nightly builds of Halide and the LLVM versions we use in CI are also available at https://buildbot.halide-lang.org/ @@ -384,7 +384,7 @@ Now you should be able to just run `make` in the root directory of the Halide source tree. `make run_tests` will run the JIT test suite, and `make test_apps` will make sure all the apps compile and run (but won't check their output). -When building the tests, you can set the AOT compilation target with the +When building the tests, you can set the AOT compilation target with the `HL_TARGET` environment variable. ### Building Halide out-of-tree with make diff --git a/cmake/BundleStatic.cmake b/cmake/BundleStatic.cmake deleted file mode 100644 index d0f7a310fa8f..000000000000 --- a/cmake/BundleStatic.cmake +++ /dev/null @@ -1,124 +0,0 @@ -cmake_minimum_required(VERSION 3.28) - -## -# Merge all the static library dependencies of TARGET into the library as a -# POST_BUILD step. - -function(_bundle_static_replace VAR BEFORE AFTER) - string(REPLACE "$<" "$\\\\<" AFTER "${AFTER}") - string(REPLACE ">" "$" AFTER "${AFTER}") - string(REPLACE "," "$" AFTER "${AFTER}") - string(REPLACE ";" "$" AFTER "${AFTER}") - set("${VAR}" "$") - set("${VAR}" "$") - set("${VAR}" "$" PARENT_SCOPE) -endfunction() - -function(_bundle_static_check_output VAR) - execute_process(COMMAND ${ARGN} OUTPUT_VARIABLE "${VAR}" RESULT_VARIABLE "_${VAR}" ERROR_QUIET) - if (_${VAR}) - set("${VAR}" "") - endif () - set("${VAR}" "${${VAR}}" PARENT_SCOPE) -endfunction() - -function(_bundle_static_is_apple_libtool result_var item) - _bundle_static_check_output(version_info "${item}" -V) - if (NOT version_info MATCHES "Apple,? Inc\\.") - set(${result_var} 0 PARENT_SCOPE) - endif () -endfunction() - -function(bundle_static TARGET) - get_property(type TARGET "${TARGET}" PROPERTY TYPE) - if (NOT type STREQUAL "STATIC_LIBRARY") - return() - endif () - - # The following code is quite subtle. First, it "recursively" (up to a depth - # limit) expands all the INTERFACE_LINK_LIBRARIES of the TARGET. Once the - # full set of library dependencies has been determined, it filters just - # the static libraries and replaces them with their on-disk locations. - - # Start with the $> dependencies of - # the target. These are the privately-linked static and interface libraries - # that the user intends to delete upon export. - set(cmd "$") - set(cmd "$") - - # Repeatedly expand and flatten: T ~> T, T.INTERFACE_LINK_LIBRARIES - foreach (i RANGE 5) - _bundle_static_replace( - cmd "(.+)" "$<$:\\1;$>" - ) - set(cmd "$>") - endforeach () - - # Ensure we are only including targets - _bundle_static_replace(cmd "(.+)" "$") - - # Rewrite T ~> T^T.TYPE -- we use ^ as a delimiter - _bundle_static_replace(cmd "(.+)" "\\1^$") - set(cmd "$") - - # Select exactly the set of static libraries - set(cmd "$") - - # Rewrite T^... ~> $ - _bundle_static_replace(cmd "^([^^]+)\\^.+$" "$") - - # Rename the target to target.tmp - add_custom_command( - TARGET "${TARGET}" POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E rename "$" "$.tmp" - VERBATIM - ) - - # Finally merge everything together using the platform tool. - find_program(LIB lib.exe HINTS "${CMAKE_AR}") - if (WIN32 AND LIB) - add_custom_command( - TARGET "${TARGET}" POST_BUILD - COMMAND "${LIB}" "/out:$" "$.tmp" "${cmd}" - COMMAND_EXPAND_LISTS - VERBATIM - ) - return() - endif () - - find_program(LIBTOOL libtool VALIDATOR _bundle_static_is_apple_libtool) - if (APPLE AND LIBTOOL) - add_custom_command( - TARGET "${TARGET}" POST_BUILD - COMMAND "${LIBTOOL}" -static -o "$" "$.tmp" "${cmd}" - COMMAND_EXPAND_LISTS - VERBATIM - ) - return() - endif () - - _bundle_static_check_output(version_info "${CMAKE_AR}" V) - if (version_info MATCHES "GNU|LLVM") - string(CONFIGURE [[ - create $ - addlib $.tmp - $, - > - save - end - ]] mri_script) - string(REGEX REPLACE "(^|\n) +" "\\1" mri_script "${mri_script}") - - file(GENERATE OUTPUT "fuse-${TARGET}.mri" - CONTENT "${mri_script}" TARGET "${TARGET}") - - add_custom_command( - TARGET "${TARGET}" POST_BUILD - COMMAND "${CMAKE_AR}" -M < "${CMAKE_CURRENT_BINARY_DIR}/fuse-${TARGET}.mri" - VERBATIM - ) - return() - endif () - - message(FATAL_ERROR "bundle_static_libs not implemented for the present toolchain") -endfunction() diff --git a/doc/BuildingHalideWithCMake.md b/doc/BuildingHalideWithCMake.md index 5f39842e5053..f2de2169d972 100644 --- a/doc/BuildingHalideWithCMake.md +++ b/doc/BuildingHalideWithCMake.md @@ -420,7 +420,6 @@ compiled. | Option | Default | Description | |------------------------------------------|-----------------------|---------------------------------------------------------------------------------------------------| | [`BUILD_SHARED_LIBS`][build_shared_libs] | `ON` | Standard CMake variable that chooses whether to build as a static or shared library. | -| `Halide_BUNDLE_STATIC` | `OFF` | When building Halide as a static library, merge static library dependencies into libHalide.a. | | `Halide_LLVM_SHARED_LIBS` | `OFF` | Link to the shared version of LLVM. Not available on Windows. | | `Halide_ENABLE_RTTI` | _inherited from LLVM_ | Enable RTTI when building Halide. Recommended to be set to `ON` | | `Halide_ENABLE_EXCEPTIONS` | `ON` | Enable exceptions when building Halide | diff --git a/packaging/common/Description.txt b/packaging/common/Description.txt index 7f11935edb42..fb9daee7628b 100644 --- a/packaging/common/Description.txt +++ b/packaging/common/Description.txt @@ -1,10 +1,10 @@ - Halide is a programming language designed to make it easier to write - high-performance image and array processing code on modern machines. Halide - currently targets: +Halide is a programming language designed to make it easier to write +high-performance image and array processing code on modern machines. Halide +currently targets: - * CPU architectures: X86, ARM, Hexagon, PowerPC, RISC-V, WebAssembly - * Operating systems: Linux, Windows, macOS, Android, iOS, Qualcomm QuRT - * GPU APIs: CUDA, OpenCL, Apple Metal, Direct X 12 +- CPU architectures: X86, ARM, Hexagon, PowerPC, RISC-V, WebAssembly +- Operating systems: Linux, Windows, macOS, Android, iOS, Qualcomm QuRT +- GPU Compute APIs: CUDA, OpenCL, Apple Metal, Microsoft Direct X 12, Vulkan Rather than being a standalone programming language, Halide is embedded in C++. This means you write C++ code that builds an in-memory representation of a diff --git a/packaging/tgz/config.cmake b/packaging/tgz/config.cmake deleted file mode 100644 index 4f751bb03e02..000000000000 --- a/packaging/tgz/config.cmake +++ /dev/null @@ -1,15 +0,0 @@ -include("shared-Release/CPackConfig.cmake") - -set(CPACK_COMPONENTS_HALIDE_RUNTIME Halide_Runtime) -set(CPACK_COMPONENTS_HALIDE_DEVELOPMENT Halide_Development) -set(CPACK_COMPONENTS_HALIDE_DOCUMENTATION Halide_Documentation) - -set(CPACK_COMPONENTS_ALL Halide_Runtime Halide_Development Halide_Documentation) - -set(CPACK_INSTALL_CMAKE_PROJECTS - # We don't package debug binaries on Unix systems. Our developers - # don't use them and LLVM in debug mode is next to unusable, too. - # static-Debug Halide ALL / - # shared-Debug Halide ALL / - static-Release Halide ALL / - shared-Release Halide ALL /) \ No newline at end of file diff --git a/packaging/tgz/package.sh b/packaging/tgz/package.sh index 39f5ab32ea8d..d802fed7be03 100755 --- a/packaging/tgz/package.sh +++ b/packaging/tgz/package.sh @@ -9,14 +9,11 @@ halide_build_root=$(realpath "$2") [ -z "$halide_source" ] && echo "Usage: $0 " && exit [ -z "$halide_build_root" ] && echo "Usage: $0 " && exit -cmake --preset=package-unix-shared -S "$halide_source" -B "$halide_build_root/shared-Release" \ - "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" -cmake --preset=package-unix-static -S "$halide_source" -B "$halide_build_root/static-Release" \ +cmake --preset=package-unix -S "$halide_source" -B "$halide_build_root/shared-Release" \ "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" cmake --build "$halide_build_root/shared-Release" -cmake --build "$halide_build_root/static-Release" cd "$halide_build_root" -cpack -G TGZ -C Release --config "$halide_source/packaging/tgz/config.cmake" +cpack -G TGZ -C Release diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 557466c0d7e3..46f0baa46523 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -487,10 +487,6 @@ target_sources( FILES "${Halide_BINARY_DIR}/include/Halide.h" ) -if (Halide_BUNDLE_STATIC) - bundle_static(Halide) -endif () - ## # CodeGen backends ## @@ -499,11 +495,7 @@ endif () foreach (backend IN LISTS Halide_LLVM_COMPONENTS) string(TOUPPER "WITH_${backend}" definition) target_compile_definitions(Halide PRIVATE "${definition}") - if (Halide_BUNDLE_STATIC AND NOT Halide_LLVM_SHARED_LIBS) - target_link_libraries(Halide PRIVATE "$") - else () - target_link_libraries(Halide PRIVATE Halide_LLVM::${backend}) - endif () + target_link_libraries(Halide PRIVATE Halide_LLVM::${backend}) endforeach () # GPU backends @@ -538,9 +530,7 @@ if (WITH_SERIALIZATION) ) _Halide_pkgdep(flatbuffers) - if (Halide_BUNDLE_STATIC) - target_link_libraries(Halide PRIVATE "$") - elseif (Halide_USE_FETCHCONTENT AND NOT BUILD_SHARED_LIBS) + if (Halide_USE_FETCHCONTENT AND NOT BUILD_SHARED_LIBS) target_sources(Halide PRIVATE "$") target_link_libraries(Halide PRIVATE "$>") else () @@ -600,9 +590,7 @@ if (Halide_WASM_BACKEND STREQUAL "wabt") find_package(wabt 1.0.36 REQUIRED) _Halide_pkgdep(wabt) - if (Halide_BUNDLE_STATIC) - target_link_libraries(Halide PRIVATE "$") - elseif (Halide_USE_FETCHCONTENT AND NOT BUILD_SHARED_LIBS) + if (Halide_USE_FETCHCONTENT AND NOT BUILD_SHARED_LIBS) target_sources(Halide PRIVATE "$") target_link_libraries(Halide PRIVATE "$>") else () @@ -614,13 +602,7 @@ elseif (Halide_WASM_BACKEND STREQUAL "V8") find_package(V8 REQUIRED) _Halide_pkgdep(V8) target_compile_definitions(Halide PRIVATE WITH_V8) - - get_property(type TARGET V8::V8 PROPERTY TYPE) - if (Halide_BUNDLE_STATIC AND type STREQUAL "STATIC_LIBRARY") - target_link_libraries(Halide PRIVATE "$") - else () - target_link_libraries(Halide PRIVATE V8::V8) - endif () + target_link_libraries(Halide PRIVATE V8::V8) elseif (Halide_WASM_BACKEND) message(FATAL_ERROR "Unknown Halide_WASM_BACKEND `${Halide_WASM_BACKEND}`") endif ()