Skip to content

Commit 5e80d0f

Browse files
committed
Change with_toolchains() to auto-provide c++ stdlibs
Because our toolchains require a pretty recent `libstdc++` (and `libc++`, in some cases!) we provide these libraries on the `LD_LIBRARY_PATH` automatically with the `with_toolchains()` function.
1 parent ca826c5 commit 5e80d0f

File tree

9 files changed

+62
-68
lines changed

9 files changed

+62
-68
lines changed

BinaryBuilderAuditor.jl/Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ julia = "1.6"
2424
[extras]
2525
BinaryBuilderToolchains = "33566f4c-336c-3150-6d30-4374274e6143"
2626
JLLPrefixes = "afc68a34-7891-4c5a-9da1-1c62935e7b0d"
27+
LazyJLLWrappers = "21706172-204c-4d4f-5420-656854206f44"
2728
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2829
TreeArchival = "216c6a2e-6c61-7669-6863-726165657274"
2930

3031
[targets]
31-
test = ["BinaryBuilderToolchains", "JLLPrefixes", "Test", "TreeArchival"]
32+
test = ["BinaryBuilderToolchains", "JLLPrefixes", "LazyJLLWrappers", "Test", "TreeArchival"]

BinaryBuilderAuditor.jl/test/passes/DynamicLinkageTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,4 @@ for target_platform in (Platform("x86_64", "linux"), Platform("aarch64", "macos"
174174
end
175175
end
176176
end
177-
end
177+
end

BinaryBuilderAuditor.jl/test/runtests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ include("passes/LicenseTests.jl")
66
include("passes/LibrarySONAMETests.jl")
77
include("passes/DynamicLinkageTests.jl")
88

9-
109
@testset "audit!" begin
1110
platform = CrossPlatform(BBHostPlatform() => HostPlatform())
1211
toolchain = CToolchain(platform; use_ccache=false)

BinaryBuilderToolchains.jl/Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ BinaryBuilderPlatformExtensions = "213f2928-4d72-6f46-7461-4c705f634367"
99
BinaryBuilderSources = "316c416d-4527-6863-7465-466137743047"
1010
HistoricalStdlibVersions = "6df8b67a-e8a0-4029-b4b7-ac196fe72102"
1111
JLLPrefixes = "afc68a34-7891-4c5a-9da1-1c62935e7b0d"
12+
LazyJLLWrappers = "21706172-204c-4d4f-5420-656854206f44"
1213
NetworkOptions = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
1314
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1415
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
@@ -27,8 +28,8 @@ Scratch = "1.2"
2728
julia = "1.9"
2829

2930
[extras]
30-
LazyJLLWrappers = "21706172-204c-4d4f-5420-656854206f44"
31+
3132
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3233

3334
[targets]
34-
test = ["LazyJLLWrappers", "Test"]
35+
test = ["Test"]

BinaryBuilderToolchains.jl/src/BinaryBuilderToolchains.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ include("InteractiveUtils.jl")
6262
CToolchain(platform),
6363
HostToolsToolchain(platform)
6464
])
65-
catch
66-
@warn("Failed to precompile support for platform", platform)
65+
catch e
66+
@warn("Failed to precompile support for platform", platform, e)
6767
end
6868
end
6969
end

BinaryBuilderToolchains.jl/src/InteractiveUtils.jl

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Scratch
1+
using Scratch, LazyJLLWrappers
22

33
export with_toolchains, runshell
44

@@ -56,6 +56,51 @@ function path_appending_merge(env, others...; appending_keys::Set{String}=defaul
5656
return env
5757
end
5858

59+
function with_cxx_csls(f::Function, env)
60+
cxx_csl_libs = [
61+
JLLSource(
62+
"libstdcxx_jll",
63+
BBHostPlatform();
64+
uuid=Base.UUID("3ba1ab17-c18f-5d2d-9d5a-db37f286de95"),
65+
repo=Pkg.Types.GitRepo(
66+
rev="main",
67+
source="https://github.com/staticfloat/libstdcxx_jll.jl",
68+
),
69+
),
70+
JLLSource(
71+
"LLVMLibcxx_jll",
72+
BBHostPlatform();
73+
uuid=Base.UUID("899a7460-a157-599b-96c7-ccb58ef9beb5"),
74+
repo=Pkg.Types.GitRepo(
75+
rev="main",
76+
source="https://github.com/staticfloat/LLVMLibcxx_jll.jl",
77+
),
78+
),
79+
JLLSource(
80+
"LLVMLibunwind_jll",
81+
BBHostPlatform();
82+
uuid=Base.UUID("871c935c-5660-55ad-bb68-d1283357316b"),
83+
repo=Pkg.Types.GitRepo(
84+
rev="main",
85+
source="https://github.com/staticfloat/LLVMLibunwind_jll.jl",
86+
),
87+
),
88+
]
89+
mktempdir() do prefix
90+
prepare(cxx_csl_libs)
91+
deploy(cxx_csl_libs, prefix)
92+
libpath = string(
93+
joinpath(prefix, "lib"),
94+
LazyJLLWrappers.pathsep,
95+
joinpath(prefix, triplet(BBHostPlatform()), "lib"),
96+
LazyJLLWrappers.pathsep,
97+
joinpath(prefix, triplet(BBHostPlatform()), "lib64"),
98+
)
99+
env = LazyJLLWrappers.adjust_ENV!(env, "", libpath, false, true)
100+
f(env)
101+
end
102+
end
103+
59104

60105
"""
61106
with_toolchains(f::Function, toolchains::Vector{AbstractToolchain};
@@ -84,9 +129,11 @@ function with_toolchains(f::Function, toolchains::Vector{<:AbstractToolchain};
84129
deploy_dir::Union{Nothing,String} = nothing,
85130
env = ENV,
86131
verbose::Bool = false)
132+
# Collect the sources from the toolchains
133+
srcs = reduce(vcat, toolchain_sources.(toolchains))
134+
87135
# Prepare all sources. We do this in one `prepare()` invocation, as
88136
# there can be efficiency benefits, especially when `deploy()`'ing later.
89-
srcs = reduce(vcat, toolchain_sources.(toolchains))
90137
prepare(srcs; verbose)
91138

92139
function deploy_and_run(prefix)
@@ -98,7 +145,9 @@ function with_toolchains(f::Function, toolchains::Vector{<:AbstractToolchain};
98145
toolchain_env.(toolchains, (prefix,))...,
99146
filter_env_vars(env),
100147
])
101-
f(prefix, env)
148+
with_cxx_csls(env) do env
149+
f(prefix, env)
150+
end
102151
end
103152

104153
# If no `deploy_dir` was given, generate a temporary one that exists only

BinaryBuilderToolchains.jl/test/CToolchainTestJLLs.jl

Lines changed: 0 additions & 50 deletions
This file was deleted.

BinaryBuilderToolchains.jl/test/CToolchainTests.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,8 @@ ENV["TESTSUITE_OUTPUT_DIR"] = mktempdir(;cleanup=false)
3535
@info("CToolchain tests", use_ccache, config...)
3636
with_toolchains([toolchain, htt_toolchain]) do prefix, env
3737
env["CCACHE_DIR"] = ccache_dir
38-
# We build with _all_ of the C++ stdlib choices here, so we need to ensure that
39-
# we have the appropriate libraries on our `LD_LIBRARY_PATH` for testing, so
40-
# that we can properly attempt to run them.
41-
with_cxx_csls(;env) do env
42-
toolchain_tests(prefix, env, platform, "CToolchain";
43-
do_cxxabi_tests=config[:cxx_runtime] == :libstdcxx)
44-
end
38+
toolchain_tests(prefix, env, platform, "CToolchain";
39+
do_cxxabi_tests=config[:cxx_runtime] == :libstdcxx)
4540
end
4641
end
4742
end

BinaryBuilderToolchains.jl/test/runtests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ end
1212
include("common.jl")
1313
include("PkgUtilsTests.jl")
1414
include("WrapperUtilsTests.jl")
15-
include("CToolchainTestJLLs.jl")
1615
include("CToolchainTests.jl")
1716
include("HostToolsToolchainTests.jl")
1817
include("CMakeToolchainTests.jl")

0 commit comments

Comments
 (0)