Skip to content

Missing LLVM Target Initialization APIs #935

@junlarsen

Description

@junlarsen
Partially related to #932

In the llvm-c/Target.h header there are six macros which declare functions for target initialization. These are ran for each target to generate a set of APIs exposed to LLVM-C.

Javacpp is currently not properly read though this (probably because the llvm/Config/Targets.def file is created during build generation.

Fix

I'm not sure how we want to go about adding these APIs as they should only be available if the target is enabled. With the current build setup, that would be one target, but a different one for each platform we build the binaries for.

  1. Creating a stub file (similar to LLVM full optimization #869) in the resources directory and add it to the preset for ALL targets
    This solution means that the initialization API for every target will be "available" regardless of which target the user's binary has enabled. This is probably not wanted behavior because calling into a function which doesn't actually exist will crash the JVM.

  2. Parse the llvm-c/Target.h file after build generator step, assuming the Javacpp parser is able to perform macro expansion.
    This requires the parser to go over the files after the build has been generated.

I have created an example showing how this could be done if we go with option 1 here

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions