virtualx-engine/platform
Hein-Pieter van Braam-Stewart ff3099abcf Fix thread_local, tls, ASLR, and DEP with MingW
This commit changes the way Thread::caller_id works. By moving caller_id
to the .cpp file we make sure that the TLS variable doesn't get
relocated twice causing a crash. Since we build with LTO for release
builds (and everyone should be doing that anyway) there is no extra
overhead from the non-static method. We do do an extra bool check now
there but I don't think this will add much in the way of overhead.

This check cannot be avoided if we still want to be able to cache the
thread ID hash, as we had to move the setter because of limitations of
the WinRT platform. The original workaround for this was in #46813 but
this has some unintended consequences. Specifically; threads that never
create a Thread object will always return 0 in Thread::get_caller_id()
which caused a regression. For instance the editor now freezes when
importing large textures. This PR also addresses that.

Additionally we now enable ASLR support when building with MingW, this
includes a workaround for MingW. MingW refuses to create an appropriate
relocation table if no symbols are exported. So we just export the
various main() functions in godot_windows.cpp.

While ASLR support isn't criticial for Godot, previous versions of Godot
just happened to work with a dynamic base 'by accident' and some users
run Godot this way. After the thread change the .tls section now needs
relocations to make this work. By enabling ASLR at build-time we create
these relocations and people who forced ALSR on previously will now get
a working Godot again.

This fixes #47256 and fixes #47219

This is the 3.x version of this PR. For master a different approach is
possible which I will make in the coming days.
2021-03-25 23:20:12 +01:00
..
android Allow to not optimize release build 2021-03-20 23:05:13 +01:00
iphone Allow to not optimize release build 2021-03-20 23:05:13 +01:00
javascript [HTML5] Fix loading when mime-type is missing. 2021-03-20 23:10:00 +01:00
osx Allow to not optimize release build 2021-03-20 23:05:13 +01:00
server Allow to not optimize release build 2021-03-20 23:05:13 +01:00
uwp Allow to not optimize release build 2021-03-20 23:05:13 +01:00
windows Fix thread_local, tls, ASLR, and DEP with MingW 2021-03-25 23:20:12 +01:00
x11 Allow to not optimize release build 2021-03-20 23:05:13 +01:00
register_platform_apis.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
SCsub SCons: Format buildsystem files with psf/black 2020-06-10 15:30:52 +02:00