-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
[3.x] SCons: Disable C++ exception handling #80622
[3.x] SCons: Disable C++ exception handling #80622
Conversation
ccc30da
to
2eceb23
Compare
@@ -328,65 +328,58 @@ Video::Video(uint64_t id, const ElementPtr element, const Document &doc, const s | |||
} | |||
|
|||
if (Content && !Content->Tokens().empty()) { | |||
//this field is omitted when the embedded texture is already loaded, let's ignore if it's not found |
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.
@RevoluPowered We shouldn't use exceptions in Godot code, how can I rewrite this to handle the failure case gracefully? (Current diff just removes try {
and } catch(...) { ... }
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.
This seems to be straight from Assimp where it's still using this hack:
https://github.com/assimp/assimp/blob/556c89b5f143738720e17572faa8e272d4eec380/code/AssetLib/FBX/FBXMaterial.cpp#L304-L364
I don't see it intentionally throwing and catching exceptions, so I guess this code will just crash and instead of adding proper failure handling they just wrapped it in exceptions... sigh
So what can crash here? token == nullptr
at least I suppose.
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 just changed it to replace the try { } catch (...) { }
by if (token)
, assuming that if it's failing it may return a nullptr. Add added another ERR_FAIL_COND
, there was already one, it probably leaves things in a broken state if the condition is met but I'm not sure we even use the FBX Video
class at all, so I don't want to do a deep dive.
2eceb23
to
032b76e
Compare
032b76e
to
9344a36
Compare
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.
Looks fine barring the query about the FBXMaterial
.
9344a36
to
9dac444
Compare
LinuxOS: Fedora 38 Build optionsEditor build options: Release export template build options: I ran each build twice with Editor# Before
vstask "Build (editor)" 524.04s user 47.64s system 1287% cpu 44.397 total
Stripped binary size: 98,324,736 bytes
# After
vstask "Build (editor)" 504.25s user 47.62s system 1374% cpu 40.163 total
Stripped binary size: 89,852,160 bytes Release export template# Before
vstask "Build (release export template)" 1240.66s user 66.26s system 2042% cpu 1:03.98 total
Stripped binary size: 40,015,136 bytes
# After
[Time elapsed: 00:00:57.894]
vstask "Build (release export template)" 1085.06s user 62.20s system 1976% cpu 58.045 total
Stripped binary size: 33,625,376 bytes WindowsOS: Windows 11 22H2 Build optionsEditor build options: Release export template build options: # Before
[Time elapsed: 00:00:52.174]
Binary size: 153,532,416 bytes
# After
[Time elapsed: 00:00:52.128]
Binary size: 153,521,152 bytes Release export template
|
I'm surprised that you're seeing virtually no difference on Windows, I'll have to test. |
Upon investigating the extremely slow MSVC build times in godotengine#80513, I noticed that while Godot policy is to never use exceptions, we weren't enforcing it with compiler flags, and thus still included exception handling code and stack unwinding. This is wasteful on multiple aspects: - Binary size: Around 20% binary size reduction with exceptions disabled for both MSVC and GCC binaries. - Compile time: * More than 50% build time reduction with MSVC. * 10% to 25% build time reduction with GCC + LTO. - Performance: Possibly, needs to be benchmarked. Since users may want to re-enable exceptions in their own thirdparty code or the libraries they compile with Godot, this behavior can be toggled with the `disable_exceptions` SCons option, which defaults to true.
9dac444
to
55550da
Compare
Tested on Windows with the same command you used, and indeed I can reproduce the results for the editor
(implicit:
No real difference on a debug build. Now an optimized one:
So 6% size reduction, 5% build time reduction. |
Backport of #80612, see that PR for discussion.