Skip to content

Commit 276fbff

Browse files
IanButterworthnilesh646
authored andcommitted
Fix and test stdlib JLL deps on Windows (JuliaLang#58560)
1 parent c543ea8 commit 276fbff

File tree

29 files changed

+948
-566
lines changed

29 files changed

+948
-566
lines changed

base/binaryplatforms.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,17 @@ function platform_dlext(p::AbstractPlatform = HostPlatform())
796796
end
797797
end
798798

799+
# Not general purpose, just for parse_dl_name_version
800+
function _this_os_name()
801+
if Sys.iswindows()
802+
return "windows"
803+
elseif Sys.isapple()
804+
return "macos"
805+
else
806+
return "other"
807+
end
808+
end
809+
799810
"""
800811
parse_dl_name_version(path::String, platform::AbstractPlatform)
801812
@@ -806,9 +817,10 @@ valid dynamic library, this method throws an error. If no soversion
806817
can be extracted from the filename, as in "libbar.so" this method
807818
returns `"libbar", nothing`.
808819
"""
809-
function parse_dl_name_version(path::String, os::String)
820+
function parse_dl_name_version(path::String, os::String=_this_os_name())
810821
# Use an extraction regex that matches the given OS
811822
local dlregex
823+
# Keep this up to date with _this_os_name
812824
if os == "windows"
813825
# On Windows, libraries look like `libnettle-6.dll`
814826
dlregex = r"^(.*?)(?:-((?:[\.\d]+)*))?\.dll$"sa
@@ -837,7 +849,7 @@ function parse_dl_name_version(path::String, os::String)
837849
end
838850

839851
# Adapter for `AbstractString`
840-
function parse_dl_name_version(path::AbstractString, os::AbstractString)
852+
function parse_dl_name_version(path::AbstractString, os::AbstractString=_this_os_name())
841853
return parse_dl_name_version(string(path)::String, string(os)::String)
842854
end
843855

stdlib/CompilerSupportLibraries_jll/src/CompilerSupportLibraries_jll.jl

Lines changed: 116 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -13,75 +13,123 @@ const PATH_list = String[]
1313
const LIBPATH = Ref("")
1414
const LIBPATH_list = String[]
1515
artifact_dir::String = ""
16-
libgcc_s_path::String = ""
17-
libgfortran_path::String = ""
18-
libstdcxx_path::String = ""
19-
libgomp_path::String = ""
2016

21-
if Sys.iswindows()
22-
const _libatomic_path = BundledLazyLibraryPath("libatomic-1.dll")
23-
const _libquadmath_path = BundledLazyLibraryPath("libquadmath-0.dll")
24-
if arch(HostPlatform()) == "x86_64"
25-
const _libgcc_s_path = BundledLazyLibraryPath("libgcc_s_seh-1.dll")
26-
else
27-
const _libgcc_s_path = BundledLazyLibraryPath("libgcc_s_sjlj-1.dll")
28-
end
29-
const _libgfortran_path = BundledLazyLibraryPath(string("libgfortran-", libgfortran_version(HostPlatform()).major, ".dll"))
30-
const _libstdcxx_path = BundledLazyLibraryPath("libstdc++-6.dll")
31-
const _libgomp_path = BundledLazyLibraryPath("libgomp-1.dll")
32-
const _libssp_path = BundledLazyLibraryPath("libssp-0.dll")
33-
elseif Sys.isapple()
34-
const _libatomic_path = BundledLazyLibraryPath("libatomic.1.dylib")
35-
const _libquadmath_path = BundledLazyLibraryPath("libquadmath.0.dylib")
36-
if arch(HostPlatform()) == "aarch64" || libgfortran_version(HostPlatform()) == v"5"
37-
const _libgcc_s_path = BundledLazyLibraryPath("libgcc_s.1.1.dylib")
38-
else
39-
const _libgcc_s_path = BundledLazyLibraryPath("libgcc_s.1.dylib")
40-
end
41-
const _libgfortran_path = BundledLazyLibraryPath(string("libgfortran.", libgfortran_version(HostPlatform()).major, ".dylib"))
42-
const _libstdcxx_path = BundledLazyLibraryPath("libstdc++.6.dylib")
43-
const _libgomp_path = BundledLazyLibraryPath("libgomp.1.dylib")
44-
const _libssp_path = BundledLazyLibraryPath("libssp.0.dylib")
45-
else
46-
if Sys.isfreebsd()
47-
const _libatomic_path = BundledLazyLibraryPath("libatomic.so.3")
17+
libatomic_path::String = ""
18+
const libatomic = LazyLibrary(
19+
if Sys.iswindows()
20+
BundledLazyLibraryPath("libatomic-1.dll")
21+
elseif Sys.isapple()
22+
BundledLazyLibraryPath("libatomic.1.dylib")
23+
elseif Sys.isfreebsd()
24+
BundledLazyLibraryPath("libatomic.so.3")
25+
elseif Sys.islinux()
26+
BundledLazyLibraryPath("libatomic.so.1")
4827
else
49-
const _libatomic_path = BundledLazyLibraryPath("libatomic.so.1")
50-
end
51-
const _libgcc_s_path = BundledLazyLibraryPath("libgcc_s.so.1")
52-
const _libgfortran_path = BundledLazyLibraryPath(string("libgfortran.so.", libgfortran_version(HostPlatform()).major))
53-
const _libstdcxx_path = BundledLazyLibraryPath("libstdc++.so.6")
54-
const _libgomp_path = BundledLazyLibraryPath("libgomp.so.1")
55-
if libc(HostPlatform()) != "musl"
56-
const _libssp_path = BundledLazyLibraryPath("libssp.so.0")
28+
error("CompilerSupportLibraries_jll: Library 'libatomic' is not available for $(Sys.KERNEL)")
5729
end
58-
if arch(HostPlatform()) ("x86_64", "i686")
59-
const _libquadmath_path = BundledLazyLibraryPath("libquadmath.so.0")
60-
end
61-
end
30+
)
6231

63-
if @isdefined(_libatomic_path)
64-
const libatomic = LazyLibrary(_libatomic_path)
32+
if Sys.iswindows() || Sys.isapple() || arch(HostPlatform()) ("x86_64", "i686")
33+
global libquadmath_path::String = ""
34+
const libquadmath = LazyLibrary(
35+
if Sys.iswindows()
36+
BundledLazyLibraryPath("libquadmath-0.dll")
37+
elseif Sys.isapple()
38+
BundledLazyLibraryPath("libquadmath.0.dylib")
39+
elseif (Sys.islinux() || Sys.isfreebsd()) && arch(HostPlatform()) ("x86_64", "i686")
40+
BundledLazyLibraryPath("libquadmath.so.0")
41+
else
42+
error("CompilerSupportLibraries_jll: Library 'libquadmath' is not available for $(Sys.KERNEL)")
43+
end
44+
)
6545
end
66-
const libgcc_s = LazyLibrary(_libgcc_s_path)
6746

68-
_libgfortran_deps = [libgcc_s]
69-
if @isdefined _libquadmath_path
70-
const libquadmath = LazyLibrary(_libquadmath_path)
71-
push!(_libgfortran_deps, libquadmath)
72-
end
47+
libgcc_s_path::String = ""
48+
const libgcc_s = LazyLibrary(
49+
if Sys.iswindows()
50+
if arch(HostPlatform()) == "x86_64"
51+
BundledLazyLibraryPath("libgcc_s_seh-1.dll")
52+
else
53+
BundledLazyLibraryPath("libgcc_s_sjlj-1.dll")
54+
end
55+
elseif Sys.isapple()
56+
if arch(HostPlatform()) == "aarch64" || libgfortran_version(HostPlatform()) == v"5"
57+
BundledLazyLibraryPath("libgcc_s.1.1.dylib")
58+
else
59+
BundledLazyLibraryPath("libgcc_s.1.dylib")
60+
end
61+
elseif Sys.islinux() || Sys.isfreebsd()
62+
BundledLazyLibraryPath("libgcc_s.so.1")
63+
else
64+
error("CompilerSupportLibraries_jll: Library 'libgcc_s' is not available for $(Sys.KERNEL)")
65+
end
66+
)
7367

74-
const libgfortran = LazyLibrary(_libgfortran_path, dependencies=_libgfortran_deps)
68+
libgfortran_path::String = ""
69+
const libgfortran = LazyLibrary(
70+
if Sys.iswindows()
71+
BundledLazyLibraryPath(string("libgfortran-", libgfortran_version(HostPlatform()).major, ".dll"))
72+
elseif Sys.isapple()
73+
BundledLazyLibraryPath(string("libgfortran.", libgfortran_version(HostPlatform()).major, ".dylib"))
74+
elseif Sys.islinux() || Sys.isfreebsd()
75+
BundledLazyLibraryPath(string("libgfortran.so.", libgfortran_version(HostPlatform()).major))
76+
else
77+
error("CompilerSupportLibraries_jll: Library 'libgfortran' is not available for $(Sys.KERNEL)")
78+
end;
79+
dependencies = @static if @isdefined(libquadmath)
80+
LazyLibrary[libgcc_s, libquadmath]
81+
else
82+
LazyLibrary[libgcc_s]
83+
end
84+
)
7585

76-
_libstdcxx_dependencies = LazyLibrary[libgcc_s]
77-
const libstdcxx = LazyLibrary(_libstdcxx_path, dependencies=_libstdcxx_dependencies)
86+
libstdcxx_path::String = ""
87+
const libstdcxx = LazyLibrary(
88+
if Sys.iswindows()
89+
BundledLazyLibraryPath("libstdc++-6.dll")
90+
elseif Sys.isapple()
91+
BundledLazyLibraryPath("libstdc++.6.dylib")
92+
elseif Sys.islinux() || Sys.isfreebsd()
93+
BundledLazyLibraryPath("libstdc++.so.6")
94+
else
95+
error("CompilerSupportLibraries_jll: Library 'libstdcxx' is not available for $(Sys.KERNEL)")
96+
end;
97+
dependencies = LazyLibrary[libgcc_s]
98+
)
7899

79-
const libgomp = LazyLibrary(_libgomp_path)
100+
libgomp_path::String = ""
101+
const libgomp = LazyLibrary(
102+
if Sys.iswindows()
103+
BundledLazyLibraryPath("libgomp-1.dll")
104+
elseif Sys.isapple()
105+
BundledLazyLibraryPath("libgomp.1.dylib")
106+
elseif Sys.islinux() || Sys.isfreebsd()
107+
BundledLazyLibraryPath("libgomp.so.1")
108+
else
109+
error("CompilerSupportLibraries_jll: Library 'libgomp' is not available for $(Sys.KERNEL)")
110+
end;
111+
dependencies = if Sys.iswindows()
112+
LazyLibrary[libgcc_s]
113+
else
114+
LazyLibrary[]
115+
end
116+
)
80117

81-
# Some installations (such as those from-source) may not have `libssp`
82-
# So let's do a compile-time check to see if we've got it.
83-
if @isdefined(_libssp_path) && isfile(string(_libssp_path))
84-
const libssp = LazyLibrary(_libssp_path)
118+
# only define if isfile
119+
let
120+
if Sys.iswindows() || Sys.isapple() || libc(HostPlatform()) != "musl"
121+
_libssp_path = if Sys.iswindows()
122+
BundledLazyLibraryPath("libssp-0.dll")
123+
elseif Sys.isapple()
124+
BundledLazyLibraryPath("libssp.0.dylib")
125+
elseif Sys.islinux() && libc(HostPlatform()) != "musl"
126+
BundledLazyLibraryPath("libssp.so.0")
127+
end
128+
if isfile(string(_libssp_path))
129+
global libssp_path::String = ""
130+
@eval const libssp = LazyLibrary($(_libssp_path))
131+
end
132+
end
85133
end
86134

87135
# Conform to LazyJLLWrappers API
@@ -103,19 +151,17 @@ end
103151
is_available() = true
104152

105153
function __init__()
106-
if @isdefined _libatomic_path
107-
global libatomic_path = string(_libatomic_path)
108-
end
109-
global libgcc_s_path = string(_libgcc_s_path)
110-
global libgomp_path = string(_libgomp_path)
111-
if @isdefined _libquadmath_path
112-
global libquadmath_path = string(_libquadmath_path)
154+
global libatomic_path = string(libatomic.path)
155+
global libgcc_s_path = string(libgcc_s.path)
156+
global libgomp_path = string(libgomp.path)
157+
if @isdefined libquadmath_path
158+
global libquadmath_path = string(libquadmath.path)
113159
end
114-
if @isdefined _libssp_path
115-
global libssp_path = string(_libssp_path)
160+
if @isdefined libssp_path
161+
global libssp_path = string(libssp.path)
116162
end
117-
global libgfortran_path = string(_libgfortran_path)
118-
global libstdcxx_path = string(_libstdcxx_path)
163+
global libgfortran_path = string(libgfortran.path)
164+
global libstdcxx_path = string(libstdcxx.path)
119165
global artifact_dir = dirname(Sys.BINDIR)
120166
LIBPATH[] = dirname(libgcc_s_path)
121167
push!(LIBPATH_list, LIBPATH[])

stdlib/GMP_jll/src/GMP_jll.jl

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
## dummy stub for https://github.com/JuliaBinaryWrappers/GMP_jll.jl
44
baremodule GMP_jll
5-
using Base, Libdl, CompilerSupportLibraries_jll
5+
using Base, Libdl
6+
if !Sys.isapple()
7+
using CompilerSupportLibraries_jll
8+
end
69

710
export libgmp, libgmpxx
811

@@ -12,44 +15,48 @@ const PATH_list = String[]
1215
const LIBPATH = Ref("")
1316
const LIBPATH_list = String[]
1417
artifact_dir::String = ""
15-
libgmp_path::String = ""
16-
libgmpxx_path::String = ""
17-
18-
if Sys.iswindows()
19-
const _libgmp_path = BundledLazyLibraryPath("libgmp-10.dll")
20-
const _libgmpxx_path = BundledLazyLibraryPath("libgmpxx-4.dll")
21-
elseif Sys.isapple()
22-
const _libgmp_path = BundledLazyLibraryPath("libgmp.10.dylib")
23-
const _libgmpxx_path = BundledLazyLibraryPath("libgmpxx.4.dylib")
24-
else
25-
const _libgmp_path = BundledLazyLibraryPath("libgmp.so.10")
26-
const _libgmpxx_path = BundledLazyLibraryPath("libgmpxx.so.4")
27-
end
2818

29-
const libgmp = LazyLibrary(_libgmp_path)
19+
libgmp_path::String = ""
20+
const libgmp = LazyLibrary(
21+
if Sys.iswindows()
22+
BundledLazyLibraryPath("libgmp-10.dll")
23+
elseif Sys.isapple()
24+
BundledLazyLibraryPath("libgmp.10.dylib")
25+
else
26+
BundledLazyLibraryPath("libgmp.so.10")
27+
end
28+
)
3029

31-
if Sys.isfreebsd()
32-
_libgmpxx_dependencies = LazyLibrary[libgmp, libgcc_s]
33-
elseif Sys.isapple()
34-
_libgmpxx_dependencies = LazyLibrary[libgmp]
35-
else
36-
_libgmpxx_dependencies = LazyLibrary[libgmp, libstdcxx, libgcc_s]
37-
end
30+
libgmpxx_path::String = ""
3831
const libgmpxx = LazyLibrary(
39-
_libgmpxx_path,
40-
dependencies=_libgmpxx_dependencies,
32+
if Sys.iswindows()
33+
BundledLazyLibraryPath("libgmpxx-4.dll")
34+
elseif Sys.isapple()
35+
BundledLazyLibraryPath("libgmpxx.4.dylib")
36+
else
37+
BundledLazyLibraryPath("libgmpxx.so.4")
38+
end,
39+
dependencies = if Sys.isfreebsd()
40+
LazyLibrary[libgmp, libgcc_s]
41+
elseif Sys.isapple()
42+
LazyLibrary[libgmp]
43+
else
44+
LazyLibrary[libgmp, libstdcxx, libgcc_s]
45+
end
4146
)
4247

4348
function eager_mode()
44-
CompilerSupportLibraries_jll.eager_mode()
49+
@static if @isdefined CompilerSupportLibraries_jll
50+
CompilerSupportLibraries_jll.eager_mode()
51+
end
4552
dlopen(libgmp)
4653
dlopen(libgmpxx)
4754
end
4855
is_available() = true
4956

5057
function __init__()
51-
global libgmp_path = string(_libgmp_path)
52-
global libgmpxx_path = string(_libgmpxx_path)
58+
global libgmp_path = string(libgmp.path)
59+
global libgmpxx_path = string(libgmpxx.path)
5360
global artifact_dir = dirname(Sys.BINDIR)
5461
LIBPATH[] = dirname(libgmp_path)
5562
push!(LIBPATH_list, LIBPATH[])

stdlib/LLVMLibUnwind_jll/src/LLVMLibUnwind_jll.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ const PATH_list = String[]
1313
const LIBPATH = Ref("")
1414
const LIBPATH_list = String[]
1515
artifact_dir::String = ""
16+
1617
llvmlibunwind_path::String = ""
18+
const llvmlibunwind = LazyLibrary(BundledLazyLibraryPath("libunwind"))
1719

18-
const _llvmlibunwind_path = BundledLazyLibraryPath("libunwind")
19-
const llvmlibunwind = LazyLibrary(_llvmlibunwind_path)
2020
function eager_mode()
2121
dlopen(llvmlibunwind)
2222
end
2323
is_available() = @static Sys.isapple() ? true : false
2424

2525
function __init__()
26-
global llvmlibunwind_path = string(_llvmlibunwind_path)
26+
global llvmlibunwind_path = string(llvmlibunwind.path)
2727
global artifact_dir = dirname(Sys.BINDIR)
2828
LIBPATH[] = dirname(llvmlibunwind_path)
2929
push!(LIBPATH_list, LIBPATH[])

stdlib/LibCURL_jll/Project.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
33
version = "8.12.1+1"
44

55
[deps]
6+
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
7+
CompilerSupportLibraries_jll = "e66e0078-7015-5450-92f7-15fbd957f2ae"
68
LibSSH2_jll = "29816b5a-b9ab-546f-933c-edad1886dfa8"
7-
nghttp2_jll = "8e850ede-7688-5339-a07c-302acd2aaf8d"
9+
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
810
OpenSSL_jll = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
911
Zlib_jll = "83775a58-1f1d-513f-b197-d71354ab007a"
10-
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
11-
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
12+
nghttp2_jll = "8e850ede-7688-5339-a07c-302acd2aaf8d"
1213

1314
[extras]
1415
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
@@ -17,4 +18,5 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1718
test = ["Test"]
1819

1920
[compat]
21+
CompilerSupportLibraries_jll = "1.3.0"
2022
julia = "1.11"

0 commit comments

Comments
 (0)