diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp index 759c781277e5c..fc30072b2f89a 100644 --- a/src/jitlayers.cpp +++ b/src/jitlayers.cpp @@ -1588,6 +1588,9 @@ struct JuliaOJIT::DLSymOptimizer { assert(++++CI->use_begin() == CI->use_end()); void *addr; if (auto GV = dyn_cast(libarg)) { + // Can happen if the library is the empty string, just give up when that happens + if (isa(GV->getInitializer())) + continue; auto libname = cast(GV->getInitializer())->getAsCString(); addr = lookup(libname.data(), fname.data()); } else { diff --git a/test/ccall.jl b/test/ccall.jl index 7e166ddbd9041..d55ba03799039 100644 --- a/test/ccall.jl +++ b/test/ccall.jl @@ -1915,3 +1915,17 @@ end ctest_total_const() = Val{ctest_total(1 + 2im)}() Core.Compiler.return_type(ctest_total_const, Tuple{}) == Val{2 + 0im} end + +const libfrobozz = "" + +function somefunction_not_found() + ccall((:somefunction, libfrobozz), Cvoid, ()) +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 +end