Skip to content

Commit 7fadf62

Browse files
Change BundledLazyLibraryPath() to be relative to private_shlibdir
This makes more sense, reduces work, and avoids that perennial thorn in my side, that in-tree builds store libraries in `${prefix}/lib`, whereas installed builds store libraries in `${prefix}/lib/julia`. Co-authored-by: Cody Tapscott <[email protected]>
1 parent 198a3f9 commit 7fadf62

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

base/libdl.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,12 @@ Base.cconvert(::Type{Cstring}, llp::LazyLibraryPath) = Base.cconvert(Cstring, st
338338
# Define `print` so that we can wrap this in a `LazyString`
339339
Base.print(io::IO, llp::LazyLibraryPath) = print(io, string(llp))
340340

341-
# Helper to get `Sys.BINDIR` at runtime
342-
struct SysBindirGetter; end
343-
Base.string(::SysBindirGetter) = dirname(Sys.BINDIR)
341+
# Helper to get `$(private_shlibdir)` at runtime
342+
struct PrivateShlibdirGetter; end
343+
const private_shlibdir = Base.OncePerProcess{String}() do
344+
dirname(dlpath("libjulia-internal"))
345+
end
346+
@inline Base.string(::PrivateShlibdirGetter) = private_shlibdir()
344347

345348
"""
346349
BundledLazyLibraryPath
@@ -349,10 +352,10 @@ Helper type for lazily constructed library paths that are stored within the
349352
bundled Julia distribution, primarily for use by Base modules.
350353
351354
```
352-
libfoo = LazyLibrary(BundledLazyLibraryPath("lib/libfoo.so.1.2.3"))
355+
libfoo = LazyLibrary(BundledLazyLibraryPath("libfoo.so.1.2.3"))
353356
```
354357
"""
355-
BundledLazyLibraryPath(subpath) = LazyLibraryPath(SysBindirGetter(), subpath)
358+
BundledLazyLibraryPath(subpath) = LazyLibraryPath(PrivateShlibdirGetter(), subpath)
356359

357360

358361
"""

stdlib/CompilerSupportLibraries_jll/src/CompilerSupportLibraries_jll.jl

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,42 @@ libstdcxx_path::String = ""
1717
libgomp_path::String = ""
1818

1919
if Sys.iswindows()
20-
const _libatomic_path = BundledLazyLibraryPath("bin\\libatomic-1.dll")
21-
const _libquadmath_path = BundledLazyLibraryPath("bin\\libquadmath-0.dll")
20+
const _libatomic_path = BundledLazyLibraryPath("libatomic-1.dll")
21+
const _libquadmath_path = BundledLazyLibraryPath("libquadmath-0.dll")
2222
if arch(HostPlatform()) == "x86_64"
23-
const _libgcc_s_path = BundledLazyLibraryPath("bin\\libgcc_s_seh-1.dll")
23+
const _libgcc_s_path = BundledLazyLibraryPath("libgcc_s_seh-1.dll")
2424
else
25-
const _libgcc_s_path = BundledLazyLibraryPath("bin\\libgcc_s_sjlj-1.dll")
25+
const _libgcc_s_path = BundledLazyLibraryPath("libgcc_s_sjlj-1.dll")
2626
end
27-
const _libgfortran_path = BundledLazyLibraryPath(string("bin\\libgfortran-", libgfortran_version(HostPlatform()).major, ".dll"))
28-
const _libstdcxx_path = BundledLazyLibraryPath("bin\\libstdc++-6.dll")
29-
const _libgomp_path = BundledLazyLibraryPath("bin\\libgomp-1.dll")
30-
const _libssp_path = BundledLazyLibraryPath("bin\\libssp-0.dll")
27+
const _libgfortran_path = BundledLazyLibraryPath(string("libgfortran-", libgfortran_version(HostPlatform()).major, ".dll"))
28+
const _libstdcxx_path = BundledLazyLibraryPath("libstdc++-6.dll")
29+
const _libgomp_path = BundledLazyLibraryPath("libgomp-1.dll")
30+
const _libssp_path = BundledLazyLibraryPath("libssp-0.dll")
3131
elseif Sys.isapple()
32-
const _libatomic_path = BundledLazyLibraryPath("lib/libatomic.1.dylib")
33-
const _libquadmath_path = BundledLazyLibraryPath("lib/libquadmath.0.dylib")
32+
const _libatomic_path = BundledLazyLibraryPath("libatomic.1.dylib")
33+
const _libquadmath_path = BundledLazyLibraryPath("libquadmath.0.dylib")
3434
if arch(HostPlatform()) == "aarch64" || libgfortran_version(HostPlatform()) == v"5"
35-
const _libgcc_s_path = BundledLazyLibraryPath("lib/libgcc_s.1.1.dylib")
35+
const _libgcc_s_path = BundledLazyLibraryPath("libgcc_s.1.1.dylib")
3636
else
37-
const _libgcc_s_path = BundledLazyLibraryPath("lib/libgcc_s.1.dylib")
37+
const _libgcc_s_path = BundledLazyLibraryPath("libgcc_s.1.dylib")
3838
end
39-
const _libgfortran_path = BundledLazyLibraryPath(string("lib/libgfortran.", libgfortran_version(HostPlatform()).major, ".dylib"))
40-
const _libstdcxx_path = BundledLazyLibraryPath("lib/libstdc++.6.dylib")
41-
const _libgomp_path = BundledLazyLibraryPath("lib/libgomp.1.dylib")
42-
const _libssp_path = BundledLazyLibraryPath("lib/libssp.0.dylib")
39+
const _libgfortran_path = BundledLazyLibraryPath(string("libgfortran.", libgfortran_version(HostPlatform()).major, ".dylib"))
40+
const _libstdcxx_path = BundledLazyLibraryPath("libstdc++.6.dylib")
41+
const _libgomp_path = BundledLazyLibraryPath("libgomp.1.dylib")
42+
const _libssp_path = BundledLazyLibraryPath("libssp.0.dylib")
4343
else
44-
if !Sys.isfreebsd()
45-
const _libatomic_path = BundledLazyLibraryPath("lib/libatomic.so.1")
44+
if !Sys.isfreebsd()
45+
const _libatomic_path = BundledLazyLibraryPath("libatomic.so.1")
4646
end
47-
const _libgcc_s_path = BundledLazyLibraryPath("lib/libgcc_s.so.1")
48-
const _libgfortran_path = BundledLazyLibraryPath(string("lib/libgfortran.so.", libgfortran_version(HostPlatform()).major))
49-
const _libstdcxx_path = BundledLazyLibraryPath("lib/libstdc++.so.6")
50-
const _libgomp_path = BundledLazyLibraryPath("lib/libgomp.so.1")
47+
const _libgcc_s_path = BundledLazyLibraryPath("libgcc_s.so.1")
48+
const _libgfortran_path = BundledLazyLibraryPath(string("libgfortran.so.", libgfortran_version(HostPlatform()).major))
49+
const _libstdcxx_path = BundledLazyLibraryPath("libstdc++.so.6")
50+
const _libgomp_path = BundledLazyLibraryPath("libgomp.so.1")
5151
if libc(HostPlatform()) != "musl"
52-
const _libssp_path = BundledLazyLibraryPath("lib/libssp.so.0")
52+
const _libssp_path = BundledLazyLibraryPath("libssp.so.0")
5353
end
5454
if arch(HostPlatform()) ("x86_64", "i686")
55-
const _libquadmath_path = BundledLazyLibraryPath("lib/libquadmath.so.0")
55+
const _libquadmath_path = BundledLazyLibraryPath("libquadmath.so.0")
5656
end
5757
end
5858

stdlib/OpenBLAS_jll/src/OpenBLAS_jll.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ else
2323
end
2424

2525
if Sys.iswindows()
26-
const _libopenblas_path = BundledLazyLibraryPath(string("bin\\libopenblas", libsuffix, ".dll"))
26+
const _libopenblas_path = BundledLazyLibraryPath(string("libopenblas", libsuffix, ".dll"))
2727
elseif Sys.isapple()
28-
const _libopenblas_path = BundledLazyLibraryPath(string("lib/libopenblas", libsuffix, ".dylib"))
28+
const _libopenblas_path = BundledLazyLibraryPath(string("libopenblas", libsuffix, ".dylib"))
2929
else
30-
const _libopenblas_path = BundledLazyLibraryPath(string("lib/libopenblas", libsuffix, ".so"))
30+
const _libopenblas_path = BundledLazyLibraryPath(string("libopenblas", libsuffix, ".so"))
3131
end
3232
const libopenblas = LazyLibrary(_libopenblas_path, dependencies=[libgfortran])
3333

stdlib/libblastrampoline_jll/src/libblastrampoline_jll.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ end
3333

3434
# NOTE: keep in sync with `Base.libblas_name` and `Base.liblapack_name`.
3535
const _libblastrampoline_path = if Sys.iswindows()
36-
BundledLazyLibraryPath("bin\\libblastrampoline-5.dll")
36+
BundledLazyLibraryPath("libblastrampoline-5.dll")
3737
elseif Sys.isapple()
38-
BundledLazyLibraryPath("lib/libblastrampoline.5.dylib")
38+
BundledLazyLibraryPath("libblastrampoline.5.dylib")
3939
else
40-
BundledLazyLibraryPath("lib/libblastrampoline.so.5")
40+
BundledLazyLibraryPath("libblastrampoline.so.5")
4141
end
4242
const libblastrampoline = LazyLibrary(_libblastrampoline_path, dependencies=[],
4343
on_load_callback=libblastrampoline_on_load_callback)

0 commit comments

Comments
 (0)