Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ variables:
##### LC GITLAB CONFIGURATION
# Keep Proteus clones out of the default ~/.jacamar-ci/builds, which other
# projects' CI jobs share and clean up.
CUSTOM_CI_BUILDS_DIR: "/usr/workspace/fink12/gitlab-runner-proteus"
CUSTOM_CI_BUILDS_DIR: "/usr/workspace/proteus-dev/gitlab-runner"
# Tells Gitlab to recursively update the submodules when cloning the project.
# GIT_SUBMODULE_STRATEGY: recursive

Expand Down
4 changes: 4 additions & 0 deletions cmake/ProteusFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ function(add_proteus target)
"-fplugin=$<TARGET_FILE:ProteusPass>"
"-fpass-plugin=$<TARGET_FILE:ProteusPass>"
"SHELL:-Xclang -mllvm -Xclang -force-proteus-jit-annotate-all"
"-fplugin=\$<TARGET_FILE:ProteusASTChecker>"
)
else()
target_compile_options(${target} PRIVATE
"-fpass-plugin=\$<TARGET_FILE:ProteusPass>"
"-fplugin=\$<TARGET_FILE:ProteusASTChecker>"
)
endif()

add_dependencies(${target} ProteusPass ProteusASTChecker)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: this dependency ordering is sometimes needed by downstream projects, so even though this feature does not require ProteusPass dependency explicitly, some downstream projects will benefit from this


target_link_options(${target} PRIVATE
"SHELL:\$<\$<LINK_LANGUAGE:HIP>:-Xoffload-linker --load-pass-plugin=\$<TARGET_FILE:ProteusPassOffload>>")

Expand Down
7 changes: 5 additions & 2 deletions docs/user/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ linking flags, for example:

```bash
CXXFLAGS += -I<install_path>/include \
-fplugin=<install_path>/<libdir>/libProteusASTChecker.so \
-fpass-plugin=<install_path>/<libdir>/libProteusPass.so

LDFLAGS += -L<install_path>/<libdir> \
-Wl,-rpath,<install_path>/<libdir> \
-lproteus $(llvm-config --libs) -lclang-cpp
```

If you don't use code annotations, you can omit the `-fpass-plugin` option,
since the LLVM pass is only needed for processing annotations.
The frontend checker loaded by `-fplugin` diagnoses unsupported uses of
`proteus::register_lambda` and `proteus::jit_variable` before LLVM IR is
emitted. If you don't use code annotations or these lambda APIs, you can omit
both plugin options.

!!! note
The example above is the simplest case and is closest to a host-only build.
Expand Down
16 changes: 14 additions & 2 deletions src/pass/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ add_library(ProteusPassOffload SHARED
$<TARGET_OBJECTS:ProteusPassObjects>
)

# Keep the Clang frontend plugin separate from the LLVM pass plugin: the pass
# is also loaded by opt/offload linkers, which do not provide Clang symbols.
add_library(ProteusASTChecker SHARED LambdaASTChecker.cpp)
target_include_directories(ProteusASTChecker SYSTEM PRIVATE
${LLVM_INCLUDE_DIRS}
${CLANG_INCLUDE_DIRS})
if(NOT LLVM_ENABLE_RTTI)
target_compile_options(ProteusASTChecker PRIVATE -fno-rtti)
endif()
target_link_options(ProteusASTChecker
PRIVATE "$<$<PLATFORM_ID:Darwin>:LINKER:SHELL:-undefined dynamic_lookup>")

# Allow undefined symbols in shared objects on Darwin (this is the default
# behaviour on Linux)
target_link_options(ProteusPass
Expand All @@ -72,7 +84,7 @@ target_link_options(
"SHELL:$<$<LINK_LANGUAGE:HIP>:-Xoffload-linker --load-pass-plugin=$<TARGET_FILE:ProteusPassOffload>>"
)

set_target_properties(ProteusPass ProteusPassOffload PROPERTIES
set_target_properties(ProteusPass ProteusPassOffload ProteusASTChecker PROPERTIES
# on macOS enable passing RPATH flags to the linker; no-ops on Linux
MACOSX_RPATH ON
# let CMake use INSTALL_RPATH even in the build tree
Expand All @@ -85,7 +97,7 @@ set_target_properties(ProteusPass ProteusPassOffload PROPERTIES
# is ready to support Clang/LLVM pass consumers too.
if(NOT PROTEUS_PYTHON_WHEEL)
install(
TARGETS ProteusPass ProteusPassOffload
TARGETS ProteusPass ProteusPassOffload ProteusASTChecker
EXPORT proteusTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand Down
Loading
Loading