Skip to content

Commit 2bb26db

Browse files
staticfloatKristofferC
authored andcommitted
Merge pull request #49842 from JuliaLang/sf/dont_eagerly_load_libgomp
Don't depend on `CompilerSupportLibraries_jll` from `OpenBLAS_jll` (cherry picked from commit 98b64b2)
1 parent 2c3e290 commit 2bb26db

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

stdlib/OpenBLAS_jll/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
33
version = "0.3.21+4"
44

55
[deps]
6+
# See note in `src/OpenBLAS_jll.jl` about this dependency.
67
CompilerSupportLibraries_jll = "e66e0078-7015-5450-92f7-15fbd957f2ae"
78
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
89
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

stdlib/OpenBLAS_jll/src/OpenBLAS_jll.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
## dummy stub for https://github.com/JuliaBinaryWrappers/OpenBLAS_jll.jl
44
baremodule OpenBLAS_jll
5-
using Base, Libdl, CompilerSupportLibraries_jll, Base.BinaryPlatforms
5+
using Base, Libdl, Base.BinaryPlatforms
6+
7+
# We are explicitly NOT loading this at runtime, as it contains `libgomp`
8+
# which conflicts with `libiomp5`, breaking things like MKL. In the future,
9+
# we hope to transition to a JLL interface that provides a more granular
10+
# interface than eagerly dlopen'ing all libraries provided in the JLL
11+
# which will eliminate issues like this, where we avoid loading a JLL
12+
# because we don't want to load a library that we don't even use yet.
13+
# using CompilerSupportLibraries_jll
14+
# Because of this however, we have to manually load the libraries we
15+
# _do_ care about, namely libgfortran
616
Base.Experimental.@compiler_options compile=min optimize=0 infer=false
717

818
const PATH_list = String[]
@@ -25,10 +35,13 @@ end
2535

2636
if Sys.iswindows()
2737
const libopenblas = "libopenblas$(libsuffix).dll"
38+
const _libgfortran = string("libgfortran-", libgfortran_version(HostPlatform()).major, ".dll")
2839
elseif Sys.isapple()
2940
const libopenblas = "@rpath/libopenblas$(libsuffix).dylib"
41+
const _libgfortran = string("@rpath/", "libgfortran.", libgfortran_version(HostPlatform()).major, ".dylib")
3042
else
3143
const libopenblas = "libopenblas$(libsuffix).so"
44+
const _libgfortran = string("libgfortran.so.", libgfortran_version(HostPlatform()).major)
3245
end
3346

3447
function __init__()
@@ -50,6 +63,10 @@ function __init__()
5063
ENV["OPENBLAS_DEFAULT_NUM_THREADS"] = "1"
5164
end
5265

66+
# As mentioned above, we are sneaking this in here so that we don't have to
67+
# depend on CSL_jll and load _all_ of its libraries.
68+
dlopen(_libgfortran)
69+
5370
global libopenblas_handle = dlopen(libopenblas)
5471
global libopenblas_path = dlpath(libopenblas_handle)
5572
global artifact_dir = dirname(Sys.BINDIR)

test/precompile.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ precompile_test_harness(false) do dir
383383
Dict(let m = Base.root_module(Base, s)
384384
Base.PkgId(m) => Base.module_build_id(m)
385385
end for s in
386-
[:ArgTools, :Artifacts, :Base64, :CompilerSupportLibraries_jll, :CRC32c, :Dates,
386+
[:ArgTools, :Artifacts, :Base64, :CRC32c, :Dates,
387387
:Distributed, :Downloads, :FileWatching, :Future, :InteractiveUtils, :libblastrampoline_jll,
388388
:LazyArtifacts, :LibCURL, :LibCURL_jll, :LibGit2, :Libdl, :LinearAlgebra,
389389
:Logging, :Markdown, :Mmap, :MozillaCACerts_jll, :NetworkOptions, :OpenBLAS_jll, :Pkg, :Printf,

0 commit comments

Comments
 (0)