Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,9 @@ struct JuliaOJIT::DLSymOptimizer {
assert(++++CI->use_begin() == CI->use_end());
void *addr;
if (auto GV = dyn_cast<GlobalVariable>(libarg)) {
// Can happen if the library is the empty string, just give up when that happens
if (isa<ConstantAggregateZero>(GV->getInitializer()))
continue;
auto libname = cast<ConstantDataArray>(GV->getInitializer())->getAsCString();
addr = lookup(libname.data(), fname.data());
} else {
Expand Down
10 changes: 10 additions & 0 deletions test/ccall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1915,3 +1915,13 @@ end
ctest_total_const() = Val{ctest_total(1 + 2im)}()
Core.Compiler.return_type(ctest_total_const, Tuple{}) == Val{2 + 0im}
end

const libfrobozz = Libdl.find_library("libfrobozz")

function somefunction_not_found()
ccall((:somefunction, libfrobozz), Cvoid, ())
end

@testset "library not found" begin
@test_throws "could not load library \"\"" somefunction_not_found()
end