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
26 changes: 26 additions & 0 deletions .github/workflows/cppinterop-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Diff CppInterOp against upstream
on:
pull_request:
paths:
- 'interpreter/CppInterOp/**'

jobs:
cppinterop-diff:
runs-on: ubuntu-latest
steps:
- name: Check out ROOT
uses: actions/checkout@v4
with:
path: root
- name: Check out CppInterOp
uses: actions/checkout@v4
with:
repository: compiler-research/CppInterOp
ref: 6c6f94a22bd971520a249e2c02e4259cdd3a5be6
path: CppInterOp
- name: Drop directories that are not added to ROOT
working-directory: CppInterOp
run: |
rm -rf .git .github discord.svg
- name: Compare
run: diff -ur CppInterOp/ root/interpreter/CppInterOp/
9 changes: 7 additions & 2 deletions 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,7 @@ if(MSVC)
set_source_files_properties(TCling.cxx COMPILE_FLAGS /bigobj)
endif()

add_dependencies(MetaCling CLING)
add_dependencies(MetaCling CLING clangCppInterOp)

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

Expand Down Expand Up @@ -113,11 +114,15 @@ ROOT_LINKER_LIBRARY(Cling
$<TARGET_OBJECTS:ClingUtils>
$<TARGET_OBJECTS:Dictgen>
$<TARGET_OBJECTS:MetaCling>
LIBRARIES ${CLING_LIBRARIES} ${LINK_LIBS} ${CLING_PLUGIN_LINK_LIBS})
LIBRARIES ${CLING_LIBRARIES} clangCppInterOp ${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.
add_dependencies(Cling rootcling_stage1)

if(testing)
add_dependencies(Cling CppInterOpUnitTests)
endif()

if(MSVC)
set_target_properties(Cling PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
set(cling_exports ${cling_exports}
Expand Down
7 changes: 7 additions & 0 deletions core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ clang/LLVM technology.
#include "cling/Utils/SourceNormalization.h"
#include "cling/Interpreter/Exception.h"

#include "clang/Interpreter/CppInterOp.h"

#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Module.h"

Expand Down Expand Up @@ -1539,6 +1541,11 @@ TCling::TCling(const char *name, const char *title, const char* const argv[], vo
if (!fInterpreter->getCI()) { // Compiler instance could not be created. See https://its.cern.ch/jira/browse/ROOT-10239
return;
}

// Tell CppInterOp that the cling::Interpreter instance is managed externally by ROOT
// Sets the interpreter by passing the fInterpreter handle as soon as TCling is initialized
Cpp::UseExternalInterpreter((Cpp::TInterp_t*)fInterpreter.get());

// Don't check whether modules' files exist.
fInterpreter->getCI()->getPreprocessorOpts().DisablePCHOrModuleValidation =
DisableValidationForModuleKind::All;
Expand Down
12 changes: 12 additions & 0 deletions interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -514,3 +514,15 @@ 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 InterOp include directories, for any ROOT component that requires the headers--------------------------------------------------------
set(CPPINTEROP_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/CppInterOp/include
CACHE STRING "CppInterOp include directories.")

#---Set InterOp to build on Cling, this can be toggled to use Clang-REPL-------------------------------------------------------
set(CPPINTEROP_USE_CLING ON BOOL "Use Cling as backend")

add_subdirectory(CppInterOp)
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
60 changes: 60 additions & 0 deletions interpreter/CppInterOp/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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,
-cppcoreguidelines-macro-usage,
-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
41 changes: 41 additions & 0 deletions interpreter/CppInterOp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Prerequisites
*.d

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

# Precompiled Headers
*.gch
*.pch

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

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

# Executables
*.exe
*.out
*.app

# Directories
build
install

# CLion files
.idea

# VSCode files
.vscode

# Default Virtual Environments
.venv
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
Loading