Skip to content
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

Enable CppInterOp #16814

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion core/metacling/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ target_include_directories(MetaCling SYSTEM PRIVATE
${CLANG_INCLUDE_DIRS}
${LLVM_INCLUDE_DIRS}
${CLAD_INCLUDE_DIRS}
${CPPINTEROP_INCLUDE_DIRS}
)

target_include_directories(MetaCling PRIVATE
Expand Down Expand Up @@ -74,7 +75,8 @@ if(MSVC)
set_source_files_properties(TCling.cxx COMPILE_FLAGS /bigobj)
endif()

add_dependencies(MetaCling CLING)
add_dependencies(MetaCling CLING clangCppInterOp)
# target_include_directories(MetaCling SYSTEM PUBLIC ${source_dir}/include/)
Copy link
Member

Choose a reason for hiding this comment

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

Can you move these modifications to the next commit, where CppInterOp is used?


##### libCling #############################################################

Expand Down Expand Up @@ -113,6 +115,7 @@ ROOT_LINKER_LIBRARY(Cling
$<TARGET_OBJECTS:ClingUtils>
$<TARGET_OBJECTS:Dictgen>
$<TARGET_OBJECTS:MetaCling>
$<TARGET_OBJECTS:clangCppInterOp>
LIBRARIES ${CLING_LIBRARIES} ${LINK_LIBS} ${CLING_PLUGIN_LINK_LIBS})

# When these two link at the same time, they can exhaust the RAM on many machines, since they both link against llvm.
Expand Down
26 changes: 26 additions & 0 deletions interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -599,3 +599,29 @@ mark_as_advanced(FORCE BUG_REPORT_URL BUILD_CLANG_FORMAT_VS_PLUGIN BUILD_SHARED_
C_INCLUDE_DIRS DEFAULT_SYSROOT FFI_INCLUDE_DIR FFI_LIBRARY_DIR
GCC_INSTALL_PREFIX LIBCLANG_BUILD_STATIC TOOL_INFO_PLIST)
mark_as_advanced(CLEAR LLVM_ENABLE_ASSERTIONS LLVM_BUILD_TYPE)


##################### LIBINTEROP ###########################
# Set the paths to Cling, Clang, and LLVM directories

# if (cppinterop)

set(LLVM_DIR "${CMAKE_BINARY_DIR}/interpreter/llvm-project/llvm/lib/cmake/llvm")
set(Clang_DIR "${CMAKE_BINARY_DIR}/interpreter/llvm-project/llvm/tools/clang/lib/cmake/clang")
set(Cling_DIR "${CMAKE_BINARY_DIR}/interpreter/cling")
Comment on lines +609 to +611
Copy link
Member

Choose a reason for hiding this comment

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

This will need adapting for externally built LLVM, Clang, and / or Cling. For LLVM and Clang, I believe this should already be taken care of above, no?

set(CPPINTEROP_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/interpreter/CppInterOp/include
CACHE STRING "CppInterOp include directories.")

# message(STATUS "LLVM_DIR: ${LLVM_DIR}")
# message(STATUS "CLING: ${Cling_DIR}")
# message(STATUS "CLANG: ${Clang_DIR}")
# message(STATUS "CLANG INCLUDE DIR: ${CLANG_INCLUDE_DIRS}")
# message(STATUS "IOP INCLUDE DIR: ${CPPINTEROP_INCLUDE_DIRS}")

set(USE_CLING ON CACHE BOOL "Use Cling as backend" FORCE)
set(USE_REPL OFF CACHE BOOL "Use Clang-repl as backend" FORCE)

add_subdirectory(CppInterOp)

# endif()
17 changes: 17 additions & 0 deletions interpreter/CppInterOp/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
BasedOnStyle: LLVM

Language: Cpp
Standard: Cpp11
PointerAlignment: Left

IncludeCategories:
- Regex: '^"[^/]+\"'
Priority: 10
- Regex: '^"cling/'
Priority: 20
- Regex: '^"clang/'
Priority: 30
- Regex: '^"llvm/'
Priority: 40
- Regex: '^<'
Priority: 50
59 changes: 59 additions & 0 deletions interpreter/CppInterOp/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Checks: >
-*,
bugprone-*,
clang-diagnostic-*,
clang-analyzer-*,
cppcoreguidelines-*,
llvm-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-bugprone-narrowing-conversions,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-unchecked-optional-access,
-misc-const-correctness,
-misc-unused-parameters,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
-misc-use-anonymous-namespace,
-modernize-return-braced-init-list,
-modernize-use-trailing-return-type,
-readability-braces-around-statements,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-magic-numbers,
-readability-named-parameter,
-readability-function-cognitive-complexity,
-readability-redundant-access-specifiers,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-member-init,
-llvm-namespace-comment

CheckOptions:
- key: readability-identifier-naming.ClassCase
value: aNy_CasE
- key: readability-identifier-naming.FunctionCase
value: aNy_CasE
- key: readability-identifier-naming.MemberCase
value: aNy_CasE
- key: readability-identifier-naming.ParameterCase
value: aNy_CasE
- key: readability-identifier-naming.UnionCase
value: CamelCase
- key: readability-identifier-naming.VariableCase
value: aNy_CasE
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 1
- key: cppcoreguidelines-avoid-magic-numbers.IgnoreMacros
value: 1
- key: cppcoreguidelines-pro-bounds-pointer-arithmetic.Pessimistic
value: 1
- key: cppcoreguidelines-pro-type-member-init.InitWithEquals
value: 1
- key: llvm-namespace-comment.Spaces
value: 2
25 changes: 25 additions & 0 deletions interpreter/CppInterOp/.codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
codecov:
require_ci_to_pass: no

coverage:
precision: 2
round: down
range: "70...100"

status:
project: yes
patch: yes
changes: no

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach, diff, flags, tree, files"
behavior: default
require_changes: no
39 changes: 39 additions & 0 deletions interpreter/CppInterOp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Directories
build
install

# CLion files
.idea
16 changes: 16 additions & 0 deletions interpreter/CppInterOp/.readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

sphinx:
configuration: docs/conf.py
builder: html

build:
os: "ubuntu-22.04"
tools:
python: "3.11"
apt_packages:
- clang-13
- cmake
- libclang-13-dev
- llvm-13-dev
- llvm-13-tools
Loading