Skip to content

Commit 027547f

Browse files
Backport #7650 to the release/16.x branch (#7653)
Default RISCV backend to OFF for LLVM < 17 (#7650) LLVM17 is doing a lot of work on the RISCV backend, and the amount of testing done on Halide's LLVM16-based RISCV codegen is very light. It's been suggested that we should default to not enabling the RISCV backend for LLVM16 and earlier because of this (so that people attempting to use Halide for RISCV won't encounter a possible footgun). This PR just adds the relevant mechanism; whether or not this is the correct decision is not clear. Discussion welcome.
1 parent 499c300 commit 027547f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ LLVM_CXX_FLAGS += -DLLVM_VERSION=$(LLVM_VERSION_TIMES_10)
119119
WITH_X86 ?= $(findstring x86, $(LLVM_COMPONENTS))
120120
WITH_ARM ?= $(findstring arm, $(LLVM_COMPONENTS))
121121
WITH_HEXAGON ?= $(findstring hexagon, $(LLVM_COMPONENTS))
122+
ifeq ($(shell test $(LLVM_VERSION_TIMES_10) -ge 170; echo $$?),0)
122123
WITH_RISCV ?= $(findstring riscv, $(LLVM_COMPONENTS))
124+
else
125+
# leave WITH_RISCV undefined
126+
endif
123127
WITH_AARCH64 ?= $(findstring aarch64, $(LLVM_COMPONENTS))
124128
WITH_POWERPC ?= $(findstring powerpc, $(LLVM_COMPONENTS))
125129
WITH_NVPTX ?= $(findstring nvptx, $(LLVM_COMPONENTS))

dependencies/llvm/CMakeLists.txt

+12-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,18 @@ foreach (comp IN LISTS known_components)
7676
string(TOUPPER "TARGET_${comp}" OPTION)
7777
string(TOUPPER "WITH_${comp}" DEFINE)
7878

79-
cmake_dependent_option(${OPTION} "Include ${comp} target" ON
80-
"${comp} IN_LIST LLVM_TARGETS_TO_BUILD" OFF)
79+
if (comp STREQUAL "RISCV" AND LLVM_PACKAGE_VERSION VERSION_LESS 17.0)
80+
# We default the RISCV target to OFF for LLVM versions prior to 17.0;
81+
# it's not clear how robust and well-tested Halide's RISCV codegen
82+
# is with LLVM16, and a great deal of effort is being put into
83+
# improving it in LLVM17... so default to off so that people won't
84+
# hurt themselves too badly.
85+
cmake_dependent_option(${OPTION} "Include ${comp} target" OFF
86+
"${comp} IN_LIST LLVM_TARGETS_TO_BUILD" OFF)
87+
else ()
88+
cmake_dependent_option(${OPTION} "Include ${comp} target" ON
89+
"${comp} IN_LIST LLVM_TARGETS_TO_BUILD" OFF)
90+
endif ()
8191
if (${OPTION} OR Halide_SHARED_LLVM)
8292
message(STATUS "Enabling ${comp} backend")
8393
list(APPEND Halide_LLVM_DEFS $<BUILD_INTERFACE:${DEFINE}>)

0 commit comments

Comments
 (0)