Merge pull request #426 from shuffle2/xsave-workaround-fix
Redo commit 932945d480
Fixes crashes from running on hardware with FMA3 support and software which doesn't support it.
This commit is contained in:
commit
3d21c6777e
|
@ -2,20 +2,12 @@
|
|||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#if defined(_WIN32) && defined(_ARCH_64)
|
||||
#if defined(_WIN32) && defined(_M_X86_64)
|
||||
|
||||
#include <math.h>
|
||||
#include <Windows.h>
|
||||
|
||||
// This puts the rest of this translation unit into a segment which is
|
||||
// initialized by the CRT *before* any of the other code (including C++
|
||||
// static initializers).
|
||||
#pragma warning(disable : 4075)
|
||||
#pragma init_seg(".CRT$XCB")
|
||||
|
||||
struct EnableXSaveWorkaround
|
||||
{
|
||||
EnableXSaveWorkaround()
|
||||
void EnableXSaveWorkaround()
|
||||
{
|
||||
// Some Windows environments may have hardware support for AVX/FMA,
|
||||
// but the OS does not support it. The CRT math library does not support
|
||||
|
@ -29,12 +21,19 @@ struct EnableXSaveWorkaround
|
|||
_set_FMA3_enable(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Create a segment which is recognized by the linker to be part of the CRT
|
||||
// initialization. XI* = C startup, XC* = C++ startup. "A" placement is reserved
|
||||
// for system use. Thus, the earliest we can get is XIB (C startup is before
|
||||
// C++).
|
||||
#pragma section(".CRT$XIB", read)
|
||||
|
||||
// Place a symbol in the special segment, make it have C linkage so that
|
||||
// referencing it doesn't require ugly decorated names.
|
||||
// Use /include:XSaveWorkaround linker flag to enable this.
|
||||
extern "C" {
|
||||
__declspec(allocate(".CRT$XIB"))
|
||||
decltype(&EnableXSaveWorkaround) XSaveWorkaround = EnableXSaveWorkaround;
|
||||
};
|
||||
|
||||
static EnableXSaveWorkaround enableXSaveWorkaround;
|
||||
|
||||
// N.B. Any code after this will still be in the .CRT$XCB segment. Please just
|
||||
// do not append any code here unless it is intended to be executed before
|
||||
// static initializers.
|
||||
|
||||
#endif
|
||||
|
|
|
@ -106,6 +106,11 @@
|
|||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
</Link>
|
||||
<!--Link Base:Application-->
|
||||
<Link Condition="'$(ConfigurationType)'=='Application'">
|
||||
<!--See Common/EnableXSaveWorkaround.cpp-->
|
||||
<ForceSymbolReferences>XSaveWorkaround</ForceSymbolReferences>
|
||||
</Link>
|
||||
<Lib>
|
||||
<TreatLibWarningAsErrors>true</TreatLibWarningAsErrors>
|
||||
<LinkTimeCodeGeneration Condition="'$(DolphinRelease)'=='true'">true</LinkTimeCodeGeneration>
|
||||
|
|
Loading…
Reference in New Issue