Skip to content

Commit

Permalink
Merge branch 'main' into xtensa-codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-johnson committed Jan 20, 2023
2 parents 2e9ae6a + c601e4e commit 4023640
Show file tree
Hide file tree
Showing 45 changed files with 243 additions and 357 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
cmake -G Ninja -S llvm-src/llvm -B llvm-build
-DCMAKE_BUILD_TYPE=Release
"-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64"
"-DLLVM_TARGETS_TO_BUILD=X86;ARM;NVPTX;AArch64;Mips;Hexagon;WebAssembly"
"-DLLVM_TARGETS_TO_BUILD=X86;ARM;NVPTX;AArch64;Hexagon;WebAssembly"
"-DLLVM_ENABLE_PROJECTS=clang;lld"
-DLLVM_ENABLE_ASSERTIONS=ON
-DLLVM_ENABLE_RTTI=ON
Expand Down
14 changes: 3 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ LLVM_CXX_FLAGS += -DLLVM_VERSION=$(LLVM_VERSION_TIMES_10)
WITH_X86 ?= $(findstring x86, $(LLVM_COMPONENTS))
WITH_ARM ?= $(findstring arm, $(LLVM_COMPONENTS))
WITH_HEXAGON ?= $(findstring hexagon, $(LLVM_COMPONENTS))
WITH_MIPS ?= $(findstring mips, $(LLVM_COMPONENTS))
WITH_RISCV ?= $(findstring riscv, $(LLVM_COMPONENTS))
WITH_AARCH64 ?= $(findstring aarch64, $(LLVM_COMPONENTS))
WITH_POWERPC ?= $(findstring powerpc, $(LLVM_COMPONENTS))
Expand All @@ -139,9 +138,6 @@ X86_LLVM_CONFIG_LIB=$(if $(WITH_X86), x86, )
ARM_CXX_FLAGS=$(if $(WITH_ARM), -DWITH_ARM, )
ARM_LLVM_CONFIG_LIB=$(if $(WITH_ARM), arm, )

MIPS_CXX_FLAGS=$(if $(WITH_MIPS), -DWITH_MIPS, )
MIPS_LLVM_CONFIG_LIB=$(if $(WITH_MIPS), mips, )

POWERPC_CXX_FLAGS=$(if $(WITH_POWERPC), -DWITH_POWERPC, )
POWERPC_LLVM_CONFIG_LIB=$(if $(WITH_POWERPC), powerpc, )

