Skip to content

Commit

Permalink
Backport #7650 to the release/16.x branch (#7653)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
steven-johnson authored Jun 22, 2023
1 parent 499c300 commit 027547f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ 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))
ifeq ($(shell test $(LLVM_VERSION_TIMES_10) -ge 170; echo $$?),0)
WITH_RISCV ?= $(findstring riscv, $(LLVM_COMPONENTS))
else
# leave WITH_RISCV undefined
endif
WITH_AARCH64 ?= $(findstring aarch64, $(LLVM_COMPONENTS))
WITH_POWERPC ?= $(findstring powerpc, $(LLVM_COMPONENTS))
WITH_NVPTX ?= $(findstring nvptx, $(LLVM_COMPONENTS))
Expand Down
14 changes: 12 additions & 2 deletions dependencies/llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,18 @@ foreach (comp IN LISTS known_components)
string(TOUPPER "TARGET_${comp}" OPTION)
string(TOUPPER "WITH_${comp}" DEFINE)

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

0 comments on commit 027547f

Please sign in to comment.