Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve relocatability of sysimages with BBBase #214

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[JLLWrappers]]
git-tree-sha1 = "a431f5f2ca3f4feef3bd7a5e94b8b8d4f2f647a0"
deps = ["Preferences"]
git-tree-sha1 = "22df5b96feef82434b07327e2d3c770a9b21e023"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.2.0"
version = "1.4.0"

[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4"
git-tree-sha1 = "8076680b162ada2a031f707ac7b4953e30667a37"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.1"
version = "0.21.2"

[[LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
Expand Down Expand Up @@ -82,20 +83,26 @@ uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"

[[OutputCollectors]]
git-tree-sha1 = "d86c19b7fa8ad6a4dc8ec2c726642cc6291b2941"
git-tree-sha1 = "5d3f2b3b2e2a9d7d6f1774c78e94530ac7f360cc"
uuid = "6c11c7d4-943b-4e2b-80de-f2cfc2930a8c"
version = "0.1.0"
version = "0.1.1"

[[Parsers]]
deps = ["Dates"]
git-tree-sha1 = "50c9a9ed8c714945e01cd53a21007ed3865ed714"
git-tree-sha1 = "0b5cfbb704034b5b4c1869e36634438a047df065"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "1.0.15"
version = "2.2.1"

[[Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[Preferences]]
deps = ["TOML"]
git-tree-sha1 = "2cf929d64681236a2e074ffafb8d568733d2e6af"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.2.3"

[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand All @@ -108,14 +115,20 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
deps = ["SHA", "Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[RelocatableFolders]]
deps = ["SHA", "Scratch"]
git-tree-sha1 = "cdbd3b1338c72ce29d9584fdbe9e9b70eeb5adca"
uuid = "05181044-ff0b-4ac5-8273-598c1e38db00"
version = "0.1.3"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[Scratch]]
deps = ["Dates"]
git-tree-sha1 = "ad4b278adb62d185bbcb6864dc24959ab0627bf6"
git-tree-sha1 = "0b4b7f1393cff97c33891da2a0bf69c6ed241fda"
uuid = "6c6a2e73-6563-6170-7368-637461726353"
version = "1.0.3"
version = "1.1.0"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Expand All @@ -142,9 +155,9 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[TranscodingStreams]]
deps = ["Random", "Test"]
git-tree-sha1 = "7c53c35547de1c5b9d46a4797cf6d8253807108c"
git-tree-sha1 = "216b95ea110b5972db65aa90f88d8d89dcb8851c"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.9.5"
version = "0.9.6"

[[UUIDs]]
deps = ["Random", "SHA"]
Expand Down
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BinaryBuilderBase"
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
authors = ["Elliot Saba <staticfloat@gmail.com>"]
version = "1.4.0"
version = "1.4.1"

[deps]
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
Expand All @@ -15,6 +15,7 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
OutputCollectors = "6c11c7d4-943b-4e2b-80de-f2cfc2930a8c"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RelocatableFolders = "05181044-ff0b-4ac5-8273-598c1e38db00"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
SimpleBufferStream = "777ac1f9-54b0-4bf8-805c-2214025038e7"
Expand Down
23 changes: 20 additions & 3 deletions src/BinaryBuilderBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module BinaryBuilderBase
using Pkg, Pkg.Artifacts, Random, Libdl, InteractiveUtils
using Base.BinaryPlatforms
using Downloads
using JSON, OutputCollectors, Scratch
using JSON, OutputCollectors, Scratch, RelocatableFolders

# Re-export useful stuff from Base.BinaryPlatforms:
export HostPlatform, platform_dlext, valid_dl_path, arch, libc,
Expand Down Expand Up @@ -70,9 +70,21 @@ const allow_ecryptfs = Ref(false)
const use_ccache = Ref(false)
const bootstrap_list = Symbol[]

const _artifacts_toml = @path Pkg.Artifacts.find_artifacts_toml(@__FILE__)

function get_bbb_version(dir=@__DIR__, uuid="7f725544-6523-48cd-82d1-3fa08ff4056e")
# Get BinaryBuilder.jl's version and git sha
version = Pkg.TOML.parsefile(joinpath(dir, "..", "Project.toml"))["version"]
version = isdir(dir) ? Pkg.TOML.parsefile(joinpath(dir, "..", "Project.toml"))["version"] :
Pkg.activate(".") do
pkgname = basename(dirname(dirname(dir)))
Pkg.Types.EnvCache().project.name == pkgname ?
Pkg.Types.EnvCache().project.version :
try
Pkg.TOML.parsefile(normpath(Base.find_package(pkgname), "..", "..", "Project.toml"))["version"]
catch e
@info "Couldn't find $pkgname in the current environment"
end
end
try
# get the gitsha if we can
repo = LibGit2.GitRepo(dirname(@__DIR__))
Expand Down Expand Up @@ -170,9 +182,14 @@ function __init__()
global runner_override, use_squashfs, allow_ecryptfs
global use_ccache, storage_cache

deps_path = joinpath(@__DIR__, "..", "deps")
ispath(deps_path) || begin
deps_path = joinpath(Pkg.depots1(), "binary_builder_deps")
@info "Creating a storage cache at $deps_path"
end
# Allow the user to override the default value for `storage_dir`
storage_cache[] = get(ENV, "BINARYBUILDER_STORAGE_DIR",
abspath(joinpath(@__DIR__, "..", "deps")))
abspath(deps_path))

# If the user has signalled that they really want us to automatically
# accept apple EULAs, do that.
Expand Down
2 changes: 1 addition & 1 deletion src/DockerRunner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end
docker_image(version::VersionNumber) = "julia_binarybuilder_rootfs:v$(version)"
function docker_image(rootfs::CompilerShard)
name = artifact_name(rootfs)
artifacts_toml = joinpath(@__DIR__, "..", "Artifacts.toml")
artifacts_toml = String(_artifacts_toml)
hash = artifact_hash(name, artifacts_toml; platform=rootfs.host)
return string(
"julia_binarybuilder_rootfs:",
Expand Down
12 changes: 6 additions & 6 deletions src/Rootfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ end
const ALL_SHARDS = Ref{Union{Vector{CompilerShard},Nothing}}(nothing)
function all_compiler_shards()::Vector{CompilerShard}
if ALL_SHARDS[] === nothing
artifacts_toml = joinpath(dirname(@__DIR__), "Artifacts.toml")
artifacts_toml = String(_artifacts_toml)
artifact_dict = load_artifacts_toml(artifacts_toml)

ALL_SHARDS[] = CompilerShard[]
Expand Down Expand Up @@ -124,8 +124,8 @@ function all_compiler_shards()::Vector{CompilerShard}
end

function shard_source_artifact_hash(cs::CompilerShard)
artifacts_toml = joinpath(dirname(@__DIR__), "Artifacts.toml")
name = artifact_name(cs)
artifacts_toml = String(_artifacts_toml)
hash = artifact_hash(
name,
artifacts_toml;
Expand Down Expand Up @@ -179,7 +179,7 @@ function mount_path(cs::CompilerShard, build_prefix::AbstractString)
return joinpath(build_prefix, ".mounts", artifact_name(cs))
else
name = artifact_name(cs)
artifacts_toml = joinpath(@__DIR__, "..", "Artifacts.toml")
artifacts_toml = String(_artifacts_toml)
hash = artifact_hash(name, artifacts_toml; platform=cs.host)
if hash === nothing
error("Unable to find artifact $(name) within $(artifacts_toml)")
Expand Down Expand Up @@ -254,7 +254,7 @@ function mount(cs::CompilerShard, build_prefix::AbstractString; verbose::Bool =
end

# Ensure this artifact is on-disk; hard to mount it if it's not installed
artifacts_toml = joinpath(dirname(@__DIR__), "Artifacts.toml")
artifacts_toml = String(_artifacts_toml)
ensure_artifact_installed(artifact_name(cs), artifacts_toml; platform=cs.host, verbose=true)

# Easy out if we're not Linux with a UserNSRunner trying to use a .squashfs
Expand Down Expand Up @@ -345,7 +345,7 @@ function macos_sdk_already_installed()
css = all_compiler_shards()
macos_artifact_names = artifact_name.(filter(cs -> cs.target !== nothing && Sys.isapple(cs.target::Platform), css))

artifacts_toml = joinpath(dirname(@__DIR__), "Artifacts.toml")
artifacts_toml = String(_artifacts_toml)
macos_artifact_hashes = artifact_hash.(macos_artifact_names, artifacts_toml; platform=default_host_platform)

# Return `true` if _any_ of these artifacts exist on-disk:
Expand Down Expand Up @@ -913,7 +913,7 @@ happens, you don't need an internet connection to build your precious, precious
binaries.
"""
function download_all_artifacts(; verbose::Bool = false)
artifacts_toml = joinpath(dirname(@__DIR__), "Artifacts.toml")
artifacts_toml = String(_artifacts_toml)
ensure_all_artifacts_installed(
artifacts_toml;
include_lazy=true,
Expand Down