Skip to content

Conversation

@dschuff
Copy link
Member

@dschuff dschuff commented Mar 20, 2025

Since mimalloc is linked statically into the Binaryen tools, none of its
files need to be installed with Binaryen.

Also use CMAKE_SYSTEM_NAME instead of LINUX, as the latter was introduced in CMake 3.25

Since mimalloc is linked statically into the Binaryen tools, none of its
files need to be installed with Binaryen.

if(MIMALLOC_STATIC)
if(NOT(LINUX AND BUILD_STATIC_LIB) OR EMSCRIPTEN)
if(NOT(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND BUILD_STATIC_LIB) OR EMSCRIPTEN)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using the emscripten-releases build script I got a very strange behavior; namely that the LINUX variable was empty, but CMAKE_SYSTEM_NAME was set to Linux as expected. I couldn't figure out what was causing it. This change works around that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I figure it out; the LINUX variable was introduced in CMake 3.25 but we support 3.16 and use 3.21 on our bots. This is the right way to do it on those versions, so I'll just update the commit message.

add_compile_definitions(MI_DEBUG=0)

add_subdirectory(mimalloc)
add_subdirectory(mimalloc EXCLUDE_FROM_ALL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From briefly looking up EXCLUDE_FROM_ALL, it seems that it means that this directory won't be built by default? Is that what we want, or is there a more specific way to exclude it from being installed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I think what's happening here is that the target_link_libraries(binaryen mimalloc-static) causes a dependence from libbinaryen on libmimalloc-static which causes it to be built when libbinaryen does. And then the tools link it in, but it doesn't get installed, which is exactly what we want.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't really find another way to prevent the installation (see also https://discourse.cmake.org/t/hot-to-make-add-subdirectory-prevent-install-but-still-build-as-part-of-all/8698)

Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, makes (enough) sense to me.

@dschuff dschuff merged commit 3f341e5 into main Mar 20, 2025
14 checks passed
@dschuff dschuff deleted the linux-exclude branch March 20, 2025 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants