[compiler-rt] [libunwind] [libunwind][cmake] Compile _Unwind* routines with -fexceptions (PR #121819)

2025-01-16 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `libunwind-sphinx-docs` 
running on `gribozavr3` while building `libunwind` at step 3 "Install pip 
dependencies".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/149/builds/34


Here is the relevant piece of the build log for the reference

```
Step 3 (Install pip dependencies) failure: 'pip install -r 
llvm/docs/requirements-hashed.txt' (failure)
Upon execvpe pip install -r llvm/docs/requirements-hashed.txt ['pip install -r 
llvm/docs/requirements-hashed.txt'] in environment id 140095679092208
:Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/process.py", line 
445, in _fork
environment)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/process.py", line 
523, in _execChild
os.execvpe(executable, args, environment)
  File "/usr/lib/python2.7/os.py", line 355, in execvpe
_execvpe(file, args, env)
  File "/usr/lib/python2.7/os.py", line 370, in _execvpe
func(file, *argrest)
OSError: [Errno 2] No such file or directory

```



https://github.com/llvm/llvm-project/pull/121819
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [libunwind] [libunwind][cmake] Compile _Unwind* routines with -fexceptions (PR #121819)

2025-01-16 Thread Paul Kirth via cfe-commits

https://github.com/ilovepi closed 
https://github.com/llvm/llvm-project/pull/121819
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [libunwind] [libunwind][cmake] Compile _Unwind* routines with -fexceptions (PR #121819)

2025-01-16 Thread Paul Kirth via cfe-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/121819

>From 9f952de3cb3e973f17121c057089a28bf4c6e5e0 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Mon, 6 Jan 2025 11:15:35 -0800
Subject: [PATCH 1/5] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 libunwind/src/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index e7ea57734cca97..72dd3f5bca9960 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -20,7 +20,7 @@ set(LIBUNWIND_C_SOURCES
 )
 set_source_files_properties(${LIBUNWIND_C_SOURCES}
 PROPERTIES
-  COMPILE_FLAGS "-std=c99")
+  COMPILE_FLAGS "-std=c99 -fexceptions")
 
 set(LIBUNWIND_ASM_SOURCES
 UnwindRegistersRestore.S

>From 71603241c3e377a5b74c308367f066f3f9e760ae Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Tue, 7 Jan 2025 14:59:24 -0800
Subject: [PATCH 2/5] Update commit message and add comment

Created using spr 1.3.6-beta.1
---
 libunwind/src/CMakeLists.txt | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 72dd3f5bca9960..602c99fe237b8e 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -20,6 +20,11 @@ set(LIBUNWIND_C_SOURCES
 )
 set_source_files_properties(${LIBUNWIND_C_SOURCES}
 PROPERTIES
+  # We need to set `-fexceptions` here so that key
+  # unwinding functions, like
+  # _UNWIND_RaiseExcpetion, are not marked as
+  # `nounwind`, which breaks LTO builds of
+  # libunwind.  See #56825 and #120657 for context.
   COMPILE_FLAGS "-std=c99 -fexceptions")
 
 set(LIBUNWIND_ASM_SOURCES

>From cc9ecaa7eb4025fb5718dcbc01133f4f53e0a251 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Fri, 10 Jan 2025 12:56:30 -0800
Subject: [PATCH 3/5] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1

[skip ci]
---
 .../lib/rtsan/tests/rtsan_test_functional.cpp   | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp 
b/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
index ef11b71f167e1b..40c4f3b129129d 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
@@ -145,13 +145,24 @@ TEST(TestRtsan, LaunchingAThreadDiesWhenRealtime) {
 
 namespace {
 void InvokeStdFunction(std::function &&function) { function(); }
+
+template 
+void HideMemoryFromCompiler(T* memory) {
+  // Pass the pointer to an empty assembly block as an input, and inform
+  // the compiler that memory is read to and possibly modified. This should not
+  // be architecture specific, since the asm block is empty.
+  __asm__ __volatile__("" ::"r"(memory) : "memory");
+}
 } // namespace
 
 TEST(TestRtsan, CopyingALambdaWithLargeCaptureDiesWhenRealtime) {
   std::array lots_of_data;
   auto LargeLambda = [lots_of_data]() mutable {
-// Stop everything getting optimised out
 lots_of_data[3] = 0.25f;
+// In LTO builds, this lambda can be optimized away, since the compiler can
+// see through the memory accesses after inlining across TUs. Ensure it can
+// no longer reason about the memory access, so that won't happen.
+HideMemoryFromCompiler(&lots_of_data[3]);
 EXPECT_EQ(16u, lots_of_data.size());
 EXPECT_EQ(0.25f, lots_of_data[3]);
   };

>From 0a419a5cbb4f2c811726a85f55a4beed00a3fa56 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Fri, 10 Jan 2025 13:04:15 -0800
Subject: [PATCH 4/5] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1

[skip ci]
---
 compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp 
b/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
index 40c4f3b129129d..e05d7ae78b5d99 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
@@ -146,8 +146,7 @@ TEST(TestRtsan, LaunchingAThreadDiesWhenRealtime) {
 namespace {
 void InvokeStdFunction(std::function &&function) { function(); }
 
-template 
-void Hid

[compiler-rt] [libunwind] [libunwind][cmake] Compile _Unwind* routines with -fexceptions (PR #121819)

2025-01-15 Thread Petr Hosek via cfe-commits


@@ -20,7 +20,12 @@ set(LIBUNWIND_C_SOURCES
 )
 set_source_files_properties(${LIBUNWIND_C_SOURCES}
 PROPERTIES
-  COMPILE_FLAGS "-std=c99")
+  # We need to set `-fexceptions` here so that key
+  # unwinding functions, like
+  # _UNWIND_RaiseExcpetion, are not marked as

petrhosek wrote:

```suggestion
  # _UNWIND_RaiseException, are not marked as
```

https://github.com/llvm/llvm-project/pull/121819
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [libunwind] [libunwind][cmake] Compile _Unwind* routines with -fexceptions (PR #121819)

2025-01-14 Thread Paul Kirth via cfe-commits

ilovepi wrote:

Hmm, the failing bot seems to be some kind of configuration error on the bot 
(or issue w/ the docker daemon?) 
https://github.com/llvm/llvm-project/actions/runs/12775719644/job/35614829092

https://github.com/llvm/llvm-project/pull/121819
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [libunwind] [libunwind][cmake] Compile _Unwind* routines with -fexceptions (PR #121819)

2025-01-14 Thread Paul Kirth via cfe-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/121819

>From 9f952de3cb3e973f17121c057089a28bf4c6e5e0 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Mon, 6 Jan 2025 11:15:35 -0800
Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 libunwind/src/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index e7ea57734cca97..72dd3f5bca9960 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -20,7 +20,7 @@ set(LIBUNWIND_C_SOURCES
 )
 set_source_files_properties(${LIBUNWIND_C_SOURCES}
 PROPERTIES
-  COMPILE_FLAGS "-std=c99")
+  COMPILE_FLAGS "-std=c99 -fexceptions")
 
 set(LIBUNWIND_ASM_SOURCES
 UnwindRegistersRestore.S

>From 71603241c3e377a5b74c308367f066f3f9e760ae Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Tue, 7 Jan 2025 14:59:24 -0800
Subject: [PATCH 2/4] Update commit message and add comment

Created using spr 1.3.6-beta.1
---
 libunwind/src/CMakeLists.txt | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 72dd3f5bca9960..602c99fe237b8e 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -20,6 +20,11 @@ set(LIBUNWIND_C_SOURCES
 )
 set_source_files_properties(${LIBUNWIND_C_SOURCES}
 PROPERTIES
+  # We need to set `-fexceptions` here so that key
+  # unwinding functions, like
+  # _UNWIND_RaiseExcpetion, are not marked as
+  # `nounwind`, which breaks LTO builds of
+  # libunwind.  See #56825 and #120657 for context.
   COMPILE_FLAGS "-std=c99 -fexceptions")
 
 set(LIBUNWIND_ASM_SOURCES

>From cc9ecaa7eb4025fb5718dcbc01133f4f53e0a251 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Fri, 10 Jan 2025 12:56:30 -0800
Subject: [PATCH 3/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1

[skip ci]
---
 .../lib/rtsan/tests/rtsan_test_functional.cpp   | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp 
b/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
index ef11b71f167e1b..40c4f3b129129d 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
@@ -145,13 +145,24 @@ TEST(TestRtsan, LaunchingAThreadDiesWhenRealtime) {
 
 namespace {
 void InvokeStdFunction(std::function &&function) { function(); }
+
+template 
+void HideMemoryFromCompiler(T* memory) {
+  // Pass the pointer to an empty assembly block as an input, and inform
+  // the compiler that memory is read to and possibly modified. This should not
+  // be architecture specific, since the asm block is empty.
+  __asm__ __volatile__("" ::"r"(memory) : "memory");
+}
 } // namespace
 
 TEST(TestRtsan, CopyingALambdaWithLargeCaptureDiesWhenRealtime) {
   std::array lots_of_data;
   auto LargeLambda = [lots_of_data]() mutable {
-// Stop everything getting optimised out
 lots_of_data[3] = 0.25f;
+// In LTO builds, this lambda can be optimized away, since the compiler can
+// see through the memory accesses after inlining across TUs. Ensure it can
+// no longer reason about the memory access, so that won't happen.
+HideMemoryFromCompiler(&lots_of_data[3]);
 EXPECT_EQ(16u, lots_of_data.size());
 EXPECT_EQ(0.25f, lots_of_data[3]);
   };

>From 0a419a5cbb4f2c811726a85f55a4beed00a3fa56 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Fri, 10 Jan 2025 13:04:15 -0800
Subject: [PATCH 4/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1

[skip ci]
---
 compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp 
b/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
index 40c4f3b129129d..e05d7ae78b5d99 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
@@ -146,8 +146,7 @@ TEST(TestRtsan, LaunchingAThreadDiesWhenRealtime) {
 namespace {
 void InvokeStdFunction(std::function &&function) { function(); }
 
-template 
-void Hid

[compiler-rt] [libunwind] [libunwind][cmake] Compile _Unwind* routines with -fexceptions (PR #121819)

2025-01-14 Thread Paul Kirth via cfe-commits

https://github.com/ilovepi edited 
https://github.com/llvm/llvm-project/pull/121819
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [libunwind] [libunwind][cmake] Compile _Unwind* routines with -fexceptions (PR #121819)

2025-01-14 Thread Paul Kirth via cfe-commits

ilovepi wrote:

Are there lingering concerns here or are we OK landing this?

https://github.com/llvm/llvm-project/pull/121819
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits