Skip to content

Commit

Permalink
Move mimalloc to a dedicated Library to avoid using C++ flags
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Sep 19, 2024
1 parent 902f8bb commit 0b472bc
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,17 @@ def _set_cpp_flags(compiler, extension):

extension.define_macros.extend(defines)
if compiler.compiler_type in {"unix", "cygwin", "mingw32"}:
extension.extra_compile_args.append("-std=c++{}".format(cpp_target))
if extension.language == "c++":
extension.extra_compile_args.append("-std=c++{}".format(cpp_target))
extension.extra_compile_args.append("-pthread")
extension.extra_compile_args.append("-fPIC")
extension.extra_compile_args.append("-Wno-alloc-size-larger-than")
extension.extra_compile_args.append("-Wno-char-subscripts")
extension.extra_link_args.append("-pthread")
extension.extra_link_args.append("-fPIC")
elif compiler.compiler_type == "msvc":
extension.extra_compile_args.append("/std:c{}".format(cpp_target))
if extension.language == "c++":
extension.extra_compile_args.append("/std:c{}".format(cpp_target))


def _set_debug_flags(compiler, extension):
Expand Down Expand Up @@ -751,6 +753,19 @@ def run(self):

setuptools.setup(
libraries=[
Library(
"mimalloc",
language="c",
sources=[
os.path.join(SETUP_FOLDER, "vendor", "FAMSA", "libs", "mimalloc", "src", "static.c"),
],
include_dirs=[
os.path.join(SETUP_FOLDER, "vendor", "FAMSA", "libs", "mimalloc", "include"),
],
depends=[
os.path.join(SETUP_FOLDER, "vendor", "FAMSA", "libs", "mimalloc", "include", "mimalloc.h"),
]
),
# NOTE(@althonos): libdeflate is only needed for `IOService`, but we
# don't use the FAMSA I/O so we don't have to build
# it and link to it, as long as we're not building
Expand Down Expand Up @@ -781,7 +796,6 @@ def run(self):
os.path.join(SETUP_FOLDER, "vendor", "FAMSA", "src", "core", "profile_seq.cpp"),
os.path.join(SETUP_FOLDER, "vendor", "FAMSA", "src", "core", "sequence.cpp"),
os.path.join(SETUP_FOLDER, "vendor", "FAMSA", "src", "core", "queues.cpp"),
os.path.join(SETUP_FOLDER, "vendor", "FAMSA", "libs", "mimalloc", "src", "static.c"),
# LCS_OBJS
os.path.join(SETUP_FOLDER, "vendor", "FAMSA", "src", "lcs", "lcsbp.cpp"),
os.path.join(SETUP_FOLDER, "vendor", "FAMSA", "src", "lcs", "lcsbp_classic.cpp"),
Expand Down Expand Up @@ -873,6 +887,7 @@ def run(self):
os.path.join(SETUP_FOLDER, "include"),
],
libraries=[
"mimalloc",
"famsa",
],
),
Expand Down

0 comments on commit 0b472bc

Please sign in to comment.