-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8365231: Don't build gtest with /EHsc #26721
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back ihse! A progress list of the required criteria for merging this PR into |
@magicus This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 66 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
@kimbarrett Any opinions? |
@@ -110,7 +109,7 @@ $(eval $(call SetupJdkLibrary, BUILD_GTEST_LIBJVM, \ | |||
self-assign-overloaded, \ | |||
DISABLED_WARNINGS_clang_test_g1ServiceThread.cpp := delete-abstract-non-virtual-dtor, \ | |||
DISABLED_WARNINGS_clang_test_logDecorations.cpp := missing-field-initializers, \ | |||
DISABLED_WARNINGS_microsoft := $(DISABLED_WARNINGS_microsoft), \ | |||
DISABLED_WARNINGS_microsoft := $(DISABLED_WARNINGS_microsoft) 4530, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How widespread are these warnings? I expect such a warning from jfr/test_networkUtilization.cpp,
but not anywhere else. Could the disable of this warning be narrowed accordingly?
googletest uses C++ exceptions:
And for C++ exception support we need
So I don't think we should remove this compiler option. |
I did take a brief look at the other Pull Request, but I still don't really understand this fully. Doesn't the gtest framework itself use C++ exceptions (As Thomas mentioned)? After all, this is likely why -fno-exceptions is not used with gcc and clang when compiling gtest. It would be a bit odd if exceptions were disabled for only Windows (More accurately VC) and not any other platform. |
@@ -62,13 +62,13 @@ $(eval $(call SetupJdkLibrary, BUILD_GTEST_LIBGTEST, \ | |||
DISABLED_WARNINGS_gcc := format-nonliteral maybe-uninitialized undef \ | |||
unused-result zero-as-null-pointer-constant, \ | |||
DISABLED_WARNINGS_clang := format-nonliteral undef unused-result, \ | |||
DISABLED_WARNINGS_microsoft := 4530, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a good idea. This doesn't fully force disable exceptions like -fno-exceptions does with gcc and clang, it can result in unexpected behaviour that causes hard to track bugs that will be difficult to solve if someone who isn't familiar with HotSpot rules introduces exceptions in gtest code (And perhaps in other cases even when exceptions aren't used too).
So we should not remove exceptions for libgtest. But for the special version of libjvm it still seem to make sense, right? Even if gtest uses exceptions internally in the framework, we should not compile our code differently. Or am I missing something? |
That just says there is source code that could potentially use exceptions, depending on configuration. So as long as the macro is set properly... If not explicitly set, it gets auto-set to 1 for |
But |
Oh, and once again, thank you thank you thank you for the ".o.cmdline" files! |
My guess is that MSVC C4530 needs to be disabled when building libgtest even That jfr test includes googletest also includes |
Not So assuming it passes testing, this change seems fine to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming no testing issues are encountered, this looks good to me.
I feel uncomfortable about switching off this warning. I agree with @TheShermanTanker there. Seems to me that if the compiler warns me that I should enable exceptions, I should do that instead of disabling the warning? What is the motivation for this change? What do we gain by switching the feature off? This switch only applies to the gtest compilation units, right, not to the libjvm? Don't we link googletest and libjvm statically? Are exceptions thrown from header files that are compiled as part of the gtest libjvm? |
-fno-exceptions to my knowledge is only set in TOOLCHAIN_CFLAGS_JVM and for adlc compiled for Linux. That must mean gtest uses the same flags that the regular JVM does. I was not aware of that, so that would make my previous statement incorrect. |
As Kim wrote, this seems to be about a bug in the compiler. If you include certain standard headers ( Our normal libjvm is compiled with exceptions disabled. It makes sense to run tests on a build that is as close as possible to the real thing, so we should compile libjvm for gtest with exceptions disabled, too. |
Okay, so we switch the risk of mismatched tests (since we are compiled with a different setting than the production JVM) with the risk of strange errors should we accidentally trigger C++ exceptions in the googletest framework or in system libraries used by it. I guess I can see the logic. Okay. |
According to #26661 (comment), 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.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26721/head:pull/26721
$ git checkout pull/26721
Update a local copy of the PR:
$ git checkout pull/26721
$ git pull https://git.openjdk.org/jdk.git pull/26721/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26721
View PR using the GUI difftool:
$ git pr show -t 26721
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26721.diff
Using Webrev
Link to Webrev Comment