Skip to content

[LLDB] Compile API tests with exceptions enabled on Windows #148691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2025

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Jul 14, 2025

From #148554 - compile tests with exceptions on Windows (-fno-exceptions was added 11 years ago in c782652). The variant test uses try {} catch {} to create variants that are valueless by exception. On other platforms, exceptions are enabled as well.

I have no clue why compiling with exceptions will optimize out a_long_guy in the changed test (even with -O0). Taking the address of that value will ensure it's kept.

@Nerixyz Nerixyz requested a review from JDevlieghere as a code owner July 14, 2025 18:05
@llvmbot llvmbot added the lldb label Jul 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 14, 2025

@llvm/pr-subscribers-lldb

Author: nerix (Nerixyz)

Changes

From #148554 - compile tests with exceptions on Windows (-fno-exceptions was added 11 years ago in c782652). The variant test uses try {} catch {} to create variants that are valueless by exception. On other platforms, exceptions are enabled as well.

I have no clue why compiling with exceptions will optimize out a_long_guy in the changed test (even with -O0). Taking the address of that value will ensure it's kept.


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

2 Files Affected:

  • (modified) lldb/packages/Python/lldbsuite/test/make/Makefile.rules (-4)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp (+1)
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 58833e1b0cc78..8521ca508a479 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -344,10 +344,6 @@ endif
 #----------------------------------------------------------------------
 ifeq "$(OS)" "Windows_NT"
 	ifeq ($(CC_TYPE), clang)
-		# Clang for Windows doesn't support C++ Exceptions
-		CXXFLAGS += -fno-exceptions
-		CXXFLAGS += -D_HAS_EXCEPTIONS=0
-
 		# MSVC 2015 or higher is required, which depends on c++14, so
 		# append these values unconditionally.
 		CXXFLAGS += -fms-compatibility-version=19.0
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
index 9d12ca30f984c..32f5f2ce436fe 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
@@ -165,6 +165,7 @@ int main (int argc, const char * argv[])
     Simple a_simple_object(3,0.14,'E');
     
     VeryLong a_long_guy;
+    auto *unused = &a_long_guy; // ensure a_long_guy isn't optimized out
 
     std::string some_string = "012345678901234567890123456789"
                               "012345678901234567890123456789"

@JDevlieghere
Copy link
Member

JDevlieghere commented Jul 14, 2025

Ignore my previous comment, I read "unit tests" and replied before looking at the change.

@Nerixyz
Copy link
Contributor Author

Nerixyz commented Jul 15, 2025

I can't merge this on my own, could you merge this for me please? @JDevlieghere

@JDevlieghere JDevlieghere merged commit 95fa676 into llvm:main Jul 15, 2025
11 checks passed
@Nerixyz Nerixyz deleted the chore/lldb-enable-exceptions branch July 15, 2025 18:48
DavidSpickett added a commit that referenced this pull request Jul 17, 2025
Since #148691 enabled
exceptions when compiling the tests, this test has been failing.

Much like was noted there, one of the variables disappeared
from the debug info. Giving it a non-zero size and initialising
it fixed that.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jul 17, 2025
…ions

Since llvm/llvm-project#148691 enabled
exceptions when compiling the tests, this test has been failing.

Much like was noted there, one of the variables disappeared
from the debug info. Giving it a non-zero size and initialising
it fixed that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants