Commit Graph

5032 Commits

Author SHA1 Message Date
Jonas Hahnfeld
dc6ee2401b Add back basic support for JITLink
The custom memory manager is only needed to avoid freeing the memory
segments; the default InProcessMemoryManager (which is mostly copied)
already does slab allocation to keep all segments together which is
needed for exception handling support.

A limitation of this rudimentary support is that CLING_DEBUG and
CLING_PROFILE do not work, they need to be registered as plugins.
2023-02-01 13:44:06 +01:00
Javier Lopez-Gomez
41c41c26df Add missing const in operator== and operator!=
Add missing `const` in `{DelayCall,MacroDirective}Info::operator==`
and `operator!=`. This fixes the following warnings in C++20
```
interpreter/cling/lib/Interpreter/Transaction.cpp:173:23: warning: ISO C++20 considers use of overloaded operator '!=' (with operand types 'cling::Transaction::DelayCallInfo' and 'cling::Transaction::DelayCallInfo') to be ambiguous despite there being a unique best viable function with non-reversed arguments [-Wambiguous-reversed-operator]
interpreter/cling/lib/Interpreter/Transaction.cpp:218:21: warning: ISO C++20 considers use of overloaded operator '==' (with operand types 'cling::Transaction::MacroDirectiveInfo' and 'cling::Transaction::MacroDirectiveInfo') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator]
```
2023-02-01 08:29:04 +01:00
Vassil Vassilev
c0cebd2c70 Adjust the modulemap for c++20 2023-02-01 08:29:04 +01:00
Vassil Vassilev
93e72c9d88 Revert "[cling] Add dedicated C++20 stl-modulemap:"
This reverts commit 82f1619a7179088c61bedd2f5d38d158957c7bde.
2023-02-01 08:29:04 +01:00
Axel Naumann
b8edc28315 Add dedicated C++20 stl-modulemap:
The bits/ headers have different include behavior (mostly due to ranges)
that makes it significantly harder to find a configuration working for
C++14, 17, and 20. Instead, create a dedicated modulemap for C++20.
2023-02-01 08:29:04 +01:00
Axel Naumann
f2b325b312 Keep private symbols private:
llvm IR naming of private constants (CodeGenModule::createUnnamedGlobalFrom(),
line 1136) will name private symbols without caring about possible name clashes.
We will create these name clashes by marking such private symbols as weak ones,
re-using previously emitted symbols (e.g. in JITDylib::defineImpl() where they
get added to MUDefsOverridden and thus re-used instead of re-emitted).

Let me see what happens when we keep private symbols private. In principle, the
interpreter should have no means fo accessing them from another transaction -
private symbols seem to be function-local ones.

Fixes https://github.com/root-project/root/pull/12183
2023-01-31 22:59:06 +01:00
Jiang Yi
da57784037 Set history size to ${CLING_HISTSIZE}
It was left unset. Then the default hist size was

static_cast<size_t>(-1), which is practically equivalent to unlimited

history size.
2023-01-30 10:29:07 +01:00
ferdymercury
c3dd723262 fix some more warnings in core 2023-01-30 10:29:07 +01:00
Sergey Linev
f4d11176e6 Use nullptr in core/textinput classes 2023-01-30 10:29:07 +01:00
ferdymercury
a78c5a41eb Implement .help edit (show line editor keybindings)
Co-authored-by: Javier Lopez-Gomez <javier.lopez.gomez@cern.ch>
Co-authored-by: Olivier Couet <Olivier.Couet@cern.ch>
2023-01-30 10:29:07 +01:00
Javier Lopez-Gomez
401f877780 Do not assign ESC a special meaning on history search mode
UNIX terminals, e.g. vt100, send escape sequences for many special
key combinations. Entering the history search mode assigned a specific
meaning to the ESC character and disabled the processing of escape
sequences, thus accidentally printing some characters that are part
of a CSI.

As a workaround, avoid changing the meaning of ESC; users can still
use the well-known `ESC ESC` sequence (or any other editor command,
e.g. move left/right) to exit the history search mode.

This change only affects UNIX terminals.

Closes issue #10209.
2023-01-30 10:29:07 +01:00
ferdymercury
0d46b6dead Implement forward history search
Co-authored-by: Javier Lopez-Gomez <javier.lopez.gomez@cern.ch>

Fixes #10137
2023-01-30 10:29:07 +01:00
Javier Lopez-Gomez
07120b98da Clear undo buffer after taking an input line
The undo buffer should only be kept for the current line (as in GNU readline).

Fixes #10182.
2023-01-30 10:29:07 +01:00
ferdymercury
97166bc3b2 prevent accessing empty vector
Fixes https://github.com/root-project/root/issues/10180
2023-01-30 10:29:07 +01:00
Javier Lopez-Gomez
a575990cfc Fix implementation of the kCmdWordTo{Lower,Upper} editor commands
These commands, bound respectively to `ESC l` and `ESC u`, should {lower,upper}case
the next word; however, only the first character was changed.

