From c9a1da0f192ac96aee6a7a014d925805930e2452 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 16 Sep 2020 15:53:21 -0700 Subject: [PATCH 1/5] Ensure that inline_all_trivial_functions() isn't dead-stripped Can break Li2018 in some build environments. --- src/Util.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Util.cpp b/src/Util.cpp index 515271f86405..043e29da06e0 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -563,6 +563,18 @@ int get_llvm_version() { } // namespace Internal void load_plugin(const std::string &lib_name) { + // TODO: this is an ugly hack. inline_all_trivial_functions() + // isn't used by libHalide, but it is used by the Li2018 + // autoscheduler plugin, so we need it to be present in the final + // libHalide. Unfortunately, build environments that static-link + // generators might deadstrip this function, causing Li2018 + // to fail at load time. This useless call ensures that the function + // is kept around; calling it with empty arguments is close to free + // and this is only called when load_plugin is called anyway. + // (If there is a better, portable way to ensure this function + // isn't dead-stripped, then let's do that instead.) + (void) Halide::Internal::inline_all_trivial_functions({}, {}, {}); + #ifdef _WIN32 std::string lib_path = lib_name; if (lib_path.find('.') == std::string::npos) { From cd695be538063da2182999e0c4f8d36701c3746f Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 16 Sep 2020 16:06:29 -0700 Subject: [PATCH 2/5] Update Util.cpp --- src/Util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util.cpp b/src/Util.cpp index 043e29da06e0..5e65621023eb 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -573,7 +573,7 @@ void load_plugin(const std::string &lib_name) { // and this is only called when load_plugin is called anyway. // (If there is a better, portable way to ensure this function // isn't dead-stripped, then let's do that instead.) - (void) Halide::Internal::inline_all_trivial_functions({}, {}, {}); + (void) Halide::inline_all_trivial_functions({}, {}, {}); #ifdef _WIN32 std::string lib_path = lib_name; From 4a5e47ff2e008e87d7f6c433b368faa53c2937b2 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 16 Sep 2020 16:08:06 -0700 Subject: [PATCH 3/5] Update Util.cpp --- src/Util.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Util.cpp b/src/Util.cpp index 5e65621023eb..370d37a36f35 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -1,4 +1,5 @@ #include "Util.h" +#include "AutoScheduleUtils.h" #include "Debug.h" #include "Error.h" #include "Introspection.h" @@ -573,7 +574,7 @@ void load_plugin(const std::string &lib_name) { // and this is only called when load_plugin is called anyway. // (If there is a better, portable way to ensure this function // isn't dead-stripped, then let's do that instead.) - (void) Halide::inline_all_trivial_functions({}, {}, {}); + (void)Halide::inline_all_trivial_functions({}, {}, {}); #ifdef _WIN32 std::string lib_path = lib_name; From 406a2de714811407732318dd2cdd85d33e4771f0 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 16 Sep 2020 16:33:38 -0700 Subject: [PATCH 4/5] Update Util.cpp --- src/Util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util.cpp b/src/Util.cpp index 370d37a36f35..5e7fcc414273 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -574,7 +574,7 @@ void load_plugin(const std::string &lib_name) { // and this is only called when load_plugin is called anyway. // (If there is a better, portable way to ensure this function // isn't dead-stripped, then let's do that instead.) - (void)Halide::inline_all_trivial_functions({}, {}, {}); + (void)Halide::Internal::inline_all_trivial_functions({}, {}, {}); #ifdef _WIN32 std::string lib_path = lib_name; From fc41d26582420cd9b33fa72cb3b702a0fe6fb6f8 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 16 Sep 2020 16:34:55 -0700 Subject: [PATCH 5/5] Update Util.cpp --- src/Util.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Util.cpp b/src/Util.cpp index 5e7fcc414273..6818aa6a67cb 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -2,6 +2,7 @@ #include "AutoScheduleUtils.h" #include "Debug.h" #include "Error.h" +#include "Function.h" #include "Introspection.h" #include #include