Commit Graph

5249 Commits

Author SHA1 Message Date
Jiang Yi
097e09d5b7 support defining and declaring default/delete ctor/dtor in cmd prompt
e.g.  class_a::class_a() = default;
      class_a::~class_a();

They have no function definition body so caller of IsClassOrFunction()

should not try to parse their function bodies.
2023-07-18 20:14:07 +02:00
Jonas Hahnfeld
8a633e6d76 Unify access to template_arguments
The other methods, such as directly calling begin() and end() as well
as getNumArgs() and getArgs() will go away in LLVM 16, see commit
https://github.com/llvm/llvm-project/commit/1acffe81ee.
2023-07-11 12:29:06 +02:00
Jonas Hahnfeld
dbb34a4450 Use standard way to set up OverlayFS
This makes it possible to drop our custom CompilerInvocation::addOverlay
functionality (but the rest of the patch that introduced it is still
needed with LLVM 13, so it cannot be reverted for now).
2023-07-11 11:59:07 +02:00
Vassil Vassilev
c2562c72b1 ParseTypeName might trigger deserialization. 2023-07-04 19:29:05 +02:00
Jonas Hahnfeld
4c7a2f1ba7 Add API to iterate already loaded specializations
This avoids deserialization if necessary, for example in DeclUnloader.

See also https://reviews.llvm.org/D154328
2023-07-04 19:29:05 +02:00
Maksymilian Graczyk
67235e8a2a Add jitlink to LLVM_LINK_COMPONENTS in relevant cling parts 2023-07-01 12:44:07 +02:00
Jonas Hahnfeld
30e1bd3c7d Remove checks for deprecated _REENTRANT macro
According to feature_test_macros, this macro is obsolete and "glibc
has been thread-safe by default for many years." Other platforms
don't use it at all, for example FreeBSD.

