mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
mdbx-windows: rename MDBX_AVOID_CRT
build option to MDBX_DISABLE_MSVC_CRT
.
Change-Id: I124c9d86d4a596718bd9671a7c1b538b84c2dd0f
This commit is contained in:
parent
c3b2c1fdef
commit
d27e48ae1b
@ -443,7 +443,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR IOS)
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
if(MDBX_NTDLL_EXTRA_IMPLIB)
|
||||
add_mdbx_option(MDBX_AVOID_CRT "Avoid dependence from MSVC CRT and use ntdll.dll instead" OFF)
|
||||
add_mdbx_option(MDBX_WITHOUT_MSVC_CRT "Avoid dependence from MSVC CRT and use ntdll.dll instead" OFF)
|
||||
endif()
|
||||
add_mdbx_option(MDBX_CONFIG_MANUAL_TLS_CALLBACK
|
||||
"Provide mdbx_dll_handler() for manual initialization" OFF)
|
||||
@ -478,7 +478,7 @@ if(CMAKE_CXX_COMPILER_LOADED AND MDBX_CXX_STANDARD GREATER_EQUAL 11 AND MDBX_CXX
|
||||
if(NOT MDBX_AMALGAMATED_SOURCE)
|
||||
option(MDBX_ENABLE_TESTS "Build MDBX tests" ${BUILD_TESTING})
|
||||
endif()
|
||||
if(NOT MDBX_AVOID_CRT
|
||||
if(NOT MDBX_WITHOUT_MSVC_CRT
|
||||
AND NOT (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
|
||||
AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4)
|
||||
AND NOT (MSVC AND MSVC_VERSION LESS 1900))
|
||||
@ -562,7 +562,7 @@ macro(libmdbx_setup_libs TARGET MODE)
|
||||
target_link_libraries(${TARGET} ${MODE} Threads::Threads)
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(${TARGET} ${MODE} ntdll.lib)
|
||||
if(MDBX_NTDLL_EXTRA_IMPLIB AND MDBX_AVOID_CRT)
|
||||
if(MDBX_NTDLL_EXTRA_IMPLIB AND MDBX_WITHOUT_MSVC_CRT)
|
||||
target_link_libraries(${TARGET} ${MODE} ntdll_extra)
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Solaris")
|
||||
@ -601,7 +601,7 @@ if(MDBX_BUILD_SHARED_LIBRARY)
|
||||
target_setup_options(mdbx)
|
||||
libmdbx_setup_libs(mdbx PRIVATE)
|
||||
if(MSVC)
|
||||
if(MDBX_NTDLL_EXTRA_IMPLIB AND MDBX_AVOID_CRT)
|
||||
if(MDBX_NTDLL_EXTRA_IMPLIB AND MDBX_WITHOUT_MSVC_CRT)
|
||||
set_property(TARGET mdbx PROPERTY LINKER_FLAGS "/NODEFAULTLIB")
|
||||
else()
|
||||
set_property(TARGET mdbx PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
|
@ -33,6 +33,10 @@ New features:
|
||||
- Added `MDBX_ENABLE_MADVISE` build option which controls the use of POSIX `madvise()` hints and friends.
|
||||
- The internal node sizes were refined, resulting in a reduction in large/overflow pages in some use cases and a slight increase in limits for a keys size.
|
||||
|
||||
Backward compatibility break:
|
||||
|
||||
- The `MDBX_AVOID_CRT` build option was renamed to `MDBX_WITHOUT_MSVC_CRT`.
|
||||
|
||||
Fixes:
|
||||
|
||||
- Fixed performance regression due non-optimal C11 atomics usage (https://github.com/erthink/libmdbx/issues/160).
|
||||
@ -88,7 +92,7 @@ New features:
|
||||
Fixes:
|
||||
|
||||
- Fixed missing cleanup (null assigned) in the C++ commit/abort (https://github.com/erthink/libmdbx/pull/143).
|
||||
- Fixed `mdbx_realloc()` for case of nullptr and `MDBX_AVOID_CRT=ON` for Windows.
|
||||
- Fixed `mdbx_realloc()` for case of nullptr and `MDBX_WITHOUT_MSVC_CRT=ON` for Windows.
|
||||
- Fixed the possibility to use invalid and renewed (closed & re-opened, dropped & re-created) DBI-handles (https://github.com/erthink/libmdbx/issues/146).
|
||||
- Fixed 4-byte aligned access to 64-bit integers, including access to the `bootid` meta-page's field (https://github.com/erthink/libmdbx/issues/153).
|
||||
- Fixed minor/potential memory leak during page flushing and unspilling.
|
||||
@ -245,7 +249,7 @@ Deprecated functions and flags:
|
||||
- Fix missing comma in array of error messages.
|
||||
- Fix div-by-zero while copy-with-compaction for non-resizable environments.
|
||||
- Fixes & enhancements for custom-comparators.
|
||||
- Fix `MDBX_AVOID_CRT` option and missing `ntdll.def`.
|
||||
- Fix `MDBX_WITHOUT_MSVC_CRT` option and missing `ntdll.def`.
|
||||
- Fix `mdbx_env_close()` to work correctly called concurrently from several threads.
|
||||
- Fix null-deref in an ASAN-enabled builds while opening the environment with error and/or read-only.
|
||||
- Fix AddressSanitizer errors after closing the environment.
|
||||
|
@ -435,7 +435,7 @@ CMakeLists.txt or Makefile respectively.
|
||||
|
||||
It should be noted that in _libmdbx_ was efforts to resolve
|
||||
runtime dependencies from CRT and other libraries Visual Studio.
|
||||
For this is enough to define the `MDBX_AVOID_CRT` during build.
|
||||
For this is enough to define the `MDBX_WITHOUT_MSVC_CRT` during build.
|
||||
|
||||
An example of running a basic test script can be found in the
|
||||
[CI-script](appveyor.yml) for [AppVeyor](https://www.appveyor.com/). To
|
||||
|
14
appveyor.yml
14
appveyor.yml
@ -9,22 +9,22 @@ environment:
|
||||
CMAKE_GENERATOR: Visual Studio 16 2019
|
||||
TOOLSET: 142
|
||||
MDBX_BUILD_SHARED_LIBRARY: OFF
|
||||
MDBX_AVOID_CRT: OFF
|
||||
MDBX_WITHOUT_MSVC_CRT: OFF
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
CMAKE_GENERATOR: Visual Studio 16 2019
|
||||
TOOLSET: 142
|
||||
MDBX_BUILD_SHARED_LIBRARY: ON
|
||||
MDBX_AVOID_CRT: ON
|
||||
MDBX_WITHOUT_MSVC_CRT: ON
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
CMAKE_GENERATOR: Visual Studio 16 2019
|
||||
TOOLSET: 142
|
||||
MDBX_BUILD_SHARED_LIBRARY: OFF
|
||||
MDBX_AVOID_CRT: ON
|
||||
MDBX_WITHOUT_MSVC_CRT: ON
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
CMAKE_GENERATOR: Visual Studio 16 2019
|
||||
TOOLSET: 142
|
||||
MDBX_BUILD_SHARED_LIBRARY: ON
|
||||
MDBX_AVOID_CRT: OFF
|
||||
MDBX_WITHOUT_MSVC_CRT: OFF
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_GENERATOR: Visual Studio 15 2017
|
||||
TOOLSET: 141
|
||||
@ -69,7 +69,7 @@ build_script:
|
||||
Write-Output "Configuration: $env:CONFIGURATION"
|
||||
Write-Output "Platform: $env:PLATFORM"
|
||||
Write-Output "Toolchain: $env:CMAKE_GENERATOR v$env:TOOLSET"
|
||||
Write-Output "Options: MDBX_AVOID_CRT=$env:MDBX_AVOID_CRT MDBX_BUILD_SHARED_LIBRARY=$env:MDBX_BUILD_SHARED_LIBRARY"
|
||||
Write-Output "Options: MDBX_WITHOUT_MSVC_CRT=$env:MDBX_AVOID_CRT MDBX_BUILD_SHARED_LIBRARY=$env:MDBX_BUILD_SHARED_LIBRARY"
|
||||
Write-Output "*******************************************************************************"
|
||||
|
||||
md _build -Force | Out-Null
|
||||
@ -80,9 +80,9 @@ build_script:
|
||||
if ($env:PLATFORM -eq "x64") {
|
||||
$generator = "$generator Win64"
|
||||
}
|
||||
& cmake -G "$generator" -D CMAKE_CONFIGURATION_TYPES="Debug;Release;RelWithDebInfo" -D MDBX_AVOID_CRT:BOOL=$env:MDBX_AVOID_CRT -D MDBX_BUILD_SHARED_LIBRARY:BOOL=$env:MDBX_BUILD_SHARED_LIBRARY ..
|
||||
& cmake -G "$generator" -D CMAKE_CONFIGURATION_TYPES="Debug;Release;RelWithDebInfo" -D MDBX_WITHOUT_MSVC_CRT:BOOL=$env:MDBX_AVOID_CRT -D MDBX_BUILD_SHARED_LIBRARY:BOOL=$env:MDBX_BUILD_SHARED_LIBRARY ..
|
||||
} else {
|
||||
& cmake -G "$generator" -A $env:PLATFORM -D CMAKE_CONFIGURATION_TYPES="Debug;Release;RelWithDebInfo" -DMDBX_AVOID_CRT:BOOL=$env:MDBX_AVOID_CRT -D MDBX_BUILD_SHARED_LIBRARY:BOOL=$env:MDBX_BUILD_SHARED_LIBRARY ..
|
||||
& cmake -G "$generator" -A $env:PLATFORM -D CMAKE_CONFIGURATION_TYPES="Debug;Release;RelWithDebInfo" -DMDBX_WITHOUT_MSVC_CRT:BOOL=$env:MDBX_AVOID_CRT -D MDBX_BUILD_SHARED_LIBRARY:BOOL=$env:MDBX_BUILD_SHARED_LIBRARY ..
|
||||
}
|
||||
if ($LastExitCode -ne 0) {
|
||||
throw "Exec: $ErrorMessage"
|
||||
|
5
mdbx.h++
5
mdbx.h++
@ -21,8 +21,9 @@
|
||||
#error "C++11 or better is required"
|
||||
#endif
|
||||
|
||||
#if (defined(_WIN32) || defined(_WIN64)) && MDBX_AVOID_CRT
|
||||
#error "CRT is required for C++ API, the MDBX_AVOID_CRT option must be disabled"
|
||||
#if (defined(_WIN32) || defined(_WIN64)) && MDBX_WITHOUT_MSVC_CRT
|
||||
#error \
|
||||
"CRT is required for C++ API, the MDBX_WITHOUT_MSVC_CRT option must be disabled"
|
||||
#endif /* Windows */
|
||||
|
||||
#ifndef __has_include
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
/* Windows */
|
||||
#cmakedefine01 MDBX_CONFIG_MANUAL_TLS_CALLBACK
|
||||
#cmakedefine01 MDBX_AVOID_CRT
|
||||
#cmakedefine01 MDBX_WITHOUT_MSVC_CRT
|
||||
|
||||
/* MacOS & iOS */
|
||||
#cmakedefine01 MDBX_OSX_SPEED_INSTEADOF_DURABILITY
|
||||
|
@ -21975,7 +21975,7 @@ __dll_export
|
||||
" MDBX_OSX_SPEED_INSTEADOF_DURABILITY=" STRINGIFY(MDBX_OSX_SPEED_INSTEADOF_DURABILITY)
|
||||
#endif /* MacOS */
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
" MDBX_AVOID_CRT=" STRINGIFY(MDBX_AVOID_CRT)
|
||||
" MDBX_WITHOUT_MSVC_CRT=" STRINGIFY(MDBX_AVOID_CRT)
|
||||
" MDBX_CONFIG_MANUAL_TLS_CALLBACK=" STRINGIFY(MDBX_CONFIG_MANUAL_TLS_CALLBACK)
|
||||
" MDBX_BUILD_SHARED_LIBRARY=" STRINGIFY(MDBX_BUILD_SHARED_LIBRARY)
|
||||
" WINVER=" STRINGIFY(WINVER)
|
||||
|
@ -25,15 +25,15 @@
|
||||
static void mdbx_winnt_import(void);
|
||||
|
||||
#if MDBX_BUILD_SHARED_LIBRARY
|
||||
#if MDBX_AVOID_CRT && defined(NDEBUG)
|
||||
#if MDBX_WITHOUT_MSVC_CRT && defined(NDEBUG)
|
||||
/* DEBUG/CHECKED builds still require MSVC's CRT for runtime checks.
|
||||
*
|
||||
* Define dll's entry point only for Release build when NDEBUG is defined and
|
||||
* MDBX_AVOID_CRT=ON. if the entry point isn't defined then MSVC's will
|
||||
* MDBX_WITHOUT_MSVC_CRT=ON. if the entry point isn't defined then MSVC's will
|
||||
* automatically use DllMainCRTStartup() from CRT library, which also
|
||||
* automatically call DllMain() from our mdbx.dll */
|
||||
#pragma comment(linker, "/ENTRY:DllMain")
|
||||
#endif /* MDBX_AVOID_CRT */
|
||||
#endif /* MDBX_WITHOUT_MSVC_CRT */
|
||||
|
||||
BOOL APIENTRY DllMain(HANDLE module, DWORD reason, LPVOID reserved)
|
||||
#else
|
||||
|
@ -35,7 +35,7 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#if !defined(_NO_CRT_STDIO_INLINE) && MDBX_BUILD_SHARED_LIBRARY && \
|
||||
!defined(MDBX_TOOLS) && MDBX_AVOID_CRT
|
||||
!defined(MDBX_TOOLS) && MDBX_WITHOUT_MSVC_CRT
|
||||
#define _NO_CRT_STDIO_INLINE
|
||||
#endif
|
||||
#elif !defined(_POSIX_C_SOURCE)
|
||||
@ -166,7 +166,7 @@ typedef struct {
|
||||
} mdbx_condpair_t;
|
||||
typedef CRITICAL_SECTION mdbx_fastmutex_t;
|
||||
|
||||
#if MDBX_AVOID_CRT
|
||||
#if MDBX_WITHOUT_MSVC_CRT
|
||||
#ifndef mdbx_malloc
|
||||
static inline void *mdbx_malloc(size_t bytes) {
|
||||
return LocalAlloc(LMEM_FIXED, bytes);
|
||||
@ -195,7 +195,7 @@ static inline void *mdbx_realloc(void *ptr, size_t bytes) {
|
||||
#define mdbx_realloc realloc
|
||||
#define mdbx_free free
|
||||
#define mdbx_strdup _strdup
|
||||
#endif /* MDBX_AVOID_CRT */
|
||||
#endif /* MDBX_WITHOUT_MSVC_CRT */
|
||||
|
||||
#ifndef snprintf
|
||||
#define snprintf _snprintf /* ntdll */
|
||||
@ -243,7 +243,7 @@ typedef pthread_mutex_t mdbx_fastmutex_t;
|
||||
/* malloc_usable_size() already provided */
|
||||
#elif defined(__APPLE__)
|
||||
#define malloc_usable_size(ptr) malloc_size(ptr)
|
||||
#elif defined(_MSC_VER) && !MDBX_AVOID_CRT
|
||||
#elif defined(_MSC_VER) && !MDBX_WITHOUT_MSVC_CRT
|
||||
#define malloc_usable_size(ptr) _msize(ptr)
|
||||
#endif /* malloc_usable_size */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user