Skip to content

Commit 14ff545

Browse files
authored
Drop deprecated / unsupported setups for Halide 20 (#8508)
* Drop deprecated CMake variables * Drop support for LLVM 17 * Bump clang-tidy version to 19
1 parent 9ecda2d commit 14ff545

19 files changed

+32
-148
lines changed

.github/workflows/presubmit.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ jobs:
3131
steps:
3232
- uses: actions/checkout@v3
3333
- name: Install clang-tidy
34-
run: brew install llvm@17 ninja
34+
run: brew install llvm@19 ninja lld
3535
- name: Run clang-tidy
3636
run: ./run-clang-tidy.sh
3737
env:
38-
CLANG_TIDY_LLVM_INSTALL_DIR: /opt/homebrew/opt/llvm@17
38+
CLANG_TIDY_LLVM_INSTALL_DIR: /opt/homebrew/opt/llvm@19
3939
check_cmake_file_lists:
4040
name: Check CMake file lists
4141
runs-on: ubuntu-20.04

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ option(THREADS_PREFER_PTHREAD_FLAG "When enabled, prefer to use the -pthread fla
195195
find_package(Threads REQUIRED)
196196

197197
## LLVM
198-
find_package(Halide_LLVM 17...20 REQUIRED
198+
find_package(Halide_LLVM 18...20 REQUIRED
199199
COMPONENTS WebAssembly X86
200200
OPTIONAL_COMPONENTS AArch64 ARM Hexagon NVPTX PowerPC RISCV)
201201

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ issue.
151151

152152
At any point in time, building Halide requires either the latest stable version
153153
of LLVM, the previous stable version of LLVM, or trunk. At the time of writing,
154-
this means versions 19, 18, and 17 are supported, but 16 is not.
154+
this means versions 20, 19, and 18 are supported, but 17 is not.
155155

156156
It is simplest to get a binary release of LLVM on macOS by using
157157
[Homebrew](https://brew.sh). Just run `brew install llvm`. On Debian flavors of
@@ -165,10 +165,10 @@ If your OS does not have packages for LLVM, or you want more control over the
165165
configuration, you can build it yourself. First check it out from GitHub:
166166

167167
```shell
168-
$ git clone --depth 1 --branch llvmorg-18.1.8 https://github.com/llvm/llvm-project.git
168+
$ git clone --depth 1 --branch llvmorg-19.1.5 https://github.com/llvm/llvm-project.git
169169
```
170170

171-
(LLVM 18.1.8 is the most recent released LLVM at the time of writing. For
171+
(LLVM 19.1.5 is the most recent released LLVM at the time of writing. For
172172
current trunk, use `main` instead)
173173

174174
Then build it like so:
@@ -305,10 +305,10 @@ Subsets of the tests can be selected with `-L` and include `correctness`,
305305
#### Building LLVM (optional)
306306

307307
Follow these steps if you want to build LLVM yourself. First, download LLVM's
308-
sources (these instructions use the 18.1.8 release).
308+
sources (these instructions use the 19.1.5 release).
309309

310310
```
311-
D:\> git clone --depth 1 --branch llvm-org-18.1.8 https://github.com/llvm/llvm-project.git
311+
D:\> git clone --depth 1 --branch llvm-org-19.1.5 https://github.com/llvm/llvm-project.git
312312
```
313313

314314
As above, run `vcvarsall.bat` to pick between x86 and x64. Then configure LLVM

cmake/FindHalide_LLVM.cmake

-7
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ find_package(LLVM ${PACKAGE_FIND_VERSION} CONFIG)
1313

1414
set(Halide_LLVM_VERSION "${LLVM_PACKAGE_VERSION}")
1515

16-
# TODO: deprecated in Halide 19.0.0, remove in Halide 20.0.0
17-
if (NOT DEFINED Halide_LLVM_SHARED_LIBS AND DEFINED Halide_SHARED_LLVM)
18-
set(Halide_LLVM_SHARED_LIBS "${Halide_SHARED_LLVM}")
19-
message(DEPRECATION
20-
"Halide_SHARED_LLVM has been renamed to Halide_LLVM_SHARED_LIBS.")
21-
endif ()
22-
2316
if (NOT DEFINED Halide_LLVM_SHARED_LIBS)
2417
# Normally, we don't like making decisions for our users. However,
2518
# this avoids an incompatible scenario that is checked below. So

cmake/FindNodeJS.cmake

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
if (EXISTS "${NODE_JS_EXECUTABLE}")
2-
message(DEPRECATION "NODE_JS_EXECUTABLE has been renamed to NodeJS_EXECUTABLE")
3-
set(NodeJS_EXECUTABLE "${NODE_JS_EXECUTABLE}")
4-
set(NodeJS_EXECUTABLE "${NODE_JS_EXECUTABLE}" CACHE PATH "")
5-
endif ()
6-
71
find_program(
82
NodeJS_EXECUTABLE
93
NAMES node nodejs

cmake/FindV8.cmake

-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
if (EXISTS "${V8_INCLUDE_PATH}")
2-
message(DEPRECATION "V8_INCLUDE_PATH has been renamed to V8_INCLUDE_DIR")
3-
set(V8_INCLUDE_DIR "${V8_INCLUDE_PATH}")
4-
set(V8_INCLUDE_DIR "${V8_INCLUDE_PATH}" CACHE PATH "")
5-
endif ()
6-
71
find_path(V8_INCLUDE_DIR v8.h)
82

9-
if (EXISTS "${V8_LIB_PATH}")
10-
message(DEPRECATION "V8_LIB_PATH has been renamed to V8_LIBRARY")
11-
set(V8_LIBRARY "${V8_LIB_PATH}")
12-
set(V8_LIBRARY "${V8_LIB_PATH}" CACHE FILEPATH "")
13-
endif ()
14-
153
find_library(
164
V8_LIBRARY
175
NAMES v8_monolith

cmake/HalideGeneratorHelpers.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ function(_Halide_library_from_generator TARGET)
288288
add_library("${TARGET}" STATIC ${local_out_${ARG_TYPE}})
289289
set_property(TARGET "${TARGET}" PROPERTY POSITION_INDEPENDENT_CODE ON)
290290
set_property(TARGET "${TARGET}" PROPERTY LINKER_LANGUAGE CXX)
291+
if (ARG_TYPE STREQUAL "c_source")
292+
set_source_files_properties("${local_out_${ARG_TYPE}}" PROPERTIES SKIP_LINTING ON)
293+
endif ()
291294

292295
if (NOT Halide_NO_DEFAULT_FLAGS)
293296
# Silence many useless warnings in generated C++ code compilation

run-clang-tidy.sh

+10-10
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ if [ -n "${FIX}" ]; then
4141
echo "Operating in -fix mode!"
4242
fi
4343

44-
# We are currently standardized on using LLVM/Clang 17 for this script.
44+
# We are currently standardized on using LLVM/Clang 19 for this script.
4545
# Note that this is totally independent of the version of LLVM that you
46-
# are using to build Halide itself. If you don't have LLVM17 installed,
46+
# are using to build Halide itself. If you don't have LLVM19 installed,
4747
# you can usually install what you need easily via:
4848
#
49-
# sudo apt-get install llvm-17 clang-17 libclang-17-dev clang-tidy-17
50-
# export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-17
49+
# sudo apt-get install llvm-19 clang-19 libclang-19-dev clang-tidy-19
50+
# export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-19
5151
#
5252
# On macOS:
5353
#
54-
# brew install llvm@17
55-
# export CLANG_TIDY_LLVM_INSTALL_DIR=/opt/homebrew/opt/llvm@17
54+
# brew install llvm@19
55+
# export CLANG_TIDY_LLVM_INSTALL_DIR=/opt/homebrew/opt/llvm@19
5656

5757
if [ -z "$CLANG_TIDY_LLVM_INSTALL_DIR" ]; then
5858
echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM installation dir for this script."
@@ -62,11 +62,11 @@ fi
6262
echo "CLANG_TIDY_LLVM_INSTALL_DIR = ${CLANG_TIDY_LLVM_INSTALL_DIR}"
6363

6464
VERSION=$("${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/clang-tidy" --version)
65-
if [[ ${VERSION} =~ .*version\ 17.* ]]
65+
if [[ ${VERSION} =~ .*version\ 19.* ]]
6666
then
67-
echo "clang-tidy version 17 found."
67+
echo "clang-tidy version 19 found."
6868
else
69-
echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM 17 install!"
69+
echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM 19 install!"
7070
exit 1
7171
fi
7272

@@ -140,4 +140,4 @@ echo "run-clang-tidy finished with status ${RESULT}"
140140

141141
rm -rf "${CLANG_TIDY_BUILD_DIR}"
142142

143-
exit "${RESULT}"
143+
exit "${RESULT}"

src/CMakeLists.txt

-13
Original file line numberDiff line numberDiff line change
@@ -587,19 +587,6 @@ set(Halide_WASM_BACKEND "wabt"
587587
CACHE STRING "Which backend to use for Halide's WASM testing.")
588588
set_property(CACHE Halide_WASM_BACKEND PROPERTY STRINGS "wabt;V8;OFF")
589589

590-
if (WITH_WABT AND NOT WITH_V8)
591-
message(DEPRECATION "WITH_WABT has been replaced by Halide_WASM_BACKEND=\"wabt\"")
592-
set(Halide_WASM_BACKEND "wabt")
593-
elseif (NOT WITH_WABT AND WITH_V8)
594-
message(DEPRECATION "WITH_V8 has been replaced by Halide_WASM_BACKEND=\"V8\"")
595-
set(Halide_WASM_BACKEND "V8")
596-
elseif (WITH_WABT AND WITH_V8)
597-
message(FATAL_ERROR "Cannot use both WABT and V8 at the same time, disable one of them.")
598-
elseif (DEFINED WITH_WABT AND DEFINED WITH_V8 AND NOT WITH_WABT AND NOT WITH_V8)
599-
message(DEPRECATION "Disabling both WITH_WABT and WITH_V8 has been replaced by Halide_WASM_BACKEND=\"OFF\"")
600-
set(Halide_WASM_BACKEND "OFF")
601-
endif ()
602-
603590
if (MSVC AND Halide_WASM_BACKEND STREQUAL "wabt")
604591
message(WARNING "wabt is not yet supported on Windows")
605592
set(Halide_WASM_BACKEND "OFF")

src/CodeGen_Internal.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -664,12 +664,6 @@ std::unique_ptr<llvm::TargetMachine> make_target_machine(const llvm::Module &mod
664664
bool use_large_code_model =
665665
get_md_bool(module.getModuleFlag("halide_use_large_code_model")).value_or(false);
666666

667-
#if LLVM_VERSION >= 180
668-
const auto opt_level = llvm::CodeGenOptLevel::Aggressive;
669-
#else
670-
const auto opt_level = llvm::CodeGenOpt::Aggressive;
671-
#endif
672-
673667
// Get module mcpu_target and mattrs.
674668
std::string mcpu_target =
675669
get_md_string(module.getModuleFlag("halide_mcpu_target")).value_or(std::string{});
@@ -682,7 +676,7 @@ std::unique_ptr<llvm::TargetMachine> make_target_machine(const llvm::Module &mod
682676
options,
683677
use_pic ? llvm::Reloc::PIC_ : llvm::Reloc::Static,
684678
use_large_code_model ? llvm::CodeModel::Large : llvm::CodeModel::Small,
685-
opt_level);
679+
CodeGenOptLevel::Aggressive);
686680
return std::unique_ptr<llvm::TargetMachine>(tm);
687681
}
688682

src/CodeGen_LLVM.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,6 @@ void CodeGen_LLVM::optimize_module() {
11441144
using OptimizationLevel = llvm::OptimizationLevel;
11451145
OptimizationLevel level = OptimizationLevel::O3;
11461146

1147-
#if LLVM_VERSION >= 180
11481147
if (tm->isPositionIndependent()) {
11491148
// Add a pass that converts lookup tables to relative lookup tables to make them PIC-friendly.
11501149
// See https://bugs.llvm.org/show_bug.cgi?id=45244
@@ -1158,7 +1157,6 @@ void CodeGen_LLVM::optimize_module() {
11581157
mpm.addPass(RelLookupTableConverterPass());
11591158
});
11601159
}
1161-
#endif
11621160

11631161
if (get_target().has_feature(Target::SanitizerCoverage)) {
11641162
pb.registerOptimizerLastEPCallback(
@@ -1237,7 +1235,7 @@ void CodeGen_LLVM::optimize_module() {
12371235
}
12381236

12391237
if (tm) {
1240-
#if LLVM_VERSION >= 180 && LLVM_VERSION < 190
1238+
#if LLVM_VERSION < 190
12411239
tm->registerPassBuilderCallbacks(pb, /*PopulateClassToPassNames=*/false);
12421240
#else
12431241
tm->registerPassBuilderCallbacks(pb);

src/CodeGen_PTX_Dev.cpp

+3-13
Original file line numberDiff line numberDiff line change
@@ -612,17 +612,12 @@ vector<char> CodeGen_PTX_Dev::compile_to_src() {
612612
options.NoZerosInBSS = false;
613613
options.GuaranteedTailCallOpt = false;
614614

615-
#if LLVM_VERSION >= 180
616-
const auto opt_level = CodeGenOptLevel::Aggressive;
617-
#else
618-
const auto opt_level = CodeGenOpt::Aggressive;
619-
#endif
620615
std::unique_ptr<TargetMachine>
621616
target_machine(llvm_target->createTargetMachine(triple.str(),
622617
mcpu_target(), mattrs(), options,
623618
llvm::Reloc::PIC_,
624619
llvm::CodeModel::Small,
625-
opt_level));
620+
CodeGenOptLevel::Aggressive));
626621

627622
internal_assert(target_machine.get()) << "Could not allocate target machine!";
628623

@@ -688,7 +683,7 @@ vector<char> CodeGen_PTX_Dev::compile_to_src() {
688683
using OptimizationLevel = llvm::OptimizationLevel;
689684
OptimizationLevel level = OptimizationLevel::O3;
690685

691-
#if LLVM_VERSION >= 180 && LLVM_VERSION < 190
686+
#if LLVM_VERSION < 190
692687
target_machine->registerPassBuilderCallbacks(pb, /*PopulateClassToPassNames=*/false);
693688
#else
694689
target_machine->registerPassBuilderCallbacks(pb);
@@ -721,14 +716,9 @@ vector<char> CodeGen_PTX_Dev::compile_to_src() {
721716

722717
// Output string stream
723718

724-
#if LLVM_VERSION >= 180
725-
const auto file_type = ::llvm::CodeGenFileType::AssemblyFile;
726-
#else
727-
const auto file_type = ::llvm::CGFT_AssemblyFile;
728-
#endif
729719
// Ask the target to add backend passes as necessary.
730720
bool fail = target_machine->addPassesToEmitFile(module_pass_manager, ostream, nullptr,
731-
file_type, true);
721+
CodeGenFileType::AssemblyFile, true);
732722
internal_assert(!fail) << "Failed to set up passes to emit PTX source\n";
733723
module_pass_manager.run(*module);
734724

src/CodeGen_RISCV.cpp

+1-11
Original file line numberDiff line numberDiff line change
@@ -382,20 +382,10 @@ bool CodeGen_RISCV::call_riscv_vector_intrinsic(const RISCVIntrinsic &intrin, co
382382
left_arg,
383383
right_arg,
384384
};
385-
#if LLVM_VERSION >= 170
386-
// LLVM 17+ has "intrinsics" that set csrw internally; the rounding_mode is before vlen.
385+
// LLVM has "intrinsics" that set csrw internally; the rounding_mode is before vlen.
387386
if (round_any) {
388387
call_args.push_back(rounding_mode);
389388
}
390-
#else
391-
// LLVM 16 requires explicitly setting csrw before calling the intrinsic
392-
if (round_any) {
393-
// Set vector fixed-point rounding flag for intrinsic.
394-
llvm::FunctionType *csrw_llvm_type = llvm::FunctionType::get(void_t, {xlen_type}, false);
395-
llvm::InlineAsm *inline_csrw = llvm::InlineAsm::get(csrw_llvm_type, "csrw vxrm,${0:z}", "rJ,~{memory}", true);
396-
builder->CreateCall(inline_csrw, {rounding_mode});
397-
}
398-
#endif
399389
call_args.push_back(actual_vlen);
400390

401391
// Finally, make the call.

src/CodeGen_WebAssembly.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -406,18 +406,14 @@ bool CodeGen_WebAssembly::use_soft_float_abi() const {
406406
}
407407

408408
bool CodeGen_WebAssembly::use_pic() const {
409-
#if LLVM_VERSION >= 180
410-
// Issues with WASM PIC and dynamic linking only got fixed in LLVM v18.x (June 26th 2023)
409+
// Issues with WASM PIC and dynamic linking were fixed in LLVM v18.x (June 26th 2023)
411410
// See https://reviews.llvm.org/D153293
412411

413412
// Always emitting PIC "does add a little bloat to the object files, due to the extra
414413
// indirection, but when linked into a static binary 100% of this can be removed by
415414
// wasm-opt in release builds."
416415
// See https://github.com/halide/Halide/issues/7796
417416
return true;
418-
#else
419-
return false;
420-
#endif
421417
}
422418

423419
int CodeGen_WebAssembly::native_vector_bits() const {

src/CodeGen_X86.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1078,11 +1078,9 @@ string CodeGen_X86::mattrs() const {
10781078
attrs.emplace_back("+amx-bf16");
10791079
}
10801080
}
1081-
#if LLVM_VERSION >= 180
10821081
if (gather_might_be_slow(target)) {
10831082
attrs.emplace_back("+prefer-no-gather");
10841083
}
1085-
#endif
10861084

10871085
if (target.has_feature(Target::AVX10_1)) {
10881086
switch (target.vector_bits) {

src/JITModule.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,7 @@ void JITModule::compile_module(std::unique_ptr<llvm::Module> m, const string &fu
288288
// Build TargetMachine
289289
llvm::orc::JITTargetMachineBuilder tm_builder(llvm::Triple(m->getTargetTriple()));
290290
tm_builder.setOptions(options);
291-
#if LLVM_VERSION >= 180
292291
tm_builder.setCodeGenOptLevel(CodeGenOptLevel::Aggressive);
293-
#else
294-
tm_builder.setCodeGenOptLevel(CodeGenOpt::Aggressive);
295-
#endif
296292
if (target.arch == Target::Arch::RISCV) {
297293
tm_builder.setCodeModel(llvm::CodeModel::Medium);
298294
}

src/LLVM_Headers.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef HALIDE_LLVM_HEADERS_H
22
#define HALIDE_LLVM_HEADERS_H
33

4-
#if LLVM_VERSION >= 170
4+
#if LLVM_VERSION >= 180
55
// We're good to go
66
#else
7-
#error "Compiling Halide requires LLVM 17.0 or newer"
7+
#error "Compiling Halide requires LLVM 18.0 or newer"
88
#endif
99

1010
// No msvc warnings from llvm headers please
@@ -93,10 +93,8 @@
9393
#include <llvm/Transforms/Instrumentation/ThreadSanitizer.h>
9494
#include <llvm/Transforms/Scalar/GVN.h>
9595
#include <llvm/Transforms/Utils/ModuleUtils.h>
96-
#include <llvm/Transforms/Utils/SymbolRewriter.h>
97-
#if LLVM_VERSION >= 180
9896
#include <llvm/Transforms/Utils/RelLookupTableConverter.h>
99-
#endif
97+
#include <llvm/Transforms/Utils/SymbolRewriter.h>
10098

10199
// IWYU pragma: end_exports
102100

src/LLVM_Output.cpp

+1-10
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,7 @@ std::unique_ptr<llvm::Module> compile_module_to_llvm_module(const Module &module
412412
}
413413

414414
void compile_llvm_module_to_object(llvm::Module &module, Internal::LLVMOStream &out) {
415-
#if LLVM_VERSION >= 180
416415
emit_file(module, out, llvm::CodeGenFileType::ObjectFile);
417-
#else
418-
emit_file(module, out, llvm::CGFT_ObjectFile);
419-
#endif
420416
}
421417

422418
void compile_llvm_module_to_assembly(llvm::Module &module, Internal::LLVMOStream &out) {
@@ -592,15 +588,10 @@ void create_static_library(const std::vector<std::string> &src_files_in, const T
592588
return;
593589
}
594590

595-
#if LLVM_VERSION >= 180
596-
const llvm::SymtabWritingMode write_symtab = llvm::SymtabWritingMode::NormalSymtab;
597-
#else
598-
const bool write_symtab = true;
599-
#endif
600591
const auto kind = Internal::get_triple_for_target(target).isOSDarwin() ? llvm::object::Archive::K_BSD : llvm::object::Archive::K_GNU;
601592
const bool thin = false;
602593
auto result = llvm::writeArchive(dst_file, new_members,
603-
write_symtab, kind,
594+
llvm::SymtabWritingMode::NormalSymtab, kind,
604595
deterministic, thin, nullptr);
605596
internal_assert(!result)
606597
<< "Failed to write archive: " << dst_file

0 commit comments

Comments
 (0)