Fixes #10136.
2023-01-30 10:29:07 +01:00
Javier Lopez-Gomez
01ffa06f0a Add a missing new-line after .q if quitting a ROOT session via Ctrl+D (EOF)
Fixes #10135.
2023-01-30 10:29:07 +01:00
Javier Lopez-Gomez
2dd8debdfb Fix implementation of kCmdSwapThisAndLeftThenMoveRight
This editor command (usually binded to Ctrl+T), transposes the character located
at the cursor and the one to its left.
However, its behavior was incorrect if the cursor was at end of the line,
invoking `std::string::operator[]()` passing an index that is out of bounds.

In that case, as per GNU Readline behavior, it should swap the two last
characters.

Closes #10133.
2023-01-30 10:29:07 +01:00
Javier Lopez-Gomez
3914be144e Bind Ctrl+Del to Editor::kCmdCutNextWord (kill next word)
This change is equivalent to the popular GNU Readline keybinding
```
"\e[3;5~": kill-word
```

As a requirement, the `[3;5~` CSI was added in StreamReaderUnix.cpp. No
additional changes required to StreamReaderWin.cpp.
2023-01-30 10:29:07 +01:00
Javier Lopez-Gomez
3a448596c6 Fix [-Winconsistent-missing-override] warnings on Apple's clang 2023-01-30 10:29:07 +01:00
Javier Lopez-Gomez
d654717749 Clear the terminal screen on Ctrl+L
Fixes #10057.
2023-01-30 10:29:07 +01:00
Javier Lopez-Gomez
106c95fb1b Add Display::Clear(): clear the terminal screen
Writes the `\033[2J\033[H` sequence to clear the visible part of the screen.
For Windows, this requires to temporarily enable processing of VT control
sequences.
2023-01-30 10:29:07 +01:00
Javier Lopez-Gomez
d077fb1048 Enable Xterm-like movement between words, i.e. using Ctrl+{Left,Right}
Enable fast word movement à la Xterm (using Ctrl+Left and Ctrl+Right). Most
users coming from a GUI (GTK+, Win32, etc.) will find this convenient, but also
Archlinux users, given that the default `inputrc` file for GNU Readline providesthese bindings (see https://wiki.archlinux.org/title/Readline#Fast_word_movement).
2023-01-30 10:29:07 +01:00
Sergey Linev
677d59246c Remove unused variable 2023-01-30 10:29:07 +01:00
Sergey Linev
3c40fef28b Modernize core/thread core/textinput includes
Declare non-implmented constructors as delete;
2023-01-30 10:29:07 +01:00
Sergey Linev
0525bca060 Use nullptr in cling
Avoid warnings when -Wzero-as-null-pointer-constant is specified
2023-01-30 08:29:07 +01:00
ferdymercury
9cdbf1d0eb nullptr use
clingUtils modernize nullptr
2023-01-26 08:59:06 +01:00
Jiang Yi
1d5536fd0b Test cmd history support 2023-01-25 13:59:06 +01:00
Jiang Yi
90a7639461 Support setting cmd history file by ${CLING_HISTFILE} 2023-01-25 13:59:06 +01:00
Jiang Yi
392d5365d5 Set history size to ${CLING_HISTSIZE}
It was left unset. Then the default hist size was

static_cast<size_t>(-1), which is practically equivalent to unlimited

history size.
2023-01-25 13:59:06 +01:00
Jonas Hahnfeld
d47b49c3ee Reset function sections before JITting (#12069)
This makes all functions end up in the same text section, which is
important for TCling on macOS to catch exceptions from constructors:
Stack unwinding requires information about program addresses to find
out which objects to destroy and what code should be called to handle
the exception. These addresses are relocated against a single __text
section when loading the produced MachO binary, which breaks if the
call sites of global constructors end up in a separate init section.

Fixes ROOT-10703 and ROOT-10962

(cherry picked from commit 028fcca0fa76111877751df876cf13968be602f9)
2023-01-24 10:29:05 +01:00
Vassil Vassilev
2949bf96b7 Bump clad version to v1.1.
This new release includes some improvements:
  * Improvements in the array handling in the Error Estimation Framework
  * Fixed numerical stability of the pow pushforward
  * Fixed handling of for-loop conditions in reverse mode
  * LLVM15 Support

See more at: https://github.com/vgvassilev/clad/blob/v1.1/docs/internalDocs/ReleaseNotes.md
2023-01-23 19:59:07 +01:00
Jonas Hahnfeld
2f48c65752 Explicitly create FunctionDecl in DeclExtractor
The function EnforceInitOrder() was using ImplicitlyDefineFunction()
as a shortcut to define a function returning an int. Future upgrades
of LLVM will add an assert in that function because it is not allowed
to be used when compiling C++, which Cling obviously does.
2023-01-23 18:44:07 +01:00
Vassil Vassilev
2129e96274 Do not register LLVMSupport as a library when it should be a component (#11703)
Do not register LLVMSupport as a library when it should be a component

LLVM component must be registered as LLVM_LINK_COMPONENTS to be
compatible with LLVM Dylib. Otherwise they are loaded twice in the final
binary, once through LLVM Dylmib and once through individual component,
and this results in some options being registered twice.

Fix root-project/cling#440
2023-01-20 16:59:05 +01:00
Jonas Hahnfeld
e1ae677300 Fix in-process lookup of symbols without GlobalPrefix
On Windows, C++ symbols are prefixed not with the "global" prefix,
but with a question mark.
2023-01-20 08:44:02 +01:00
Jonas Hahnfeld
10912bdab3 Remove explicit setting of COFF binary format on Windows
This is the default anyway.
2023-01-20 08:44:02 +01:00
Axel Naumann
931552f385 Silence macOS linker warnings on -undefined dynamic_lookup:
See https://github.com/root-project/root/issues/11937
for why that is currently needed. `flat_namespace` is not a solution.
2023-01-19 12:59:06 +01:00
Axel Naumann
0c9821959f Revert "[cmake] Xcode 14 warns about -undefined dynamic_lookup; simply suppress:"
See https://github.com/root-project/root/issues/11937
for why `-flat_namespace` is bad.

This reverts commit a05d4beded1481a86a65e450826352eb528b03e7.
2023-01-19 12:59:06 +01:00
Axel Naumann
feb0db382e For MSVC weak symbols, re-use even small funcs:
Without, the JIT fails to compile roottest/root/aclic/misc/assertROOT7027.C
correctly.
2023-01-17 16:59:06 +01:00
Axel Naumann
8a87d1f8d6 JIT: find existing weak symbol without materializer:
m_JIT.getSymbolAddress() invokes the symbol materializers, which compile (which
is sort of okay) but also try autoloading (which totally is not okay).

Instead, implement a function to search existing JIT symbols.

This can be accelerated by looking up the whole set of symbols, instead of doing it
symbol by symbol. I leave that refactoring for later...
2023-01-17 16:59:06 +01:00
Axel Naumann
1b6158779e JIT: separate re-use of weak sym vars, funcs (NFCI). 2023-01-17 16:59:06 +01:00
Axel Naumann
2925ee3a32 JIT: only re-use *large* existing weak functions:
Small functions might get inlined, and hiding their definition prevents
the inliner from doing its job.
2023-01-17 16:59:06 +01:00
Axel Naumann
4b2e5f8e2c Reuse existing weak symbols, also from JIT:
With the upgrade to llvm-13, the JIT lost the ability to re-use existing weak
symbols that the JIT had already emitted, instead only looking at dlsym. This
causes a significant increase in JITted symbols, and thus a significant slow-down
of cling / its JIT.

This restores the old behavior, with an identical set of symbols that jet jitted.
2023-01-17 16:59:06 +01:00
Jonas Hahnfeld
51e15ea523 Prepare for monorepo layout 2023-01-16 14:59:08 +01:00
Axel Naumann
da247bd77a Re-enable CodeGen-OptLevel after llvm13 upgrade:
With the upgrade, BackendPasses was modifying a TargetMachine that was
not used by SimpleCompiler.

Change that by
- using a SimpleCompiler that uses IncrementalJIT::TM;
- moving the TM creation to IncrementalJIT, and giving access to it

This reduces the runtime of https://github.com/root-project/root/issues/11927
to
- before llvm upgrade: 2.69s
- llvm13, without this commit: ???
- llvm13, with this commit: 2.89s
i.e, a slow-down of 7% (that is likely caused by the different emission
mechanism of Orc-v2; to be confirmed...)
2022-12-21 17:14:02 +01:00
Vassil Vassilev
cefa80ef54 Rebase better to llvm13 to the FileEntryRef and FileEntry.
Likely fixes root-project/root#11933
2022-12-20 08:59:05 +01:00
Guilherme Amadio
b0940d1ba7 Re-enable support for profiling/debugging interpreted/JITted code
This feature, originally added in commit 22b1606f, was reverted to
make the LLVM upgrade to version 13 easier. This commit adds back
all functionality as it was just before the LLVM upgrade.
2022-12-15 10:29:03 +01:00
Jonas Hahnfeld
b9ec7687bf Create non-empty source file
LLVM currently has an issue that a completely empty source file is
stored as a nullptr, but DIFile::getSource() does not correctly deal
with this situation. A crash can be observed if just attempting to
launch root.exe with EXTRA_CLING_ARGS="-gdwarf-5 -gembed-source".

See https://reviews.llvm.org/D137152 and https://reviews.llvm.org/D138658
for discussions with upstream.
2022-12-13 09:59:05 +01:00
Jonas Hahnfeld
092c9c981f Increase initial offset into virtual file
Otherwise the PresumedLoc's suddely get valid once we avoid a
completely empty soure buffer in the next commit.
2022-12-13 09:59:05 +01:00
Bertrand Bellenot
9cfaafc10e Fix compilation with VS 2022 v17.4 (#11866)
* Fix compilation with VS 2022 v17.4

This fixes the issue #10875 _HAS_CONDITIONAL_EXPLICIT=0 won't work with VS 2022 17.4

* In fact with LLVM 13 this workaround is not needed anymore
2022-12-12 11:29:05 +01:00
Axel Naumann
7bcc42aa20 Make string_view module non-textual:
this causes issues with C++20 module composability and the need for textual is unclear.
2022-12-11 22:14:05 +01:00