Skip to content

Conversation

@arsenm
Copy link
Contributor

@arsenm arsenm commented Jul 2, 2025

Fixes regression reported #146342 (comment)

The test could probably be better. I'm not sure what special is happening with the module
compile, but I can't seem to reproduce this with just a plain -cc1 run.

Fixes regression reported #146342 (comment)

The test could probably be better. I'm not sure what special is happening with the module
compile, but I can't seem to reproduce this with just a plain -cc1 run.
Copy link
Contributor Author

arsenm commented Jul 2, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm added clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category labels Jul 2, 2025 — with Graphite App
@arsenm arsenm marked this pull request as ready for review July 2, 2025 07:34
@llvmbot llvmbot added the clang:modules C++20 modules and Clang Header Modules label Jul 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 2, 2025

@llvm/pr-subscribers-clang-modules
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Matt Arsenault (arsenm)

Changes

Fixes regression reported #146342 (comment)

The test could probably be better. I'm not sure what special is happening with the module
compile, but I can't seem to reproduce this with just a plain -cc1 run.


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

2 Files Affected:

  • (modified) clang/lib/Frontend/CompilerInvocation.cpp (+5-4)
  • (added) clang/test/Modules/mingw-exceptions.cppm (+4)
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index d8916a6b15f58..0a9e3649b386b 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3682,12 +3682,13 @@ static StringRef GetInputKindName(InputKind IK) {
 static StringRef getExceptionHandlingName(unsigned EHK) {
   switch (static_cast<LangOptions::ExceptionHandlingKind>(EHK)) {
   case LangOptions::ExceptionHandlingKind::None:
-  default:
     return "none";
-  case LangOptions::ExceptionHandlingKind::SjLj:
-    return "sjlj";
   case LangOptions::ExceptionHandlingKind::DwarfCFI:
     return "dwarf";
+  case LangOptions::ExceptionHandlingKind::SjLj:
+    return "sjlj";
+  case LangOptions::ExceptionHandlingKind::WinEH:
+    return "seh";
   case LangOptions::ExceptionHandlingKind::Wasm:
     return "wasm";
   }
@@ -4028,7 +4029,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
               A->getValue())
               .Case("dwarf", LangOptions::ExceptionHandlingKind::DwarfCFI)
               .Case("sjlj", LangOptions::ExceptionHandlingKind::SjLj)
-              .Case("wineh", LangOptions::ExceptionHandlingKind::WinEH)
+              .Case("seh", LangOptions::ExceptionHandlingKind::WinEH)
               .Case("wasm", LangOptions::ExceptionHandlingKind::Wasm)
               .Case("none", LangOptions::ExceptionHandlingKind::None)
               .Default(std::nullopt);
diff --git a/clang/test/Modules/mingw-exceptions.cppm b/clang/test/Modules/mingw-exceptions.cppm
new file mode 100644
index 0000000000000..e6f383f07200f
--- /dev/null
+++ b/clang/test/Modules/mingw-exceptions.cppm
@@ -0,0 +1,4 @@
+// RUN: %clang -target x86_64-windows-gnu -x c++-module -std=gnu++23 -c -o /dev/null -Xclang -disable-llvm-passes %s
+
+// Make sure the command succeeds and doesn't break on the -exception-model flag in cc1.
+export module empty;

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good to me! I'd still wait a little bit in case a Clang maintainer has an opinion on it, but it seems to fix the issue for me.

@mstorsjo
Copy link
Member

mstorsjo commented Jul 2, 2025

I'll go ahead and land this now to unbreak my builds.

@mstorsjo mstorsjo merged commit 7fc50e9 into main Jul 2, 2025
13 checks passed
@mstorsjo mstorsjo deleted the users/arsenm/clang/fix-parsing-exception-model-seh branch July 2, 2025 20:21
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 2, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-quick running on linaro-clang-aarch64-quick while building clang at step 5 "ninja check 1".

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

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'Clang :: Modules/mingw-exceptions.cppm' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/clang -target x86_64-windows-gnu -x c++-module -std=gnu++23 -c -o /dev/null -Xclang -disable-llvm-passes /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/Modules/mingw-exceptions.cppm # RUN: at line 1
+ /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/clang -target x86_64-windows-gnu -x c++-module -std=gnu++23 -c -o /dev/null -Xclang -disable-llvm-passes /home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/Modules/mingw-exceptions.cppm
error: unable to create target: 'No available targets are compatible with triple "x86_64-unknown-windows-gnu"'
1 error generated.

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 2, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-4 while building clang at step 6 "test-build-unified-tree-check-all".

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

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'Clang :: Modules/mingw-exceptions.cppm' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -target x86_64-windows-gnu -x c++-module -std=gnu++23 -c -o /dev/null -Xclang -disable-llvm-passes /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Modules/mingw-exceptions.cppm # RUN: at line 1
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -target x86_64-windows-gnu -x c++-module -std=gnu++23 -c -o /dev/null -Xclang -disable-llvm-passes /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Modules/mingw-exceptions.cppm
error: unable to create target: 'No available targets are compatible with triple "x86_64-unknown-windows-gnu"'
1 error generated.

--

********************


@mstorsjo
Copy link
Member

mstorsjo commented Jul 2, 2025

I pushed a fix to add REQUIRES: x86-registered-target in 551d6dd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:modules C++20 modules and Clang Header Modules clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants