Skip to content

Commit

Permalink
Merge pull request #49842 from JuliaLang/sf/dont_eagerly_load_libgomp
Browse files Browse the repository at this point in the history
Don't depend on `CompilerSupportLibraries_jll` from `OpenBLAS_jll`
  • Loading branch information
staticfloat authored May 17, 2023
2 parents 3583fae + 34a2436 commit 98b64b2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions stdlib/OpenBLAS_jll/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.23+0"

[deps]
# See note in `src/OpenBLAS_jll.jl` about this dependency.
CompilerSupportLibraries_jll = "e66e0078-7015-5450-92f7-15fbd957f2ae"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
Expand Down
19 changes: 18 additions & 1 deletion stdlib/OpenBLAS_jll/src/OpenBLAS_jll.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

## dummy stub for https://github.com/JuliaBinaryWrappers/OpenBLAS_jll.jl
baremodule OpenBLAS_jll
using Base, Libdl, CompilerSupportLibraries_jll, Base.BinaryPlatforms
using Base, Libdl, Base.BinaryPlatforms

# We are explicitly NOT loading this at runtime, as it contains `libgomp`
# which conflicts with `libiomp5`, breaking things like MKL. In the future,
# we hope to transition to a JLL interface that provides a more granular
# interface than eagerly dlopen'ing all libraries provided in the JLL
# which will eliminate issues like this, where we avoid loading a JLL
# because we don't want to load a library that we don't even use yet.
# using CompilerSupportLibraries_jll
# Because of this however, we have to manually load the libraries we
# _do_ care about, namely libgfortran
Base.Experimental.@compiler_options compile=min optimize=0 infer=false

const PATH_list = String[]
Expand All @@ -25,10 +35,13 @@ end

if Sys.iswindows()
const libopenblas = "libopenblas$(libsuffix).dll"
const _libgfortran = string("libgfortran-", libgfortran_version(HostPlatform()).major, ".dll")
elseif Sys.isapple()
const libopenblas = "@rpath/libopenblas$(libsuffix).dylib"
const _libgfortran = string("@rpath/", "libgfortran.", libgfortran_version(HostPlatform()).major, ".dylib")
else
const libopenblas = "libopenblas$(libsuffix).so"
const _libgfortran = string("libgfortran.so.", libgfortran_version(HostPlatform()).major)
end

function __init__()
Expand All @@ -50,6 +63,10 @@ function __init__()
ENV["OPENBLAS_DEFAULT_NUM_THREADS"] = "1"
end

# As mentioned above, we are sneaking this in here so that we don't have to
# depend on CSL_jll and load _all_ of its libraries.
dlopen(_libgfortran)

global libopenblas_handle = dlopen(libopenblas)
global libopenblas_path = dlpath(libopenblas_handle)
global artifact_dir = dirname(Sys.BINDIR)
Expand Down
2 changes: 1 addition & 1 deletion test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ precompile_test_harness(false) do dir
Dict(let m = Base.root_module(Base, s)
Base.PkgId(m) => Base.module_build_id(m)
end for s in
[:ArgTools, :Artifacts, :Base64, :CompilerSupportLibraries_jll, :CRC32c, :Dates,
[:ArgTools, :Artifacts, :Base64, :CRC32c, :Dates,
:Downloads, :FileWatching, :Future, :InteractiveUtils, :libblastrampoline_jll,
:LibCURL, :LibCURL_jll, :LibGit2, :Libdl, :LinearAlgebra,
:Logging, :Markdown, :Mmap, :MozillaCACerts_jll, :NetworkOptions, :OpenBLAS_jll, :Pkg, :Printf,
Expand Down

0 comments on commit 98b64b2

Please sign in to comment.