[llvm] 346de9b - Fix several issues with compiler extensions
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 10 01:10:34 PST 2020
Author: serge-sans-paille
Date: 2020-01-10T10:10:20+01:00
New Revision: 346de9b67228f42eb9b55fa3b426b5dedfdb1d40
URL: https://github.com/llvm/llvm-project/commit/346de9b67228f42eb9b55fa3b426b5dedfdb1d40
DIFF: https://github.com/llvm/llvm-project/commit/346de9b67228f42eb9b55fa3b426b5dedfdb1d40.diff
LOG: Fix several issues with compiler extensions
- Update documentation now that the move to monorepo has been made
- Do not tie compiler extension testing to LLVM_BUILD_EXAMPLES
- No need to specify LLVM libraries for plugins
- Add NO_MODULE option to match Polly specific requirements (i.e. building the
module *and* linking it statically)
- Issue a warning when building the compiler extension with
LLVM_BYE_LINK_INTO_TOOLS=ON, as it modifies the behavior of clang, which only
makes sense for testing purpose.
Still mark llvm/test/Feature/load_extension.ll as XFAIL because of a
ManagedStatic dependency that's going to be fixed in a seperate commit.
Differential Revision: https://reviews.llvm.org/D72327
Added:
Modified:
llvm/cmake/modules/AddLLVM.cmake
llvm/examples/Bye/CMakeLists.txt
llvm/test/lit.cfg.py
polly/lib/CMakeLists.txt
Removed:
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 75e0f10d68ac..fce36ba21253 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -847,32 +847,40 @@ macro(add_llvm_executable name)
llvm_codesign(${name} ENTITLEMENTS ${ARG_ENTITLEMENTS} BUNDLE_PATH ${ARG_BUNDLE_PATH})
endmacro(add_llvm_executable name)
-# add_llvm_pass_plugin(name)
+# add_llvm_pass_plugin(name [NO_MODULE] ...)
# Add ${name} as an llvm plugin.
# If option LLVM_${name_upper}_LINK_INTO_TOOLS is set to ON, the plugin is registered statically.
# Otherwise a pluggable shared library is registered.
+#
+# If NO_MODULE is specified, when option LLVM_${name_upper}_LINK_INTO_TOOLS is set to OFF,
+# only an object library is built, and no module is built. This is specific to the Polly use case.
function(add_llvm_pass_plugin name)
+ cmake_parse_arguments(ARG
+ "NO_MODULE" "" ""
+ ${ARGN})
string(TOUPPER ${name} name_upper)
option(LLVM_${name_upper}_LINK_INTO_TOOLS "Statically link ${name} into tools (if available)" OFF)
- # process_llvm_pass_plugins takes care of the actual linking, just create an
- # object library as of now
- add_llvm_library(${name} OBJECT ${ARGN})
-
- if(LLVM_${name_upper}_LINK_INTO_TOOLS)
- target_compile_definitions(${name} PRIVATE LLVM_${name_upper}_LINK_INTO_TOOLS)
- set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS LLVM_LINK_INTO_TOOLS)
- if (TARGET intrinsics_gen)
- add_dependencies(obj.${name} intrinsics_gen)
- endif()
- endif()
-
- message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")
if(LLVM_${name_upper}_LINK_INTO_TOOLS)
+ list(REMOVE_ITEM ARG_UNPARSED_ARGUMENTS BUILDTREE_ONLY)
+ # process_llvm_pass_plugins takes care of the actual linking, just create an
+ # object library as of now
+ add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS})
+ target_compile_definitions(${name} PRIVATE LLVM_${name_upper}_LINK_INTO_TOOLS)
+ set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS LLVM_LINK_INTO_TOOLS)
+ if (TARGET intrinsics_gen)
+ add_dependencies(obj.${name} intrinsics_gen)
+ endif()
+ message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")
set_property(GLOBAL APPEND PROPERTY LLVM_COMPILE_EXTENSIONS ${name})
+ elseif(NOT ARG_NO_MODULE)
+ add_llvm_library(${name} MODULE ${ARG_UNPARSED_ARGUMENTS})
+ else()
+ add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS})
endif()
+
endfunction(add_llvm_pass_plugin)
# Generate X Macro file for extension handling. It provides a
diff --git a/llvm/examples/Bye/CMakeLists.txt b/llvm/examples/Bye/CMakeLists.txt
index a6767209491a..3206f90d0916 100644
--- a/llvm/examples/Bye/CMakeLists.txt
+++ b/llvm/examples/Bye/CMakeLists.txt
@@ -1,23 +1,13 @@
-add_llvm_pass_plugin(Bye
- Bye.cpp
- DEPENDS
- intrinsics_gen
- BUILDTREE_ONLY
- )
-
-if (LLVM_LINK_LLVM_DYLIB)
- target_link_libraries(Bye PUBLIC LLVM)
-else()
- target_link_libraries(Bye
- PUBLIC
- LLVMSupport
- LLVMCore
- LLVMipo
- LLVMPasses
- )
+if(LLVM_BYE_LINK_INTO_TOOLS)
+ message(WARNING "Setting LLVM_BYE_LINK_INTO_TOOLS=ON only makes sense for testing purpose")
endif()
-if( LLVM_BUILD_EXAMPLES )
- install(TARGETS ${name} RUNTIME DESTINATION examples)
-endif()
+add_llvm_pass_plugin(Bye
+ Bye.cpp
+ DEPENDS
+ intrinsics_gen
+ BUILDTREE_ONLY
+ )
+
+install(TARGETS ${name} RUNTIME DESTINATION examples)
set_target_properties(${name} PROPERTIES FOLDER "Examples")
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index e785b220540f..b57b87ad657f 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -200,13 +200,13 @@ def get_asan_rtlib():
if config.build_examples:
config.available_features.add('examples')
-if config.linked_bye_extension and config.build_examples:
+if config.linked_bye_extension:
config.substitutions.append(('%llvmcheckext', 'CHECK-EXT'))
config.substitutions.append(('%loadbye', ''))
else:
config.substitutions.append(('%llvmcheckext', 'CHECK-NOEXT'))
config.substitutions.append(('%loadbye',
- '-load={}/libBye{}'.format(config.llvm_shlib_dir,
+ '-load={}/Bye{}'.format(config.llvm_shlib_dir,
config.llvm_shlib_ext)))
# Static libraries are not built if BUILD_SHARED_LIBS is ON.
diff --git a/polly/lib/CMakeLists.txt b/polly/lib/CMakeLists.txt
index 9e8cd1906d62..ee0834cc8e32 100644
--- a/polly/lib/CMakeLists.txt
+++ b/polly/lib/CMakeLists.txt
@@ -24,6 +24,7 @@ endif ()
# Use an object-library to add the same files to multiple libs without requiring
# the sources them to be recompiled for each of them.
add_llvm_pass_plugin(Polly
+ NO_MODULE
Analysis/DependenceInfo.cpp
Analysis/PolyhedralInfo.cpp
Analysis/ScopDetection.cpp
More information about the llvm-commits
mailing list