mimalloc icon indicating copy to clipboard operation
mimalloc copied to clipboard

Extra compiler flags

Open bgemmill opened this issue 1 year ago • 1 comments

I'm trying to build mimalloc with march set to a deployment machine's architecture, and I can't seem to get the extra flags passed through to mimalloc's build process.

The usual way of configuring: cmake "-DCMAKE_CXX_FLAGS= -march=skylake" . runs correctly, but does not seem to produce any makefiles containing march=skylake

Near as I can tell, this is because the CMakeLists.txt file uses mi_cflags instead, and manually sets it on the target.

Is there a good way to add compile flags from the outside?

bgemmill avatar Jul 18 '24 21:07 bgemmill

Ah, I am not a CMake expert -- but it looks like target_compile_options only adds options and still respects CMAKE_CXX_FLAGS ? (see https://cmake.org/cmake/help/latest/command/target_compile_options.html#command:target_compile_options)

Maybe it is cached and you need to first remove all files in your build folder? Or maybe use the CFLAGS environment variable? or cmake "-DCMAKE_C_FLAGS= -march=skylake" since we usually build it as a C project?.

daanx avatar Aug 13 '24 23:08 daanx