From 49039c6f1c2520e00ff414bb760c999f769bc84b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Fri, 11 Dec 2020 19:16:36 +0000 Subject: [PATCH] Allow `dlopen_flags=nothing` to not dlopen libraries --- Project.toml | 2 +- src/products/library_generators.jl | 7 +++++-- test/OpenLibm_jll/src/wrappers/aarch64-linux-gnu.jl | 6 ++++++ test/OpenLibm_jll/src/wrappers/aarch64-linux-musl.jl | 6 ++++++ test/OpenLibm_jll/src/wrappers/armv7l-linux-gnueabihf.jl | 6 ++++++ test/OpenLibm_jll/src/wrappers/armv7l-linux-musleabihf.jl | 6 ++++++ test/OpenLibm_jll/src/wrappers/i686-linux-gnu.jl | 6 ++++++ test/OpenLibm_jll/src/wrappers/i686-linux-musl.jl | 6 ++++++ test/OpenLibm_jll/src/wrappers/i686-w64-mingw32.jl | 6 ++++++ test/OpenLibm_jll/src/wrappers/powerpc64le-linux-gnu.jl | 6 ++++++ test/OpenLibm_jll/src/wrappers/x86_64-apple-darwin.jl | 6 ++++++ test/OpenLibm_jll/src/wrappers/x86_64-linux-gnu.jl | 6 ++++++ test/OpenLibm_jll/src/wrappers/x86_64-linux-musl.jl | 6 ++++++ .../src/wrappers/x86_64-unknown-freebsd11.1.jl | 6 ++++++ test/OpenLibm_jll/src/wrappers/x86_64-w64-mingw32.jl | 6 ++++++ test/runtests.jl | 1 + 16 files changed, 85 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 6d5f5d0..5ddacf1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "JLLWrappers" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" authors = ["Mosè Giordano", "Elliot Saba"] -version = "1.1.4" +version = "1.2.0" [compat] julia = "1.0.0" diff --git a/src/products/library_generators.jl b/src/products/library_generators.jl index ca3eb00..a8da25e 100644 --- a/src/products/library_generators.jl +++ b/src/products/library_generators.jl @@ -58,8 +58,11 @@ macro init_library_product(product_name, product_path, dlopen_flags) global $(path_name) = joinpath(artifact_dir, $(product_path)) # Manually `dlopen()` this right now so that future invocations # of `ccall` with its path/SONAME will find this path immediately. - global $(handle_name) = dlopen($(path_name), $(dlopen_flags)) - push!(LIBPATH_list, joinpath(artifact_dir, $(dirname(product_path)))) + # dlopen_flags === nothing means to not dlopen the library. + if $(dlopen_flags) !== nothing + global $(handle_name) = dlopen($(path_name), $(dlopen_flags)) + push!(LIBPATH_list, joinpath(artifact_dir, $(dirname(product_path)))) + end end, init_new_library_product(product_name), ) diff --git a/test/OpenLibm_jll/src/wrappers/aarch64-linux-gnu.jl b/test/OpenLibm_jll/src/wrappers/aarch64-linux-gnu.jl index b3aab7b..5d9c6dc 100644 --- a/test/OpenLibm_jll/src/wrappers/aarch64-linux-gnu.jl +++ b/test/OpenLibm_jll/src/wrappers/aarch64-linux-gnu.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "libopenlibm.so.3") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.so.0") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "lib/libopenlibm.so", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "lib/libnonexisting.so", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/OpenLibm_jll/src/wrappers/aarch64-linux-musl.jl b/test/OpenLibm_jll/src/wrappers/aarch64-linux-musl.jl index 08f83a4..d7929c3 100644 --- a/test/OpenLibm_jll/src/wrappers/aarch64-linux-musl.jl +++ b/test/OpenLibm_jll/src/wrappers/aarch64-linux-musl.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "libopenlibm.so.3") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.so.0") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "lib/libopenlibm.so", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "lib/libnonexisting.so", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/OpenLibm_jll/src/wrappers/armv7l-linux-gnueabihf.jl b/test/OpenLibm_jll/src/wrappers/armv7l-linux-gnueabihf.jl index 63831a7..4c0c52c 100644 --- a/test/OpenLibm_jll/src/wrappers/armv7l-linux-gnueabihf.jl +++ b/test/OpenLibm_jll/src/wrappers/armv7l-linux-gnueabihf.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "libopenlibm.so.3") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.so.0") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "lib/libopenlibm.so", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "lib/libnonexisting.so", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/OpenLibm_jll/src/wrappers/armv7l-linux-musleabihf.jl b/test/OpenLibm_jll/src/wrappers/armv7l-linux-musleabihf.jl index 74254c9..aaa6528 100644 --- a/test/OpenLibm_jll/src/wrappers/armv7l-linux-musleabihf.jl +++ b/test/OpenLibm_jll/src/wrappers/armv7l-linux-musleabihf.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "libopenlibm.so.3") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.so.0") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "lib/libopenlibm.so", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "lib/libnonexisting.so", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/OpenLibm_jll/src/wrappers/i686-linux-gnu.jl b/test/OpenLibm_jll/src/wrappers/i686-linux-gnu.jl index 208b992..d4ca491 100644 --- a/test/OpenLibm_jll/src/wrappers/i686-linux-gnu.jl +++ b/test/OpenLibm_jll/src/wrappers/i686-linux-gnu.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "libopenlibm.so.3") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.so.0") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "lib/libopenlibm.so", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "lib/libnonexisting.so", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/OpenLibm_jll/src/wrappers/i686-linux-musl.jl b/test/OpenLibm_jll/src/wrappers/i686-linux-musl.jl index 0cc32c0..fa8ee07 100644 --- a/test/OpenLibm_jll/src/wrappers/i686-linux-musl.jl +++ b/test/OpenLibm_jll/src/wrappers/i686-linux-musl.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "libopenlibm.so.3") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.so.0") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "lib/libopenlibm.so", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "lib/libnonexisting.so", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/OpenLibm_jll/src/wrappers/i686-w64-mingw32.jl b/test/OpenLibm_jll/src/wrappers/i686-w64-mingw32.jl index 942d9b2..aff593b 100644 --- a/test/OpenLibm_jll/src/wrappers/i686-w64-mingw32.jl +++ b/test/OpenLibm_jll/src/wrappers/i686-w64-mingw32.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "libopenlibm.dll") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.dll") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "bin/libopenlibm.dll", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "bin/libnonexisting.dll", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/OpenLibm_jll/src/wrappers/powerpc64le-linux-gnu.jl b/test/OpenLibm_jll/src/wrappers/powerpc64le-linux-gnu.jl index 20d6f34..18b8a7a 100644 --- a/test/OpenLibm_jll/src/wrappers/powerpc64le-linux-gnu.jl +++ b/test/OpenLibm_jll/src/wrappers/powerpc64le-linux-gnu.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "libopenlibm.so.3") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.so.0") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "lib/libopenlibm.so", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "lib/libnonexisting.so", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/OpenLibm_jll/src/wrappers/x86_64-apple-darwin.jl b/test/OpenLibm_jll/src/wrappers/x86_64-apple-darwin.jl index 9ca56ab..12d818a 100644 --- a/test/OpenLibm_jll/src/wrappers/x86_64-apple-darwin.jl +++ b/test/OpenLibm_jll/src/wrappers/x86_64-apple-darwin.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "@rpath/libopenlibm.3.dylib") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.0.dylib") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "lib/libopenlibm.3.0.dylib", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "lib/libnonexisting.0.0.dylib", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/OpenLibm_jll/src/wrappers/x86_64-linux-gnu.jl b/test/OpenLibm_jll/src/wrappers/x86_64-linux-gnu.jl index f9f0ccc..53868ef 100644 --- a/test/OpenLibm_jll/src/wrappers/x86_64-linux-gnu.jl +++ b/test/OpenLibm_jll/src/wrappers/x86_64-linux-gnu.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "libopenlibm.so.3") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.so.0") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "lib/libopenlibm.so", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "lib/libnonexisting.so", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/OpenLibm_jll/src/wrappers/x86_64-linux-musl.jl b/test/OpenLibm_jll/src/wrappers/x86_64-linux-musl.jl index 7935d81..237c4d8 100644 --- a/test/OpenLibm_jll/src/wrappers/x86_64-linux-musl.jl +++ b/test/OpenLibm_jll/src/wrappers/x86_64-linux-musl.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "libopenlibm.so.3") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.so.0") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "lib/libopenlibm.so", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "lib/libnonexisting.so", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/OpenLibm_jll/src/wrappers/x86_64-unknown-freebsd11.1.jl b/test/OpenLibm_jll/src/wrappers/x86_64-unknown-freebsd11.1.jl index d3574d8..0abdb5d 100644 --- a/test/OpenLibm_jll/src/wrappers/x86_64-unknown-freebsd11.1.jl +++ b/test/OpenLibm_jll/src/wrappers/x86_64-unknown-freebsd11.1.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "libopenlibm.so.3") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.so.0") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "lib/libopenlibm.so", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "lib/libnonexisting.so", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/OpenLibm_jll/src/wrappers/x86_64-w64-mingw32.jl b/test/OpenLibm_jll/src/wrappers/x86_64-w64-mingw32.jl index 8d7a1bd..c2ecff9 100644 --- a/test/OpenLibm_jll/src/wrappers/x86_64-w64-mingw32.jl +++ b/test/OpenLibm_jll/src/wrappers/x86_64-w64-mingw32.jl @@ -3,6 +3,7 @@ export libopenlibm JLLWrappers.@generate_wrapper_header("OpenLibm") JLLWrappers.@declare_library_product(libopenlibm, "libopenlibm.dll") +JLLWrappers.@declare_library_product(libnonexisting, "libnonexisting.dll") function __init__() JLLWrappers.@generate_init_header() JLLWrappers.@init_library_product( @@ -10,6 +11,11 @@ function __init__() "bin/libopenlibm.dll", RTLD_LAZY | RTLD_DEEPBIND, ) + JLLWrappers.@init_library_product( + libnonexisting, + "bin/libnonexisting.dll", + nothing, + ) JLLWrappers.@generate_init_footer() end # __init__() diff --git a/test/runtests.jl b/test/runtests.jl index a068706..fac1c90 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -41,6 +41,7 @@ module TestJLL end @test isdir(@eval TestJLL OpenLibm_jll.artifact_dir) @test isempty(@eval TestJLL OpenLibm_jll.PATH[]) @test occursin(Sys.BINDIR, @eval TestJLL OpenLibm_jll.LIBPATH[]) + @test C_NULL == @eval TestJLL OpenLibm_jll.libnonexisting_handle # Issue #20 if Sys.iswindows()