mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-18 03:32:55 +00:00
build: optional mimalloc replacement for system malloc
Toggle with -Denable_mimalloc=enabled/disabled/auto.
This commit is contained in:
parent
b7792622a9
commit
fe77d9c2a0
|
|
@ -92,6 +92,8 @@ simdutf_dep = dependency('simdutf',
|
|||
)
|
||||
miniaudio_dep = dependency('miniaudio')
|
||||
|
||||
mimalloc_dep = cc.find_library('mimalloc', required: get_option('enable_mimalloc'))
|
||||
|
||||
subdir('targets/util')
|
||||
subdir('targets/java')
|
||||
subdir('targets/nbt')
|
||||
|
|
|
|||
|
|
@ -40,3 +40,10 @@ option(
|
|||
value: 'frustum',
|
||||
description: 'Occlusion culling mode. Off disables ALL CULLING (debug only!), Frustum disables offscreen rendering (default), BFS is experimental connectivity culling, hardware uses GPU queries.',
|
||||
)
|
||||
|
||||
option(
|
||||
'enable_mimalloc',
|
||||
type: 'feature',
|
||||
value: 'auto',
|
||||
description: 'Link mimalloc as the malloc implementation. Requires libmimalloc-dev.',
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,18 @@ if host_machine.system() == 'linux'
|
|||
platform_sources += files(fs.read('linux_sources.txt').strip().split('\n'))
|
||||
endif
|
||||
|
||||
client_dependencies = [
|
||||
client_dependencies = []
|
||||
|
||||
# mimalloc must come first so the linker resolves malloc/free symbols to it
|
||||
# before glibc. --no-as-needed prevents the linker from dropping it as
|
||||
# "unreferenced" (the override happens via weak symbols, not direct calls).
|
||||
client_link_args = []
|
||||
if mimalloc_dep.found()
|
||||
client_dependencies += mimalloc_dep
|
||||
client_link_args += ['-Wl,--no-as-needed']
|
||||
endif
|
||||
|
||||
client_dependencies += [
|
||||
java_dep,
|
||||
nbt_dep,
|
||||
render_dep,
|
||||
|
|
@ -52,6 +63,7 @@ client = executable(
|
|||
'-D_UNICODE',
|
||||
],
|
||||
c_args: global_cpp_defs + ['-DUNICODE', '-D_UNICODE'],
|
||||
link_args: client_link_args,
|
||||
install: true,
|
||||
install_dir: '',
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue