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

Fix stack alignment in build script for x86 Windows #151

Merged
merged 3 commits into from Jan 8, 2019

Conversation

Projects
None yet
2 participants
@slipher
Copy link
Contributor

slipher commented Jan 5, 2019

No description provided.

@slipher slipher force-pushed the slipher:align branch from aae6981 to 0c821bc Jan 6, 2019

@slipher

This comment has been minimized.

Copy link
Contributor

slipher commented Jan 6, 2019

I moved the ALIGN_STACK macro into Compiler.h and added it a couple more places where mingw code is called from non-mingw code. For example, the unhandled exception filter, cause it would be a real shame if we crashed while we were crashing.

@slipher slipher closed this Jan 6, 2019

@slipher slipher reopened this Jan 6, 2019

@@ -2533,7 +2533,7 @@ static HANDLE IRC_ThreadHandle = nullptr;
IRC_SystemThreadProc
==================
*/
static DWORD WINAPI IRC_SystemThreadProc( LPVOID )
static DWORD ALIGN_STACK_FOR_MINGW WINAPI IRC_SystemThreadProc( LPVOID )

This comment has been minimized.

@Kangz

Kangz Jan 7, 2019

Contributor

Should this attribute be used on every thread entrypoint? There are at least 3 other threads I know of: in . System.cpp, VirtualMachine.cpp and somewhere in the renderer.

This comment has been minimized.

@slipher

slipher Jan 7, 2019

Contributor

I assume it should be handled correctly in the ones that use the std::thread library provided by mingw, so I didn't put it on the singleton socket one. Added the attribute to the DLL entry and the render thread.

@slipher slipher force-pushed the slipher:align branch from 0c821bc to 95e0f1a Jan 7, 2019

slipher added some commits Jan 5, 2019

Build external_deps DLLs which can be safely called on x86 Windows
By default gcc assumes the stack will be 16 byte aligned on a function
entry. This is incompatible with MSVC code which only does 4 byte
alignment. The problem manifests when SSE instructions are used on the
stack. So decrease the alignment assumption to 4 with the
-mpreferred-stack-boundary=2 flag.

Also explicitly enable SSE2 for x86 Windows builds to match Daemon
flags.

@slipher slipher force-pushed the slipher:align branch from 95e0f1a to 3c650cf Jan 7, 2019

@Kangz

Kangz approved these changes Jan 7, 2019

Copy link
Contributor

Kangz left a comment

LGTM

@slipher slipher merged commit e45f116 into DaemonEngine:master Jan 8, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment