[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-18 Thread via cfe-commits

SahilPatidar wrote:

Sorry for the delay. We'll come up with a solution, or perhaps we can use a 
direct binary as suggested by @vgvassilev, since we want to avoid invoking the 
system linker.

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-14 Thread Davide Italiano via cfe-commits

dcci wrote:

Given the fix forward didn't work, I reverted this to unblock

```
commit 61ab36a3e226df32855286dd31a2c3859800475d (HEAD -> main, upstream/main)
Author: Davide Italiano 
Date:   Sat Dec 14 18:25:50 2024 +

Revert "[Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic 
libraries. (#117475)"

This reverts commit 30ad53b92cec0cff9679d559edcc5b933312ba0c as it breaks
systems that don't have a systemwide libc++ or libstdc++ installed. It 
should
be rewritten to not invoke the system linker. In the meanwhile, reverting
to unblock the bots.

commit 9ddcaed3a64c2a187a0cfff4ba8f989c665ae1e5
Author: Davide Italiano 
Date:   Sat Dec 14 18:25:02 2024 +

Revert "[Clang] Interpreter test should not depend on system header 
(#119903)"

This reverts commit 8ab6912831277d87838518c5f775f79d14616860.
```

as it seems to need some amount of work. Feel free to ping us so we can try 
this patch once you have something ready to confirm it fixes the build.

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-14 Thread Yuxuan Chen via cfe-commits

yuxuanchen1997 wrote:

> @SahilPatidar, could you help us with this?

Can we temporarily disable this test when @SahilPatidar is looking for a 
solution?

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-13 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

@SahilPatidar, could you help us with this?

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-13 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev edited 
https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-13 Thread Vassil Vassilev via cfe-commits


@@ -0,0 +1,20 @@
+// REQUIRES: host-supports-jit, x86_64-linux
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+//
+// RUN: split-file %s %t
+//
+// RUN: %clang++ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o
+// RUN: %clang++ -shared %t/vec.o -o %t/vec.so

vgvassilev wrote:

The tools is called `yaml2obj`.

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-13 Thread Yuxuan Chen via cfe-commits


@@ -0,0 +1,20 @@
+// REQUIRES: host-supports-jit, x86_64-linux
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+//
+// RUN: split-file %s %t
+//
+// RUN: %clang++ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o
+// RUN: %clang++ -shared %t/vec.o -o %t/vec.so

yuxuanchen1997 wrote:

If there's no quick solution, I would propose to revert the testing portion of 
this patch. This has been blocking CI on our end for a couple of days. No other 
tests in llvm repo invokes system linker like this one. 

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-13 Thread Yuxuan Chen via cfe-commits


@@ -0,0 +1,20 @@
+// REQUIRES: host-supports-jit, x86_64-linux
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+//
+// RUN: split-file %s %t
+//
+// RUN: %clang++ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o
+// RUN: %clang++ -shared %t/vec.o -o %t/vec.so

yuxuanchen1997 wrote:

> Perhaps we should use this yaml-to-so tool to build the library.

Can you point me to the tool? A naive search returned nothing. 

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-13 Thread Vassil Vassilev via cfe-commits


@@ -0,0 +1,20 @@
+// REQUIRES: host-supports-jit, x86_64-linux
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+//
+// RUN: split-file %s %t
+//
+// RUN: %clang++ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o
+// RUN: %clang++ -shared %t/vec.o -o %t/vec.so

vgvassilev wrote:

Perhaps we should use this yaml-to-so tool to build the library. 

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-13 Thread Yuxuan Chen via cfe-commits


@@ -0,0 +1,20 @@
+// REQUIRES: host-supports-jit, x86_64-linux
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+//
+// RUN: split-file %s %t
+//
+// RUN: %clang++ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o
+// RUN: %clang++ -shared %t/vec.o -o %t/vec.so

yuxuanchen1997 wrote:

This invokes the system linker. From the build system's point of view, it's 
almost never correct to invoke the system linker without the environment 
variables `$LDFLAGS` and `$LIBS`. In this case, you expect to make the shared 
library to link against the default libs. 

I am thinking of changing this line to read 
```
// RUN: %clang++ -shared %t/vec.o -o %t/vec.so $LDFLAGS $LIBS
```
Not particularly satisfied with this approach though.

I also think that your `vec.o` and `vec.so` are both empty after my previous 
fix. This suggests that the two steps here may not even be needed at all for 
the sake of testing this fix. 

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-13 Thread Yuxuan Chen via cfe-commits


@@ -0,0 +1,20 @@
+// REQUIRES: host-supports-jit, x86_64-linux
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+//
+// RUN: split-file %s %t
+//
+// RUN: %clang++ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o
+// RUN: %clang++ -shared %t/vec.o -o %t/vec.so
+//
+// RUN: cat %t/Test.cpp | LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH clang-repl

yuxuanchen1997 wrote:

How does `clang-repl` respond to `#include ` if the path to the library 
is not provided on the command line? IIUC, this will continue to search for a 
systemwide installation of the C++ standard library. If that's the case, this 
continues to be wrong. 

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-13 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 edited 
https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-13 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 commented:

I landed my previous fix but I found that this test to be more problematic than 
I originally anticipated. I left some comments. I may send more patches to fix 
it until I am satisfied. 

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-12-09 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev closed 
https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-27 Thread via cfe-commits

https://github.com/SahilPatidar updated 
https://github.com/llvm/llvm-project/pull/117475

>From 559a2d05e0a3518cf59cd828bcf41a6de10a4e76 Mon Sep 17 00:00:00 2001
From: SahilPatidar 
Date: Sun, 24 Nov 2024 15:19:50 +0530
Subject: [PATCH 1/3] [Clang-REPL] Fix crash during `__run_exit_handlers` with
 dynamic libraries

---
 clang/lib/Interpreter/Interpreter.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 5dc67f6375098f..71299f7176e2fe 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -719,7 +719,9 @@ llvm::Error Interpreter::LoadDynamicLibrary(const char 
*name) {
 
   if (auto DLSG = llvm::orc::DynamicLibrarySearchGenerator::Load(
   name, DL.getGlobalPrefix()))
-EE->getMainJITDylib().addGenerator(std::move(*DLSG));
+// FIXME: Eventually we should put each library in its own JITDylib and
+//turn off process symbols by default.
+EE->getProcessSymbolsJITDylib()->addGenerator(std::move(*DLSG));
   else
 return DLSG.takeError();
 

>From 86210eda27a32e7910780f954171e2c9186d48ac Mon Sep 17 00:00:00 2001
From: SahilPatidar 
Date: Wed, 27 Nov 2024 14:08:33 +0530
Subject: [PATCH 2/3] Add test to verify fix for crash

---
 clang/test/Interpreter/crash.cpp | 20 
 1 file changed, 20 insertions(+)
 create mode 100644 clang/test/Interpreter/crash.cpp

diff --git a/clang/test/Interpreter/crash.cpp b/clang/test/Interpreter/crash.cpp
new file mode 100644
index 00..1dda3e65f54582
--- /dev/null
+++ b/clang/test/Interpreter/crash.cpp
@@ -0,0 +1,20 @@
+// REQUIRES: host-supports-jit, x86_64-linux
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+//
+// RUN: split-file %s %t
+//
+// RUN: %clang++ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o
+// RUN: %clang++ -shared %t/vec.o -o %t/vec.so
+//
+// RUN: cat %t/Test.cpp | LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH clang-repl
+
+//--- vec.cpp
+#include 
+
+//--- Test.cpp
+%lib vec.dylib
+#include 
+std::vector v;
+%quit

>From 89015b34f27cdb7fd9241f26d0c73afd8e32d789 Mon Sep 17 00:00:00 2001
From: SahilPatidar 
Date: Wed, 27 Nov 2024 14:40:54 +0530
Subject: [PATCH 3/3] Fix minor typo

---
 clang/test/Interpreter/crash.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Interpreter/crash.cpp b/clang/test/Interpreter/crash.cpp
index 1dda3e65f54582..1ab24b0febfa15 100644
--- a/clang/test/Interpreter/crash.cpp
+++ b/clang/test/Interpreter/crash.cpp
@@ -14,7 +14,7 @@
 #include 
 
 //--- Test.cpp
-%lib vec.dylib
+%lib vec.so
 #include 
 std::vector v;
 %quit

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-27 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-27 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev edited 
https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-27 Thread Vassil Vassilev via cfe-commits


@@ -0,0 +1,20 @@
+// REQUIRES: host-supports-jit, x86_64-linux
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+//
+// RUN: split-file %s %t
+//
+// RUN: %clang++ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o
+// RUN: %clang++ -shared %t/vec.o -o %t/vec.so
+//
+// RUN: cat %t/Test.cpp | LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH clang-repl
+
+//--- vec.cpp
+#include 
+
+//--- Test.cpp
+%lib vec.dylib

vgvassilev wrote:

```suggestion
%lib vec.so
```

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-27 Thread via cfe-commits

https://github.com/SahilPatidar updated 
https://github.com/llvm/llvm-project/pull/117475

>From 559a2d05e0a3518cf59cd828bcf41a6de10a4e76 Mon Sep 17 00:00:00 2001
From: SahilPatidar 
Date: Sun, 24 Nov 2024 15:19:50 +0530
Subject: [PATCH 1/2] [Clang-REPL] Fix crash during `__run_exit_handlers` with
 dynamic libraries

---
 clang/lib/Interpreter/Interpreter.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 5dc67f6375098f..71299f7176e2fe 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -719,7 +719,9 @@ llvm::Error Interpreter::LoadDynamicLibrary(const char 
*name) {
 
   if (auto DLSG = llvm::orc::DynamicLibrarySearchGenerator::Load(
   name, DL.getGlobalPrefix()))
-EE->getMainJITDylib().addGenerator(std::move(*DLSG));
+// FIXME: Eventually we should put each library in its own JITDylib and
+//turn off process symbols by default.
+EE->getProcessSymbolsJITDylib()->addGenerator(std::move(*DLSG));
   else
 return DLSG.takeError();
 

>From 86210eda27a32e7910780f954171e2c9186d48ac Mon Sep 17 00:00:00 2001
From: SahilPatidar 
Date: Wed, 27 Nov 2024 14:08:33 +0530
Subject: [PATCH 2/2] Add test to verify fix for crash

---
 clang/test/Interpreter/crash.cpp | 20 
 1 file changed, 20 insertions(+)
 create mode 100644 clang/test/Interpreter/crash.cpp

diff --git a/clang/test/Interpreter/crash.cpp b/clang/test/Interpreter/crash.cpp
new file mode 100644
index 00..1dda3e65f54582
--- /dev/null
+++ b/clang/test/Interpreter/crash.cpp
@@ -0,0 +1,20 @@
+// REQUIRES: host-supports-jit, x86_64-linux
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+//
+// RUN: split-file %s %t
+//
+// RUN: %clang++ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o
+// RUN: %clang++ -shared %t/vec.o -o %t/vec.so
+//
+// RUN: cat %t/Test.cpp | LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH clang-repl
+
+//--- vec.cpp
+#include 
+
+//--- Test.cpp
+%lib vec.dylib
+#include 
+std::vector v;
+%quit

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-26 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

> Would it be okay if I push the test for the Linux modification and check the 
> results here? I don’t have access to a Linux x86 setup for testing.

Yes, that's what the pre-merge checks are for ;)

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-26 Thread via cfe-commits

SahilPatidar wrote:

Would it be okay if I push the test for the Linux modification and check the 
results here? I don’t have access to a Linux x86 setup for testing.

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-25 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

> I came across the following setup:
> 
> ```c++
> // REQUIRES: host-supports-jit
> 
> // RUN: rm -rf %t
> // RUN: mkdir -p %t
> //
> // RUN: split-file %s %t
> //
> // RUN: %clang++ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o
> // RUN: %clang++ -shared %t/vec.o -o %t/vec.dylib
> //
> // RUN: cat %t/Test.cpp | DYLD_LIBRARY_PATH=%t:$DYLD_LIBRARY_PATH clang-repl
> 
> //--- vec.cpp
> #include 
> 
> //--- Test.cpp
> %lib vec.dylib
> #include 
> std::vector v;
> %quit
> ```

Hm, okay, would that work on linux? If so, then I guess we can follow that 
pattern.

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-25 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

> I have added a test, but it should only run on Darwin (macOS) platforms.
> 
> ```c++
> // REQUIRES: host-supports-jit
> 
> // RUN: cat %s | env SDKROOT=$(xcrun --show-sdk-path) 
> DYLD_LIBRARY_PATH=%S/Inputs:$DYLD_LIBRARY_PATH clang-repl
> 
> %lib vec.dylib
> #include 
> std::vector v;
> %quit
> ```

In this case we will need an extra requires clause. Also I do not think we need 
the xcrun. There was some way to make a library out of yaml, you can look in 
the list of tests what it was. Maybe that’s useful. 

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-25 Thread via cfe-commits

SahilPatidar wrote:

I have added a test, but it should only run on Darwin (macOS) platforms.
```cpp
// REQUIRES: host-supports-jit

// RUN: cat %s | env SDKROOT=$(xcrun --show-sdk-path) 
DYLD_LIBRARY_PATH=%S/Inputs:$DYLD_LIBRARY_PATH clang-repl

%lib vec.dylib
#include 
std::vector v;
%quit

```

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-24 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

It is worth adding a test here. 

https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (SahilPatidar)


Changes

Apply the fix suggested by Lang Hames to address a crash in Clang-REPL that 
occurs during the execution of `__run_exit_handlers` when using dynamic 
libraries.

---
Full diff: https://github.com/llvm/llvm-project/pull/117475.diff


1 Files Affected:

- (modified) clang/lib/Interpreter/Interpreter.cpp (+3-1) 


``diff
diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 5dc67f6375098f..71299f7176e2fe 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -719,7 +719,9 @@ llvm::Error Interpreter::LoadDynamicLibrary(const char 
*name) {
 
   if (auto DLSG = llvm::orc::DynamicLibrarySearchGenerator::Load(
   name, DL.getGlobalPrefix()))
-EE->getMainJITDylib().addGenerator(std::move(*DLSG));
+// FIXME: Eventually we should put each library in its own JITDylib and
+//turn off process symbols by default.
+EE->getProcessSymbolsJITDylib()->addGenerator(std::move(*DLSG));
   else
 return DLSG.takeError();
 

``




https://github.com/llvm/llvm-project/pull/117475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang-REPL] Fix crash during `__run_exit_handlers` with dynamic libraries. (PR #117475)

2024-11-24 Thread via cfe-commits

https://github.com/SahilPatidar created 
https://github.com/llvm/llvm-project/pull/117475

Apply the fix suggested by Lang Hames to address a crash in Clang-REPL that 
occurs during the execution of `__run_exit_handlers` when using dynamic 
libraries.

>From 559a2d05e0a3518cf59cd828bcf41a6de10a4e76 Mon Sep 17 00:00:00 2001
From: SahilPatidar 
Date: Sun, 24 Nov 2024 15:19:50 +0530
Subject: [PATCH] [Clang-REPL] Fix crash during `__run_exit_handlers` with
 dynamic libraries

---
 clang/lib/Interpreter/Interpreter.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 5dc67f6375098f..71299f7176e2fe 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -719,7 +719,9 @@ llvm::Error Interpreter::LoadDynamicLibrary(const char 
*name) {
 
   if (auto DLSG = llvm::orc::DynamicLibrarySearchGenerator::Load(
   name, DL.getGlobalPrefix()))
-EE->getMainJITDylib().addGenerator(std::move(*DLSG));
+// FIXME: Eventually we should put each library in its own JITDylib and
+//turn off process symbols by default.
+EE->getProcessSymbolsJITDylib()->addGenerator(std::move(*DLSG));
   else
 return DLSG.takeError();
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits