Skip to content

[FEA] Optionally compile rmm as object library #2463

Open

Description

@baliika

Is your feature request related to a problem? Please describe.
When someone is creating a static library (e.g., libnvcomp_static.a), they might want to embed librmm.a into their own artifact. This is to simplify dependency management for users, especially, if rmm is only used for a subset of the library's functionality. This is basically the case for nvcomp, where we only use librmm in a subset of the functions and we don't want to force users to always have librmm available on their system.
During a static library creation, the linker is not invoked, so we cannot pull of the -Wl,--whole-archive trick that one can do when creating a shared library.

Describe the solution you'd like
Ideally we would like to have a cmake option to allow us to compile librmm into an OBJECT library.
On your side, the change is something along the lines of:

option(BUILD_OBJECT_LIBS "Configure CMake to build rmm as object library" OFF)

if(BUILD_OBJECT_LIBS)
    set(RMM_LIB_TYPE OBJECT)
elseif(BUILD_SHARED_LIBS)
    set(RMM_LIB_TYPE SHARED)
else()
    set(RMM_LIB_TYPE STATIC)
endif()

add_library(rmm ${RMM_LIB_TYPE} ...)

We could certainly run ar x librmm.a to get back the object files and embed those, but a lot more elegant way would be to embed rmm via $<TARGET_OBJECTS:rmm::rmm> once we compiled it as an object library.

Describe alternatives you've considered

  • ar x librmm.a and then embedding the resulting object files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions