mdbx-windows: setup DllMain() as entry and don't linking with CRT.

17 of 17 for https://github.com/leo-yuriev/libmdbx/issues/43

Change-Id: Ie3b37633ab081ca4ba2dc485e67de96df032a3df
This commit is contained in:
Leonid Yuriev 2018-10-14 12:47:29 +03:00
parent 25ab7da33e
commit ae83982811
2 changed files with 21 additions and 0 deletions

View File

@ -133,6 +133,9 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<BufferSecurityCheck>false</BufferSecurityCheck>
<AssemblerOutput>All</AssemblerOutput>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
@ -142,6 +145,7 @@
<OptimizeReferences>true</OptimizeReferences>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<AdditionalDependencies>ntdll.lib;$(IntermediateOutputPath)mdbx_ntdll_extra.lib;kernel32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Link>
<CustomBuildStep>
<Message>Generate fake-library mdbx_ntdll_extra.lib for $(PlatformTarget)</Message>
@ -185,10 +189,14 @@
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
<WarningLevel>EnableAllWarnings</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<BufferSecurityCheck>false</BufferSecurityCheck>
<AssemblerOutput>All</AssemblerOutput>
</ClCompile>
<Link>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<AdditionalDependencies>ntdll.lib;$(IntermediateOutputPath)mdbx_ntdll_extra.lib;kernel32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Link>
<CustomBuildStep>
<Message>Generate fake-library mdbx_ntdll_extra.lib for $(PlatformTarget)</Message>

View File

@ -27,6 +27,19 @@
static void mdbx_winnt_import(void);
#ifdef MDBX_BUILD_DLL
/* DEBUG/CHECKED builds still require MSVC's CRT for runtime checks.
*
* Therefore we don't define dll's entry point for debug/checked builds by MSVC.
* In this case MSVC's will automatically use DllMainCRTStartup() from CRT
* library, which also automatically call DllMain() from our mdbx.dll
*
* On the other side, for RELEASE builds
* we explicitly define DllMain() as the entry point and don't linking with
* any CRT libraries (IgnoreAllDefaultLibraries = Yes). */
#if !defined(_MSC_VER) || defined(NDEBUG)
#pragma comment(linker, "/ENTRY:DllMain")
#endif
BOOL APIENTRY DllMain(HANDLE module, DWORD reason, LPVOID reserved)
#else
#if !MDBX_CONFIG_MANUAL_TLS_CALLBACK