Skip to content

Fix/pass plugin dylib integration #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/llvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on: [push]

jobs:
build_llvm:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macOS-latest
steps:
- name: Setup Windows
if: startsWith(matrix.os, 'windows')
uses: tstellar/actions/setup-windows@master
with:
arch: amd64
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install Ninja
uses: tstellar/actions/install-ninja@master
with:
os: ${{ runner.os }}
- name: Test LLVM / dynamic
if: startsWith(matrix.os, 'windows') == false
uses: tstellar/actions/build-test-llvm-project@master
with:
cmake_args: -G Ninja -DCMAKE_BUILD_TYPE=Release ${{ matrix.cmake_args }} -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_BUILD_LLVM_DYLIB=ON -DCLANG_LINK_CLANG_DYLIB=ON -DLLVM_ENABLE_PROJECTS='polly;clang' -DPOLLY_ENABLE_GPGPU_CODEGEN=OFF -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_POLLY_LINK_INTO_TOOLS=OFF
os: ${{ runner.os }}
- name: Test LLVM / static
uses: tstellar/actions/build-test-llvm-project@master
with:
cmake_args: -G Ninja -DCMAKE_BUILD_TYPE=Release ${{ matrix.cmake_args }} -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_BUILD_LLVM_DYLIB=ON -DCLANG_LINK_CLANG_DYLIB=ON -DLLVM_ENABLE_PROJECTS='polly;clang' -DPOLLY_ENABLE_GPGPU_CODEGEN=ON -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_POLLY_LINK_INTO_TOOLS=ON
os: ${{ runner.os }}
24 changes: 18 additions & 6 deletions llvm/cmake/modules/AddLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -873,13 +873,18 @@ function(add_llvm_pass_plugin name)
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})

if(LLVM_LINK_LLVM_DYLIB)
set_property(GLOBAL APPEND PROPERTY LLVM_COMPONENT_LIBS ${name})
endif()

elseif(NOT ARG_NO_MODULE)
add_llvm_library(${name} MODULE ${ARG_UNPARSED_ARGUMENTS})
else()
add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS})
endif()
message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")

endfunction(add_llvm_pass_plugin)

Expand All @@ -903,13 +908,20 @@ function(process_llvm_pass_plugins)
if(LLVM_${llvm_extension_upper}_LINK_INTO_TOOLS)
file(APPEND "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "HANDLE_EXTENSION(${llvm_extension_project})\n")

get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
foreach(llvm_plugin_target ${llvm_plugin_targets})
set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
endforeach()
# In the context of dylib, tools already listed in the
# LLVM_COMMON_LIBS.
if(NOT LLVM_LINK_LLVM_DYLIB)
get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
foreach(llvm_plugin_target ${llvm_plugin_targets})
set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
endforeach()
endif()
else()
add_llvm_library(${llvm_extension_lower} MODULE obj.${llvm_extension_lower})
if (LLVM_LINK_LLVM_DYLIB)
target_link_libraries(${llvm_extension_lower} PUBLIC LLVM)
endif()
endif()

endforeach()
Expand Down
16 changes: 7 additions & 9 deletions polly/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,13 @@ if (GPU_CODEGEN)
llvm_map_components_to_libnames(nvptx_libs NVPTX)
endif ()

if (LLVM_LINK_LLVM_DYLIB)
# The shlib/dylib contains all the LLVM components
# (including NVPTX is enabled) already. Adding them to target_link_libraries
# would cause them being twice in the address space
# (their LLVM*.a/so and their copies in libLLVM.so)
# which results in errors when the two instances try to register the same
# command-line switches.
target_link_libraries(Polly PUBLIC LLVM)
else ()
# The shlib/dylib contains all the LLVM components
# (including NVPTX is enabled) already. Adding them to target_link_libraries
# would cause them being twice in the address space
# (their LLVM*.a/so and their copies in libLLVM.so)
# which results in errors when the two instances try to register the same
# command-line switches.
if (NOT LLVM_LINK_LLVM_DYLIB)
target_link_libraries(Polly PUBLIC
LLVMSupport
LLVMCore
Expand Down