Skip to content

Add optional config map to metacall_load_from_X API for explicit compiler/linker flagsΒ #634

@ROKUMATE

Description

@ROKUMATE

πŸš€ Feature

Add an optional config map parameter to metacall_load_from_X functions so callers can pass explicit compiler flags, include paths, and library paths directly β€” replacing the current fragile path-guessing approach.

Is your feature request related to a problem?

metacall_load_from_package and related functions have no way to accept loader-specific configuration. The C loader works around this by guessing paths from execution_paths, which breaks whenever headers and libraries are in different directories. There is also no way to pass compiler flags (-std=c++17, -DFOO, etc.) or extra include/library paths at call time.

This was directly exposed by #631 where load_from_package failed to find libloadtest.so and loadtest.h because they were in different locations than the loader expected.

Describe the solution you'd like

Add an optional void *config parameter (a metacall_value map) to the load functions:

// Current
int metacall_load_from_package(const char *tag, const char *name, void **handle);

// Proposed
int metacall_load_from_package(const char *tag, const char *name, void **handle, void *config);

The config map is loader-defined. For the C loader, supported keys would be:

Key Maps to
"include_paths" -I /path/to/include
"library_paths" -L /path/to/lib
"compiler_flags" -std=c++17, -DFOO, etc.

Passing NULL preserves the current behavior for backward compatibility.

Files to change: metacall_loaders.h, metacall_loaders.c, the loader interface in source/loader/, and c_loader_impl.cpp to consume the keys. Other loaders can add their own keys incrementally.

Describe alternatives you've considered

Additional context

This was discussed with @viferga as the next planned contribution after the immediate fix in #631. The config map approach is already part of the broader design direction for the metacall_load_from_X API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions