-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Prevent LTCG (MSVC LTO) from removing "pck" section #57450
Conversation
7e62eb1
to
e4bde93
Compare
For a bit more safety it may be worthy to surround the assignment with |
According to the documentation this won't work
|
Thanks! |
Cherry-picked for 3.5. |
Cherry-picked for 3.4.3. |
This seems to have broken template build with MinGW-GCC at least:
This can either be fixed with: diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp
index c4926209c7..506c903c35 100644
--- a/platform/windows/godot_windows.cpp
+++ b/platform/windows/godot_windows.cpp
@@ -41,7 +41,7 @@
#pragma section("pck", read)
__declspec(allocate("pck")) static char dummy[8] = { 0 };
#elif defined __GNUC__
-static const char dummy[8] __attribute__((section("pck"), used)) = { 0 };
+static char dummy[8] __attribute__((section("pck"), used)) = { 0 };
#endif
#endif or: diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp
index c4926209c7..906403c592 100644
--- a/platform/windows/godot_windows.cpp
+++ b/platform/windows/godot_windows.cpp
@@ -142,7 +142,7 @@ int widechar_main(int argc, wchar_t **argv) {
#ifndef TOOLS_ENABLED
// Workaround to prevent LTCG (MSVC LTO) from removing "pck" section
- char *dummy_guard = dummy;
+ char *dummy_guard = (char *)dummy;
#endif
char **argv_utf8 = new char *[argc]; Not sure which is best / preserves the compiler magic that keeps this section in place. |
Hmm, I think that it would be better to just wrap this part in |
Follow-up to godotengine#57450. (cherry picked from commit 5a1f42b)
Fixes #35590
MSVC doesn't have equivalent of GCC
__attribute__((used))
so this is the easiest workaround I could think of to prevent removing unused section.