Expand Down Expand Up @@ -209,7 +205,6 @@ CXX_FLAGS += $(OPENCL_CXX_FLAGS)
CXX_FLAGS += $(METAL_CXX_FLAGS)
CXX_FLAGS += $(OPENGLCOMPUTE_CXX_FLAGS)
CXX_FLAGS += $(D3D12_CXX_FLAGS)
CXX_FLAGS += $(MIPS_CXX_FLAGS)
CXX_FLAGS += $(POWERPC_CXX_FLAGS)
CXX_FLAGS += $(INTROSPECTION_CXX_FLAGS)
CXX_FLAGS += $(EXCEPTIONS_CXX_FLAGS)
Expand Down Expand Up @@ -238,7 +233,6 @@ LLVM_STATIC_LIBFILES = \
$(METAL_LLVM_CONFIG_LIB) \
$(PTX_LLVM_CONFIG_LIB) \
$(AARCH64_LLVM_CONFIG_LIB) \
$(MIPS_LLVM_CONFIG_LIB) \
$(POWERPC_LLVM_CONFIG_LIB) \
$(HEXAGON_LLVM_CONFIG_LIB) \
$(AMDGPU_LLVM_CONFIG_LIB) \
Expand Down Expand Up @@ -433,7 +427,6 @@ SOURCE_FILES = \
CodeGen_Internal.cpp \
CodeGen_LLVM.cpp \
CodeGen_Metal_Dev.cpp \
CodeGen_MIPS.cpp \
CodeGen_OpenCL_Dev.cpp \
CodeGen_OpenGLCompute_Dev.cpp \
CodeGen_Posix.cpp \
Expand Down Expand Up @@ -738,7 +731,6 @@ HEADER_FILES = \
StrictifyFloat.h \
Substitute.h \
Target.h \
ThreadPool.h \
Tracing.h \
TrimNoOps.h \
Tuple.h \
Expand Down Expand Up @@ -796,7 +788,6 @@ RUNTIME_CPP_COMPONENTS = \
metal \
metal_objc_arm \
metal_objc_x86 \
mips_cpu_features \
module_aot_ref_count \
module_jit_ref_count \
msan \
Expand Down Expand Up @@ -857,7 +848,6 @@ RUNTIME_LL_COMPONENTS = \
arm \
arm_no_neon \
hvx_128 \
mips \
posix_math \
powerpc \
ptx_dev \
Expand Down Expand Up @@ -1624,7 +1614,7 @@ $(FILTERS_DIR)/autograd_grad.a: $(BIN_DIR)/autograd.generator $(BIN_MULLAPUDI201
# all have the form nested_externs_*).
$(FILTERS_DIR)/nested_externs_%.a: $(BIN_DIR)/nested_externs.generator
@mkdir -p $(@D)
$(CURDIR)/$< -g nested_externs_$* $(GEN_AOT_OUTPUTS) -o $(CURDIR)/$(FILTERS_DIR) target=$(TARGET)-no_runtime
$(CURDIR)/$< -g nested_externs_$* $(GEN_AOT_OUTPUTS) -o $(CURDIR)/$(FILTERS_DIR) target=$(TARGET)-no_runtime-user_context-c_plus_plus_name_mangling

# Similarly, gpu_multi needs two different kernels to test compilation caching.
# Also requies user-context.
Expand Down Expand Up @@ -2271,6 +2261,7 @@ install: $(LIB_DIR)/libHalide.a $(BIN_DIR)/libHalide.$(SHARED_EXT) $(INCLUDE_DIR
cp $(ROOT_DIR)/tools/halide_image_io.h $(PREFIX)/share/halide/tools
cp $(ROOT_DIR)/tools/halide_image_info.h $(PREFIX)/share/halide/tools
cp $(ROOT_DIR)/tools/halide_malloc_trace.h $(PREFIX)/share/halide/tools
cp $(ROOT_DIR)/tools/halide_thread_pool.h $(PREFIX)/share/halide/tools
ifeq ($(UNAME), Darwin)
install_name_tool -id $(PREFIX)/lib/libHalide.$(SHARED_EXT) $(PREFIX)/lib/libHalide.$(SHARED_EXT)
endif
Expand Down Expand Up @@ -2349,6 +2340,7 @@ $(DISTRIB_DIR)/lib/libHalide.$(SHARED_EXT): \
cp $(ROOT_DIR)/tools/halide_image_io.h $(DISTRIB_DIR)/tools
cp $(ROOT_DIR)/tools/halide_image_info.h $(DISTRIB_DIR)/tools
cp $(ROOT_DIR)/tools/halide_malloc_trace.h $(DISTRIB_DIR)/tools
cp $(ROOT_DIR)/tools/halide_thread_pool.h $(DISTRIB_DIR)/tools
cp $(ROOT_DIR)/tools/halide_trace_config.h $(DISTRIB_DIR)/tools
cp $(ROOT_DIR)/README*.md $(DISTRIB_DIR)
cp $(BUILD_DIR)/halide_config.* $(DISTRIB_DIR)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, MIPS, Hexagon, PowerPC, RISC-V
- CPU architectures: X86, ARM, Hexagon, PowerPC, RISC-V
- Operating systems: Linux, Windows, macOS, Android, iOS, Qualcomm QuRT
- GPU Compute APIs: CUDA, OpenCL, OpenGL Compute Shaders, Apple Metal, Microsoft
Direct X 12
Expand Down Expand Up @@ -138,7 +138,7 @@ Then build it like so:
```
% cmake -DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="clang;lld;clang-tools-extra" \
-DLLVM_TARGETS_TO_BUILD="X86;ARM;NVPTX;AArch64;Mips;Hexagon;WebAssembly" \
-DLLVM_TARGETS_TO_BUILD="X86;ARM;NVPTX;AArch64;Hexagon;WebAssembly" \
-DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON -DLLVM_BUILD_32_BITS=OFF \
-S llvm-project/llvm -B llvm-build
Expand Down Expand Up @@ -298,7 +298,7 @@ D:\> cmake -G Ninja ^
-DCMAKE_BUILD_TYPE=Release ^
-DLLVM_ENABLE_PROJECTS=clang;lld;clang-tools-extra ^
-DLLVM_ENABLE_TERMINFO=OFF ^
-DLLVM_TARGETS_TO_BUILD=X86;ARM;NVPTX;AArch64;Mips;Hexagon ^
-DLLVM_TARGETS_TO_BUILD=X86;ARM;NVPTX;AArch64;Hexagon ^
-DLLVM_ENABLE_ASSERTIONS=ON ^
-DLLVM_ENABLE_EH=ON ^
-DLLVM_ENABLE_RTTI=ON ^
Expand All @@ -313,7 +313,7 @@ D:\> cmake -G Ninja ^
-DCMAKE_BUILD_TYPE=Release ^
-DLLVM_ENABLE_PROJECTS=clang;lld;clang-tools-extra ^
-DLLVM_ENABLE_TERMINFO=OFF ^
-DLLVM_TARGETS_TO_BUILD=X86;ARM;NVPTX;AArch64;Mips;Hexagon ^
-DLLVM_TARGETS_TO_BUILD=X86;ARM;NVPTX;AArch64;Hexagon ^
-DLLVM_ENABLE_ASSERTIONS=ON ^
-DLLVM_ENABLE_EH=ON ^
-DLLVM_ENABLE_RTTI=ON ^
Expand Down
18 changes: 9 additions & 9 deletions README_cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ LLVM component names):
| `TARGET_AMDGPU` | `ON`, _if available_ | Enable the AMD GPU backend |
| `TARGET_ARM` | `ON`, _if available_ | Enable the ARM backend |
| `TARGET_HEXAGON` | `ON`, _if available_ | Enable the Hexagon backend |
| `TARGET_MIPS` | `ON`, _if available_ | Enable the MIPS backend |
| `TARGET_NVPTX` | `ON`, _if available_ | Enable the NVidia PTX backend |
| `TARGET_POWERPC` | `ON`, _if available_ | Enable the PowerPC backend |
| `TARGET_RISCV` | `ON`, _if available_ | Enable the RISC V backend |
Expand Down Expand Up @@ -770,14 +769,15 @@ Variables set by the package:

Halide defines the following targets that are available to users:

| Imported target | Description |
|----------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| `Halide::Halide` | this is the JIT-mode library to use when using Halide from C++. |
| `Halide::Generator` | this is the target to use when defining a generator executable. It supplies a `main()` function. |
| `Halide::Runtime` | adds include paths to the Halide runtime headers |
| `Halide::Tools` | adds include paths to the Halide tools, including the benchmarking utility. |
| `Halide::ImageIO` | adds include paths to the Halide image IO utility and sets up dependencies to PNG / JPEG if they are available. |
| `Halide::RunGenMain` | used with the `REGISTRATION` parameter of `add_halide_library` to create simple runners and benchmarking tools for Halide libraries. |
| Imported target | Description |
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `Halide::Halide` | this is the JIT-mode library to use when using Halide from C++. |
| `Halide::Generator` | this is the target to use when defining a generator executable. It supplies a `main()` function. |
| `Halide::Runtime` | adds include paths to the Halide runtime headers |
| `Halide::Tools` | adds include paths to the Halide tools, including the benchmarking utility. |
| `Halide::ImageIO` | adds include paths to the Halide image IO utility. Depends on `PNG::PNG` and `JPEG::JPEG` if they exist or were loaded through the corresponding package components. |
| `Halide::ThreadPool` | adds include paths to the Halide _simple_ thread pool utility library. This is not the same as the runtime's thread pool and is intended only for use by tests. Depends on `Threads::Threads`. |
| `Halide::RunGenMain` | used with the `REGISTRATION` parameter of `add_halide_library` to create simple runners and benchmarking tools for Halide libraries. |

The following targets are not guaranteed to be available:

Expand Down
2 changes: 1 addition & 1 deletion README_webassembly.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ $ ctest -L "correctness|generator" -j
(`"all"`) then it's already present, but otherwise, add it explicitly:
```
-DLLVM_TARGETS_TO_BUILD="X86;ARM;NVPTX;AArch64;Mips;PowerPC;Hexagon;WebAssembly
-DLLVM_TARGETS_TO_BUILD="X86;ARM;NVPTX;AArch64;PowerPC;Hexagon;WebAssembly
```
## Enabling wasm JIT
Expand Down
11 changes: 5 additions & 6 deletions apps/HelloAndroid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ HelloHalide is a simple application which applies a tone curve and sharpening to
a video preview from the camera on a phone or tablet.

This application builds for multiple native ABIs. (At present armeabi,
armeabi-v7a, arm64-v8a, mips, x86_64, and x86 are supported. mips64 is not
presently working.) Halide code is generated for each architecture.
armeabi-v7a, arm64-v8a, x86_64, and x86 are supported.) Halide code is
generated for each architecture.

This build is meant to use Android command line tools. (An IDE is not required.)
In order to build, the following will be required:
Expand Down Expand Up @@ -47,10 +47,9 @@ application.

Pay attention to the list of platforms supported by your Halide installation.
They are listed in jni/Application.mk APP_ABI variable and in build.gradle archs
map. For example, if your Halide installation was built without mips support or
without arm64-v8a, remove them from APP_ABI and archs. Both list and map should
match, otherwise you will be getting compilation errors complaining about a
missing hello.h file:
map. For example, if your Halide installation was built without arm64-v8a,
remove it from APP_ABI and archs. Both list and map should match, otherwise
you will be getting compilation errors complaining about a missing hello.h file:

```
:compileDebugNdkClassic FAILED
Expand Down
1 change: 0 additions & 1 deletion apps/HelloAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ binaries.withType(NativeExecutableBinary) { binary ->
"armeabi": "arm-32-android",
"armeabi-v7a": "arm-32-android",
"arm64-v8a": "arm-64-android",
"mips": "mips-32-android",
"x86_64": "x86-64-android-sse41",
"x86": "x86-32-android"
]
Expand Down
6 changes: 1 addition & 5 deletions apps/HelloAndroid/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ c++ jni/hello_generator.cpp ../../tools/GenGen.cpp \
-L ../../bin -lHalide -ldl -lpthread -lz \
-o bin/hello_generator

# 64-bit MIPS (mips-64-android,mips64) currently does not build since
# llvm will not compile for the R6 version of the ISA without Nan2008
# and the gcc toolchain used by the Android build setup requires those
# two options together.
for archs in arm-32-android,armeabi arm-32-android-armv7s,armeabi-v7a arm-64-android,arm64-v8a mips-32-android,mips x86-64-android-sse41,x86_64 x86-32-android,x86 ; do
for archs in arm-32-android,armeabi arm-32-android-armv7s,armeabi-v7a arm-64-android,arm64-v8a x86-64-android-sse41,x86_64 x86-32-android,x86 ; do
IFS=,
set $archs
HL_TARGET=$1
Expand Down
6 changes: 1 addition & 5 deletions apps/HelloAndroid/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# Can't use "APP_ABI = all" as 64-bit MIPS currently does not build since
# llvm will not compile for the R6 version of the ISA without Nan2008
# and the gcc toolchain used by the Android build setup requires those
# two options together.
APP_ABI := armeabi armeabi-v7a arm64-v8a mips x86_64 x86
APP_ABI := armeabi armeabi-v7a arm64-v8a x86_64 x86
APP_PLATFORM := android-17
APP_STL := gnustl_static
APP_CPPFLAGS := -std=c++17
12 changes: 6 additions & 6 deletions apps/HelloAndroidCamera2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ E/halide_native( 6146): ANativeWindow buffer locked but its size was 1920 x
1440, expected 1440 x 1080

This application builds for multiple native ABIs. (At present armeabi,
armeabi-v7a, arm64-v8a, mips, x86_64, and x86 are supported. mips64 is not
presently working.) Halide code is generated for each architecture.
armeabi-v7a, arm64-v8a, x86_64, and x86 are supported.) Halide code is
generated for each architecture.

This build is meant to use Android command line tools. (An IDE is not required.)
In order to build, the following will be required:
Expand Down Expand Up @@ -65,10 +65,10 @@ application.

Pay attention to the list of platforms supported by your Halide installation.
They are listed in jni/Application.mk APP_ABI variable and in build.gradle archs
map. For example, if your Halide installation was built without mips support or
without arm64-v8a, remove them from APP_ABI and archs. Both list and map should
match, otherwise you will be getting compilation errors complaining about a
missing halide_generated.h file:
map. For example, if your Halide installation was built without arm64-v8a,
remove it from APP_ABI and archs. Both list and map should match, otherwise
you will be getting compilation errors complaining about a missing
halide_generated.h file:

```
:ndkBuild FAILED
Expand Down
1 change: 0 additions & 1 deletion apps/HelloAndroidCamera2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ binaries.withType(NativeExecutableBinary) { binary ->
"armeabi": "arm-32-android",
"armeabi-v7a": "arm-32-android",
"arm64-v8a": "arm-64-android",
"mips": "mips-32-android",
"x86_64": "x86-64-android-sse41",
"x86": "x86-32-android"
]
Expand Down
6 changes: 1 addition & 5 deletions apps/HelloAndroidCamera2/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ c++ jni/deinterleave_generator.cpp ../../tools/GenGen.cpp \
-L ../../bin -lHalide -ldl -lpthread -lz \
-o bin/deinterleave_generator

# 64-bit MIPS (mips-64-android,mips64) currently does not build since
# llvm will not compile for the R6 version of the ISA without Nan2008
# and the gcc toolchain used by the Android build setup requires those
# two options together.
for archs in arm-32-android,armeabi arm-32-android-armv7s,armeabi-v7a arm-64-android,arm64-v8a mips-32-android,mips x86-64-android-sse41,x86_64 x86-32-android,x86 ; do
for archs in arm-32-android,armeabi arm-32-android-armv7s,armeabi-v7a arm-64-android,arm64-v8a x86-64-android-sse41,x86_64 x86-32-android,x86 ; do
IFS=,
set $archs
HL_TARGET=$1
Expand Down
6 changes: 1 addition & 5 deletions apps/HelloAndroidCamera2/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# Can't use "APP_ABI = all" as 64-bit MIPS currently does not build since
# llvm will not compile for the R6 version of the ISA without Nan2008
# and the gcc toolchain used by the Android build setup requires those
# two options together.
APP_ABI := armeabi armeabi-v7a arm64-v8a mips x86_64 x86
APP_ABI := armeabi armeabi-v7a arm64-v8a x86_64 x86
APP_PLATFORM := android-21
APP_STL := c++_static
APP_CPPFLAGS := -std=c++17 -fno-rtti -fexceptions
2 changes: 1 addition & 1 deletion apps/openglcompute/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# TODO(aam): Confirm that application builds and runs for all supported targets:
# APP_ABI := armeabi armeabi-v7a arm64-v8a mips x86_64 x86
# APP_ABI := armeabi armeabi-v7a arm64-v8a x86_64 x86
APP_ABI := armeabi-v7a
APP_PLATFORM := android-17

Expand Down
36 changes: 24 additions & 12 deletions cmake/HalideGeneratorHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function(add_halide_generator TARGET)

if (NOT ARG_EXPORT_FILE)
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/cmake")
set(ARG_EXPORT_FILE "${PROJECT_BINARY_DIR}/cmake/${ARG_PACKAGE_NAME}-config.cmake")
set(ARG_EXPORT_FILE "${PROJECT_BINARY_DIR}/cmake/${ARG_PACKAGE_NAME}Config.cmake")
endif ()

if (NOT ARG_SOURCES)
Expand Down Expand Up @@ -228,6 +228,16 @@ function(add_halide_library TARGET)
message(FATAL_ERROR "Missing FROM argument specifying a Halide generator target")
endif ()

if (NOT TARGET ${ARG_FROM})
# FROM is usually an unqualified name; if we are crosscompiling, we might need a
# fully-qualified name, so add the default package name and retry
set(FQ_ARG_FROM "${PROJECT_NAME}::halide_generators::${ARG_FROM}")
if (NOT TARGET ${FQ_ARG_FROM})
message(FATAL_ERROR "Unable to locate FROM as either ${ARG_FROM} or ${FQ_ARG_FROM}")
endif ()
set(ARG_FROM "${FQ_ARG_FROM}")
endif()

get_property(py_src TARGET ${ARG_FROM} PROPERTY Halide_PYTHON_GENERATOR_SOURCE)
if (py_src)
# TODO: Python Generators need work to support crosscompiling (https://github.com/halide/Halide/issues/7014)
Expand All @@ -241,15 +251,6 @@ function(add_halide_library TARGET)
set(GENERATOR_CMD ${CMAKE_COMMAND} -E env PYTHONPATH=${PYTHONPATH} ${Python3_EXECUTABLE} $<SHELL_PATH:${py_src}>)
set(GENERATOR_CMD_DEPS ${ARG_FROM} Halide::Python ${py_src})
else()
if (NOT TARGET ${ARG_FROM})
# FROM is usually an unqualified name; if we are crosscompiling, we might need a
# fully-qualified name, so add the default package name and retry
set(FQ_ARG_FROM "${PROJECT_NAME}::halide_generators::${ARG_FROM}")
if (NOT TARGET ${FQ_ARG_FROM})
message(FATAL_ERROR "Unable to locate FROM as either ${ARG_FROM} or ${FQ_ARG_FROM}")
endif ()
set(ARG_FROM "${FQ_ARG_FROM}")
endif()
set(GENERATOR_CMD "${ARG_FROM}")
set(GENERATOR_CMD_DEPS ${ARG_FROM})
_Halide_place_dll(${ARG_FROM})
Expand Down Expand Up @@ -313,7 +314,7 @@ function(add_halide_library TARGET)
set(ARG_USE_RUNTIME Halide::Runtime)
elseif (NOT ARG_USE_RUNTIME)
# If we're not using an existing runtime, create one.
add_halide_runtime("${TARGET}.runtime" TARGETS ${ARG_TARGETS})
add_halide_runtime("${TARGET}.runtime" TARGETS ${ARG_TARGETS} FROM ${ARG_FROM})
set(ARG_USE_RUNTIME "${TARGET}.runtime")
elseif (NOT TARGET ${ARG_USE_RUNTIME})
message(FATAL_ERROR "Invalid runtime target ${ARG_USE_RUNTIME}")
Expand Down Expand Up @@ -555,7 +556,7 @@ endfunction()

function(add_halide_runtime RT)
set(options "")
set(oneValueArgs "")
set(oneValueArgs FROM)
set(multiValueArgs TARGETS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

Expand All @@ -569,6 +570,17 @@ function(add_halide_runtime RT)
# so that GCD calculation doesn't get confused.
list(TRANSFORM ARG_TARGETS APPEND "-no_runtime")

if (ARG_FROM)
# Try to use generator which is available. This is essential for cross-compilation
# where we cannot use host compiler to build generator only for runtime.

# Need to check if the ones for python extension, which is not actually an executable
get_target_property(target_type ${ARG_FROM} TYPE)
get_target_property(aliased ${ARG_FROM} ALIASED_TARGET)
if (target_type STREQUAL "EXECUTABLE" AND NOT aliased)
add_executable(_Halide_gengen ALIAS ${ARG_FROM})
endif()
endif()
# Ensure _Halide_gengen is defined
_Halide_gengen_ensure()

Expand Down
Loading

0 comments on commit 4023640

Please sign in to comment.