foonathan / memory

STL compatible C++ memory allocator library using a new RawAllocator concept that is similar to an Allocator but easier to use and write.

Home Page:https://memory.foonathan.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build issues on MacOS while building tools with static flag

nicosmd opened this issue · comments

Hey,

when building for MacOS M1 I get the following error: ld: library not found for -lcrt0.o while clang is trying to build the tools. I figured out that this might caused by the static flag here:

if (CMAKE_CROSSCOMPILING)
    # statically link when cross compiling so emulator doesn't need library paths
    if (MSVC)
        set_target_properties(foonathan_memory_node_size_debugger PROPERTIES LINK_FLAGS "/WHOLEARCHIVE")
    else()
        set_target_properties(foonathan_memory_node_size_debugger PROPERTIES LINK_FLAGS "-static") 
    endif()
endif()

which seems to be not supported: https://stackoverflow.com/questions/3801011/ld-library-not-found-for-lcrt0-o-on-osx-10-6-with-gcc-clang-static-flag

Hm, I'm not sure what the best approach is here.

To clarify: are you cross-compiling on an M1 or cross-compiling to the M1? Can you add the appropriate logic to disable -static with that configuration?

Unfortunately, I'm not building it for my own. The issue came up while I was trying to allow cross compilation in the foonathan memory conan package: conan-io/conan-center-index#16997
I will most likely just remove the -static flag there using a patch since it is not needed to run in emulators in conan center. But that's not a feasible solution for this repo. I'm also not sure how to deal with it appropriately. But maybe it is already sufficient to add a CMake option like LINK_STATIC so it can be at least disabled from outside?

Actually, I think that logic is no longer necessary.

As of #129, the node sizes are determined using compiler error messages; the tool doesn't matter anymore. So you can just remove the entire `if(). Can you do a PR?