Some parts of ROOT used it to determine if we are compiling with
-pthread, but this is essentially unused these days because the
CMake build always enables threading support and there exists no
option to turn it off.
2023-06-30 11:14:03 +02:00
Jonas Hahnfeld
95cdce8055 Adopt upstream llvm-project monorepo directory layout (#13049)
This will be required for future LLVM upgrades that rely on a common
cmake/ directory next to clang/ and llvm/.

The bulk of this change is the result of the following commands:
 $ mkdir interpreter/llvm-project/
 $ git mv interpreter/llvm/src/tools/clang/ interpreter/llvm-project/clang/
 $ git mv interpreter/llvm/src/ interpreter/llvm-project/llvm/
 $ git mv interpreter/llvm/llvm-project.tag interpreter/llvm-project/llvm-project.tag
2023-06-25 13:44:07 +02:00
Mikolaj Krzewicki
acb2334131 Initial support for building on FreeBSD (#12996)
Co-authored-by: Mikolaj Krzewicki <Mikolaj Krzewicki mkrzewicki@gmail.com>
2023-06-22 11:14:05 +02:00
Jiang Yi
a1b1c875fd startup script support
Before showing command promt or executing scripts from argv,
enumerate .C files in the directory ${CLING_HOME}/.cling.d/ in alphabetic
order then .x them.

Search order of ${CLING_HOME}:

1. ${CLING_HOME} envvar
2. ${XDG_CONFIG_HOME}/cling/
3. ${HOME}/.config/cling/
4. ${HOME}/
2023-06-16 16:29:08 +02:00
Jonas Hahnfeld
ee2c1bbe2d Remove module for xlocale.h
As commit 2db042523a explains, this header doesn't exist anymore since
glibc 2.26. The oldest distributions that ROOT currently supports are
EL8 and Debian 10, both of which have glibc 2.28. Remove the module as
it also causes problems on FreeBSD due to including locale.h and a
cyclic dependency std -> xlocale.h -> std.
2023-06-13 11:44:04 +02:00
Jiang Yi
42e296f28c meta cmd .x should not crash if no arg is given 2023-06-07 21:59:06 +02:00
Javier Lopez-Gomez
1cca2f0f7e Restore symbol lookup in child interpreters
Prior to the upgrade to LLVM13, child interpreters used to also lookup symbols
in their parent.
This commit introduces a `DefinitionGenerator` that allows for symbol lookup
across different `IncrementalJIT` instances, which restores the old behavior.

This change fixes the following tests:
- CodeUnloading/AtExit.C
- MultipleInterpreters/MultipleInterpreters.C

Fixes #12455.
2023-05-31 21:29:03 +02:00
Javier Lopez-Gomez
09fe1fd2b3 DeclExtractor: use BuildReturnStmt() instead
Do not use `ActOnReturnStmt()`, given that the scope returned by
`m_Sema->getCurScope()` might be == m_Sema->TUScope which obviously is
not a function scope.

This fixes the following crash:
```
1:  #3 0x0000556b6a50389e clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*, clang::Scope*) (/home/jalopezg/CERN/repos/root/_build/interpreter/llvm/src/bin/cling+0x225389e)
1:  #4 0x0000556b69215c56 cling::DeclExtractor::EnforceInitOrder(llvm::SmallVector<clang::Stmt*>&) (/home/jalopezg/CERN/repos/root/_build/interpreter/llvm/src/bin/cling+0xf65c56)
1:  #5 0x0000556b69216788 cling::DeclExtractor::ExtractDecl(clang::FunctionDecl*) (/home/jalopezg/CERN/repos/root/_build/interpreter/llvm/src/bin/cling+0xf66788)
1:  #6 0x0000556b69216a75 cling::DeclExtractor::Transform(clang::Decl*) (/home/jalopezg/CERN/repos/root/_build/interpreter/llvm/src/bin/cling+0xf66a75)
```
2023-05-31 21:29:03 +02:00
Jonas Hahnfeld
f23f0ed9ca Re-download all Clad patches from GitHub
This guarantees valid patch files.
2023-05-30 09:14:07 +02:00
Bertrand Bellenot
9735886a70 Fix failing patch on Windows (#12882)
* Fix failing patch on Windows

Fix `fatal: corrupt patch at line 28` on Windows

* More trailing white spaces
2023-05-25 15:14:06 +02:00
Jonas Hahnfeld
833c1c1b75 Simplify logic for build with old toolchain
Setting LLVM_FORCE_USE_OLD_TOOLCHAIN will skip all checks in
interpreter/llvm/src/cmake/modules/CheckCompilerVersion.cmake, which
is what we want.
2023-05-25 11:14:05 +02:00
Javier Lopez-Gomez
ef943ddcfa Always promote warn_falloff_nonvoid_function to error
This diagnostic should always be promoted to error, regardless of the ignoring
state in `FilteringDiagConsumer`.
This fixes the SourceCall/ErrorMacro.C test.

The failure became visible after merging
https://github.com/root-project/root/pull/12654, given that `IgnorePromptDiags`
now defaults to 0 in `makeDefaultCompilationOptions()`.
2023-05-19 23:29:06 +02:00
Javier Lopez-Gomez
5ca904dabd Fix DynamicLibraryManager/cached_realpath.C test
Fetching the value of `errno` only makes sense after a failed call to
`realpath()`, i.e. if the return value of the function is NULL.
2023-05-19 23:29:06 +02:00
Javier Lopez-Gomez
4d49306895 Fix DynamicLibraryManager/callable_lib_L_AB_order1.C test
`--enable-new-dtags` is needed in some toolchains to emit the new ELF dynamic
tags, i.e. RUNPATH.
Per ld(1) manual page: `By default, the new dynamic tags are not created.`
2023-05-19 23:29:06 +02:00
Javier Lopez-Gomez
e635331e85 Fix CodeUnloading/Macros.C test
Clang diagnostic verification was unhappy with the previous state of
affairs. Move affected `expected-(warning|note)` markers to `Macros.h`.

Apparently, as Jonas Hahnfeld found, this failure originated in commit
8deb57c04a5ceea96533d095092fcd4f71d1df94, but is not to be reverted
per discussion in https://github.com/root-project/root/pull/12454.
2023-05-19 23:29:06 +02:00
Javier Lopez-Gomez
11a1a348f8 DeclUnloader: remove TagDecls after all other decls
The order in which declarations are removed makes a difference, e.g.
`MaybeRemoveDeclFromModule()` may require access to type information to
make up the mangled name.

Thus, we segregate declarations to be removed in `TagDecl`s (i.e., struct
/ union / class / enum) and other declarations.  Removal of `TagDecl`s
is deferred until all the other declarations have been processed.
Declarations in each group are iterated in reverse order.

Fixes #12457.
2023-05-19 23:14:06 +02:00
Jonas Hahnfeld
badb929352 Fix C++14 build with GCC 12
Since adding bits/utility.h in commit e9a8c48e4f, a C++14 build with
GCC 12 (and potentially also other compiler versions) failed with
```
While building module 'Core':
While building module 'std' imported from input_line_1:1:
In file included from <module-includes>:38:
/opt/gcc/12.2.0/include/c++/12.2.0/functional:337:35: error: missing '#include <bits/utility.h>'; 'tuple_size' must be declared before it is used
      = typename enable_if<(__i < tuple_size<_Tuple>::value),
                                  ^
/opt/gcc/12.2.0/include/c++/12.2.0/bits/utility.h:49:12: note: declaration here is not visible
    struct tuple_size;
           ^
```

Apparently, once the module is declared, it must also be enabled for
C++14 and not restricted with cplusplus17.
2023-05-10 14:59:07 +02:00
Javier Lopez-Gomez
5f576a2ba8 DefinitionShadower: fix crash with C++20 concepts
In principle, for a TemplateDecl, `isDefinition()` issues a recursive
call passing the templated decl as a parameter.  A `ConceptDecl` is
derived from `TemplateDecl`, however, it should always be considered
a definition.

Also, update the DeclShadowing test incorporating a C++20 concept.

Fixes #12779.
2023-05-08 00:14:05 +02:00
Sergey Linev
ad5841e05c Fix std.modulemap for gcc13 (#12765)
* Fix std.modulemap for gcc13
* Update interpreter/cling/include/cling/std.modulemap

Co-authored-by: Vassil Vassilev <v.g.vassilev@gmail.com>
2023-05-05 15:44:04 +02:00
Vassil Vassilev
ea8b591452 Add memory_resource header to the modulemap. 2023-05-03 21:29:07 +02:00
Jonas Hahnfeld
4267bda54b Extend for C++20 with gcc13
Add more headers to solve merging issues with C++20.
2023-04-29 11:44:05 +02:00
Jonas Hahnfeld
03f61a8ac9 Extend for C++20 with gcc11
The new header bits/uses_allocator_args.h requires a module to solve
merging issues with C++20, but did not exist in older versions.
2023-04-29 11:44:05 +02:00
Jonas Hahnfeld
664f0837d4 Extend for C++20 with gcc10
Define bits/ranges_base.h as optional, it did not exist in the old
version of the compiler. Add two more modules to solve merging issues
with C++20.
2023-04-29 11:44:05 +02:00
Garima Singh
7c492a17c9 Add AD support for RooChebychev and RooAddPdf. 2023-04-27 00:14:06 +02:00
Garima Singh
32a72240d2 Add code-squash support for RooPolyVar and RooPolynomial. 2023-04-25 17:44:04 +02:00
Javier Lopez-Gomez
a0d186073b Ignore -Wunused-result in wrapped code
Make `FilteringDiagConsumer` also ignore -Wunused-result. Whether or not
such diagnostic is filtered depends on `CompilationOptions::IgnorePromptDiags`.

In particular, `IgnorePromptDiags` should _only_ be enabled for code parsed
via `Interpreter::EvaluateInternal()`.  Thus, as of this commit `IgnorePromptDiags`
defaults to 0 in `makeDefaultCompilationOpts()`

The observable effect of this change is ignoring `-Wunused-result` for
wrapped code, e.g.
```c++
[[nodiscard]] int f() { return 0; }

// This yields `warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]`
void g() { f(); }

f(); // but this should not
```
2023-04-20 15:14:04 +02:00
Axel Naumann
37658ca14b bits/chrono.h exists already with C++11:
It is needed for C++11 support of #include <chrono>. Failures:
```
Processing /home/sftnight/build/night/LABEL/ROOT-fedora36/SPEC/default/V/master/root/tutorials/multicore/mt201_parallelHistoFill.C...
In file included from input_line_10:1:
/home/sftnight/build/night/LABEL/ROOT-fedora36/SPEC/default/V/master/root/tutorials/multicore/mt201_parallelHistoFill.C:55:51: error: no member named 'duration' in namespace 'std::chrono'
         std::this_thread::sleep_for(std::chrono::duration<double, std::nano>(500));
                                     ~~~~~~~~~~~~~^
```

and

```
root [11] #include <bits/chrono.h>
/home/sftnight/build/night/LABEL/ROOT-fedora36/SPEC/default/V/master/build/etc/cling/std.modulemap:432:10: error: module 'std.bits/chrono.h' requires feature 'cplusplus17'
  module "bits/chrono.h" [optional] {
         ^
ROOT_prompt_11:1:10: note: submodule of top-level module 'std' implicitly imported here
         ^
```
2023-04-19 12:59:06 +02:00
Axel Naumann
eaaf95f5c8 Pass isysroot to clang when determining stdlib incpath:
isysroot influences where clang will pick up libc++. Without this, and with
Xcode 14.3, cling will use libc++ from Xcode (or the command line tools) rather
than stdc++ from the macOS SDK, as clang would normally use. Passing the isysroot
(which point to the SDK) fixes this.

This solves build errors such as:
```
While building module 'Core':
While building module 'std' imported from input_line_1:1:
In file included from <module-includes>:17:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/math.h:309:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:462:1: error: cannot template a using declaration
using _BoolConstant _LIBCPP_NODEBUG_TYPE = integral_constant<bool, _Val>;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:462:21: error: C++ requires a type specifier for all declarations
using _BoolConstant _LIBCPP_NODEBUG_TYPE = integral_constant<bool, _Val>;
                    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:462:68: error: use of undeclared identifier '_Val'
using _BoolConstant _LIBCPP_NODEBUG_TYPE = integral_constant<bool, _Val>;
                                                                   ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:462:73: error: expected '(' for function-style cast or type construction
using _BoolConstant _LIBCPP_NODEBUG_TYPE = integral_constant<bool, _Val>;
                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
```
2023-04-06 13:59:05 +02:00
Vassil Vassilev
f7571c07f5 Implement a module attribute 'optional' to allow missing headers.
This deals with the fact that our modulemaps include headers which can vary
across library versions and that attribute is a way to express this.
2023-03-30 17:59:05 +02:00
Vassil Vassilev
d09d5a71b7 Reland "[cxxmodules] Add more bits headers to fix module merging issues."
This reverts commit f6327a6e56861d95f34d1a85a47dcc616b335dc3.
2023-03-30 17:59:05 +02:00
Vassil Vassilev
ba13f18449 Reland "Add a module for stl_iterator_base_funcs.h avoiding merging issues for c++20"
This reverts commit 4a3258a492f4ed9660311efe12e9dbe7cd7ed188.
2023-03-30 17:59:05 +02:00
Axel Naumann
6d52a95449 Revert "Add a module for stl_iterator_base_funcs.h avoiding merging issues for c++20"
This reverts commit a4c07502a3e76c82f30828200f5fe4ae935ac166.

While this itself might not cause build issues, the related commit 90ffa89ae4 does;
handle them together.
2023-03-21 15:29:04 +01:00
Axel Naumann
f2bc02a68b Revert "[cxxmodules] Add more bits headers to fix module merging issues."
This reverts commit 90ffa89ae46b48c634547d6abd861a524a5d27c7.
It causes build failures on GCC 12.2.1 / c++17 with

```
[ 70%] Generating G__Core.cxx, ../lib/Core.pcm
In file included from input_line_7:111:
/home/linev/build/webgui/include/ROOT/RDirectoryEntry.hxx:31:33: error: missing '#include <bits/chrono.h>'; 'system_clock' must be declared before it is used
   using clock_t = std::chrono::system_clock;
                                ^
/usr/include/c++/12/bits/chrono.h:1110:12: note: declaration here is not visible
    struct system_clock
           ^
In module 'std' imported from input_line_1:1:
/usr/include/c++/12/bits/move.h:204:11: error: missing '#include <bits/chrono.h>'; 'time_point' must be defined before it is used
      _Tp __tmp = _GLIBCXX_MOVE(__a);
          ^
/home/linev/build/webgui/include/ROOT/RDirectoryEntry.hxx:89:4: note: in instantiation of function template specialization 'std::swap<std::chrono::time_point<std::chrono::system_clock, std::chrono::duration<long, std::ratio<1, 1000000000>>>>' requested here
   swap(fDate, other.fDate);
   ^
/usr/include/c++/12/bits/chrono.h:856:14: note: definition here is not reachable
      struct time_point
```
2023-03-21 15:29:04 +01:00
Vassil Vassilev
782cc41a6c Add more bits headers to fix module merging issues. 2023-03-21 09:29:07 +01:00
Vassil Vassilev
2cebf663dc Add a module for stl_iterator_base_funcs.h avoiding merging issues for c++20 2023-03-21 09:29:07 +01:00
Jonas Hahnfeld
1499c8c74f Use compiled Module for stored states
Since the upgrade to LLVM 13, the JIT infrastructure takes ownership
of the Module. After JIT compilation, we get back a (const) pointer
to the compiled module.

This fixes the Cling test ErrorRecovery/StoredState.C.
2023-03-09 11:14:07 +01:00
Axel Naumann
33de07df48 Do not try to find runtime headers in ./:
These headers are part of cling, not user code, so starting
with the current directory is pointless and can actually be
counterproductive.

This helps with https://github.com/root-project/root/issues/12409
but not enough; any dictionary header will still try to access "./".
2023-03-03 17:59:05 +01:00
Jonas Hahnfeld
8c3b18f683 Forward ABIName to MCTargetOptions
This is required on RISC-V where Linux uses the lp64d ABI that allows
the usage of floating point registers to pass arguments. It seems to
work out-of-the-box upstream in clang-repl which passes through the
function initTargetOptions in clang/lib/CodeGen/BackendUtil.cpp with
the same effect.
2023-03-01 19:14:06 +01:00
Jonas Hahnfeld
eb82dc505a Use JITLink on RISC-V
RuntimeDyld does not support RISC-V, so it makes sense to enable
JITLink by default. This also makes relocations work without support
for a large code model.

See the equivalent change upstream in https://reviews.llvm.org/D129092,
committed for LLVM 15 in a4e2c1f762
2023-03-01 19:14:06 +01:00
Jonas Hahnfeld
e65614cb92 Disable outline-atomics on AArch64
The routines __aarch64_* are defined in the static library libgcc.a
and not necessarily included in libCling or otherwise present in the
process, so the interpreter has a hard time finding them.

Fixes #12294
2023-02-20 22:14:04 +01:00
Vassil Vassilev
e26c70ae49 Remove the problematic uses_allocator_args.h
It is not present on some versions of libstdc++ which makes the compilation
of Core.pcm fail.
2023-02-17 10:29:02 +01:00
Vassil Vassilev
b474a0ab43 Add a module for experimental/string_view
Recent gcc updates somehow make experimental/string_view available through
module string_view. Then it wrongly decides it needs to include
"bits/ranges_base.h" which is a c++14 header and breaks the compilation in case
of c++11.

This patch adds a proper experimental/string_view to disallow such shadowing.
2023-02-17 10:29:02 +01:00
Bertrand Bellenot
b3b15d60e1 Fix modules and modules.idx generation on Windows and disable a few more modules causing potential crashes (#12252)
* Fix modules and modules.idx generation on Windows and disable a few more modules causing potential crashes

* Introduce a new TROOT::GetSharedLibDir() method to reduce the need of #ifdef R__WIN32

* Use the value of ROOT_GET_LIBRARY_OUTPUT_DIR instead of CMAKE_RUNTIME_OUTPUT_DIRECTORY (which is the same anyway)

* cleanup the code

* Remove unnecessary check
2023-02-17 08:44:05 +01:00
Jonas Hahnfeld
75930f9dfd Set DataLayout from our TargetMachine (#12335)
Otherwise LLJIT's constructor will ask the LLJITBuilder's JTMB to
create a DataLayout. As we don't propagate the JTMB (yet -- we
probably should!), this will be wrong if target features influence
the DataLayout.

This should fix #12293.
2023-02-16 20:44:03 +01:00