mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 08:15:18 -04:00
makepanda: Support building with mimalloc on Windows, experimentally
Partial backport of 07545bc9e318d1799ceabe8838d04d7ad9297a45 for Windows, requires building with `--override USE_MEMORY_MIMALLOC=1 --override USE_DELETED_CHAIN=UNDEF` for optimum effect
This commit is contained in:
parent
be2e07637f
commit
a37dfa727e
@ -387,6 +387,10 @@ typedef struct _object PyObject;
|
|||||||
// This specialized malloc implementation can perform the required alignment.
|
// This specialized malloc implementation can perform the required alignment.
|
||||||
#undef MEMORY_HOOK_DO_ALIGN
|
#undef MEMORY_HOOK_DO_ALIGN
|
||||||
|
|
||||||
|
#elif defined(USE_MEMORY_MIMALLOC)
|
||||||
|
// This one does, too.
|
||||||
|
#undef MEMORY_HOOK_DO_ALIGN
|
||||||
|
|
||||||
#elif defined(USE_MEMORY_PTMALLOC2)
|
#elif defined(USE_MEMORY_PTMALLOC2)
|
||||||
// But not this one. For some reason it crashes when we try to build it with
|
// But not this one. For some reason it crashes when we try to build it with
|
||||||
// alignment 16. So if we're using ptmalloc2, we need to enforce alignment
|
// alignment 16. So if we're using ptmalloc2, we need to enforce alignment
|
||||||
@ -438,7 +442,7 @@ typedef struct _object PyObject;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Determine our memory-allocation requirements. */
|
/* Determine our memory-allocation requirements. */
|
||||||
#if defined(USE_MEMORY_PTMALLOC2) || defined(USE_MEMORY_DLMALLOC) || defined(DO_MEMORY_USAGE) || defined(MEMORY_HOOK_DO_ALIGN)
|
#if defined(USE_MEMORY_MIMALLOC) || defined(USE_MEMORY_PTMALLOC2) || defined(USE_MEMORY_DLMALLOC) || defined(DO_MEMORY_USAGE) || defined(MEMORY_HOOK_DO_ALIGN)
|
||||||
/* In this case we have some custom memory management requirements. */
|
/* In this case we have some custom memory management requirements. */
|
||||||
#else
|
#else
|
||||||
/* Otherwise, if we have no custom memory management needs at all, we
|
/* Otherwise, if we have no custom memory management needs at all, we
|
||||||
|
@ -51,6 +51,18 @@ static_assert((MEMORY_HOOK_ALIGNMENT & (MEMORY_HOOK_ALIGNMENT - 1)) == 0,
|
|||||||
|
|
||||||
#if defined(CPPPARSER)
|
#if defined(CPPPARSER)
|
||||||
|
|
||||||
|
#elif defined(USE_MEMORY_MIMALLOC)
|
||||||
|
|
||||||
|
// mimalloc is a modern memory manager by Microsoft that is very fast as well
|
||||||
|
// as thread-safe.
|
||||||
|
|
||||||
|
#include "mimalloc.h"
|
||||||
|
|
||||||
|
#define call_malloc mi_malloc
|
||||||
|
#define call_realloc mi_realloc
|
||||||
|
#define call_free mi_free
|
||||||
|
#undef MEMORY_HOOK_MALLOC_LOCK
|
||||||
|
|
||||||
#elif defined(USE_MEMORY_DLMALLOC)
|
#elif defined(USE_MEMORY_DLMALLOC)
|
||||||
|
|
||||||
// Memory manager: DLMALLOC This is Doug Lea's memory manager. It is very
|
// Memory manager: DLMALLOC This is Doug Lea's memory manager. It is very
|
||||||
|
@ -103,6 +103,7 @@ PkgListSet(["PYTHON", "DIRECT", # Python support
|
|||||||
"PANDAPARTICLESYSTEM", # Built in particle system
|
"PANDAPARTICLESYSTEM", # Built in particle system
|
||||||
"CONTRIB", # Experimental
|
"CONTRIB", # Experimental
|
||||||
"SSE2", "NEON", # Compiler features
|
"SSE2", "NEON", # Compiler features
|
||||||
|
"MIMALLOC", # Memory allocators
|
||||||
])
|
])
|
||||||
|
|
||||||
CheckPandaSourceTree()
|
CheckPandaSourceTree()
|
||||||
@ -767,6 +768,7 @@ if (COMPILER == "MSVC"):
|
|||||||
if (PkgSkip("DIRECTCAM")==0): LibName("DIRECTCAM", "quartz.lib")
|
if (PkgSkip("DIRECTCAM")==0): LibName("DIRECTCAM", "quartz.lib")
|
||||||
if (PkgSkip("DIRECTCAM")==0): LibName("DIRECTCAM", "odbc32.lib")
|
if (PkgSkip("DIRECTCAM")==0): LibName("DIRECTCAM", "odbc32.lib")
|
||||||
if (PkgSkip("DIRECTCAM")==0): LibName("DIRECTCAM", "odbccp32.lib")
|
if (PkgSkip("DIRECTCAM")==0): LibName("DIRECTCAM", "odbccp32.lib")
|
||||||
|
if (PkgSkip("MIMALLOC")==0): LibName("MIMALLOC", GetThirdpartyDir() + "mimalloc/lib/mimalloc-static.lib")
|
||||||
if (PkgSkip("OPENSSL")==0):
|
if (PkgSkip("OPENSSL")==0):
|
||||||
if os.path.isfile(GetThirdpartyDir() + "openssl/lib/libpandassl.lib"):
|
if os.path.isfile(GetThirdpartyDir() + "openssl/lib/libpandassl.lib"):
|
||||||
LibName("OPENSSL", GetThirdpartyDir() + "openssl/lib/libpandassl.lib")
|
LibName("OPENSSL", GetThirdpartyDir() + "openssl/lib/libpandassl.lib")
|
||||||
@ -949,6 +951,8 @@ if (COMPILER == "MSVC"):
|
|||||||
LibName("BULLET", GetThirdpartyDir() + "bullet/lib/BulletSoftBody" + suffix)
|
LibName("BULLET", GetThirdpartyDir() + "bullet/lib/BulletSoftBody" + suffix)
|
||||||
|
|
||||||
if (COMPILER=="GCC"):
|
if (COMPILER=="GCC"):
|
||||||
|
PkgDisable("MIMALLOC") # no discernable benefit over glibc
|
||||||
|
|
||||||
if GetTarget() != "darwin":
|
if GetTarget() != "darwin":
|
||||||
PkgDisable("CARBON")
|
PkgDisable("CARBON")
|
||||||
PkgDisable("COCOA")
|
PkgDisable("COCOA")
|
||||||
@ -3766,7 +3770,7 @@ if GetTarget() == 'windows':
|
|||||||
# DIRECTORY: dtool/src/dtoolbase/
|
# DIRECTORY: dtool/src/dtoolbase/
|
||||||
#
|
#
|
||||||
|
|
||||||
OPTS=['DIR:dtool/src/dtoolbase', 'BUILDING:DTOOL']
|
OPTS=['DIR:dtool/src/dtoolbase', 'BUILDING:DTOOL', 'MIMALLOC']
|
||||||
TargetAdd('p3dtoolbase_composite1.obj', opts=OPTS, input='p3dtoolbase_composite1.cxx')
|
TargetAdd('p3dtoolbase_composite1.obj', opts=OPTS, input='p3dtoolbase_composite1.cxx')
|
||||||
TargetAdd('p3dtoolbase_composite2.obj', opts=OPTS, input='p3dtoolbase_composite2.cxx')
|
TargetAdd('p3dtoolbase_composite2.obj', opts=OPTS, input='p3dtoolbase_composite2.cxx')
|
||||||
TargetAdd('p3dtoolbase_lookup3.obj', opts=OPTS, input='lookup3.c')
|
TargetAdd('p3dtoolbase_lookup3.obj', opts=OPTS, input='lookup3.c')
|
||||||
@ -3797,7 +3801,7 @@ TargetAdd('libp3dtool.dll', input='p3dtoolbase_composite1.obj')
|
|||||||
TargetAdd('libp3dtool.dll', input='p3dtoolbase_composite2.obj')
|
TargetAdd('libp3dtool.dll', input='p3dtoolbase_composite2.obj')
|
||||||
TargetAdd('libp3dtool.dll', input='p3dtoolbase_indent.obj')
|
TargetAdd('libp3dtool.dll', input='p3dtoolbase_indent.obj')
|
||||||
TargetAdd('libp3dtool.dll', input='p3dtoolbase_lookup3.obj')
|
TargetAdd('libp3dtool.dll', input='p3dtoolbase_lookup3.obj')
|
||||||
TargetAdd('libp3dtool.dll', opts=['ADVAPI','WINSHELL','WINKERNEL'])
|
TargetAdd('libp3dtool.dll', opts=['ADVAPI','WINSHELL','WINKERNEL','MIMALLOC'])
|
||||||
|
|
||||||
#
|
#
|
||||||
# DIRECTORY: dtool/src/cppparser/
|
# DIRECTORY: dtool/src/cppparser/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user