RFR: 8365231: Don't build gtest with /EHsc

Thomas Stuefe stuefe at openjdk.org
Thu Aug 14 14:09:15 UTC 2025


On Mon, 11 Aug 2025 09:55:20 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

> According to https://github.com/openjdk/jdk/pull/26661#issuecomment-3162014034, we should not build gtest with `/EHsc`. 
> 
> I can honestly say I don't fully understand the consequences of this change, but at least it passes building and testing on Oracle CI. And it does seem to make sense that we build the gtest version of libjvm as close as possible to the real version. For libgtest I just thought it was prudent to keep the flags in sync with how we build libjvm. This might not be the correct decision.
> 
> I have not tested how or if this affects the ability for gtest to handle bugs or crashes in the JVM, nor do I really have any idea about any such consequences. This PR is opened more to start a discussion than with the intention of just integrating this.

googletest uses C++ exceptions:


thomas at starfish:/shared/projects/openjdk/gtest/googletest-1.14.0$ ack 'throw [a-zA-Z]' | wc -l
68


And for C++ exception support we need `/EHsc`, `/EHs` or `/EHa`:
https://learn.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=msvc-170


Standard C++ exception handling

Full compiler support for the Standard C++ exception handling model that safely unwinds stack objects requires /EHsc (recommended), /EHs, or /EHa.


So I don't think we should remove this compiler option.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/26721#issuecomment-3188586481


More information about the build-dev mailing list