Skip to content

use emit_error in ccall when library-not-found #6184

@timholy

Description

@timholy

It seems there are some bumps in writing code that issues ccalls conditionally on the availability of a C library, see https://groups.google.com/forum/?fromgroups=#!topic/julia-users/O2lBbCaJ99w

The solution worked out there seem likely to be fragile with respect to improvements in inlining. The following seems safe:

const libfrobozz = find_library("libfrobozz")
const have_frobozz = !isempty(libfrobozz)

function somefunction()
    if have_frobozz
        eval(:(ccall((:somefunction, $libfrobozz), rettype, argtypes, args...))
    else
        # do something else
    end
end

But that also seems a bit undesirable. Is there a better way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:codegenGeneration of LLVM IR and native code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions