Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -1594,6 +1594,9 @@ struct JuliaOJIT::DLSymOptimizer {
auto libname = cast<ConstantDataArray>(GV->getInitializer())->getAsCString();
addr = lookup(libname.data(), fname.data());
} else {
// Can happen if we fail the compile time dlfind i.e when we try a symbol that doesn't exist in libc
if (dyn_cast<ConstantPointerNull>(libarg))
continue;
assert(cast<ConstantExpr>(libarg)->getOpcode() == Instruction::IntToPtr && "libarg should be either a global variable or a integer index!");
libarg = cast<ConstantExpr>(libarg)->getOperand(0);
auto libidx = cast<ConstantInt>(libarg)->getZExtValue();
Expand Down
5 changes: 5 additions & 0 deletions test/ccall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1922,10 +1922,15 @@ function somefunction_not_found()
ccall((:somefunction, libfrobozz), Cvoid, ())
end

function somefunction_not_found_libc()
ccall(:test,Int,())
end

@testset "library not found" begin
if Sys.islinux()
@test_throws "could not load symbol \"somefunction\"" somefunction_not_found()
else
@test_throws "could not load library \"\"" somefunction_not_found()
end
@test_throws "could not load symbol \"test\"" somefunction_not_found_libc()
end