diff --git a/Compiler/extras/CompilerDevTools/test/testpkg.jl b/Compiler/extras/CompilerDevTools/test/testpkg.jl index b31459219c8dd..f658a48862d2c 100644 --- a/Compiler/extras/CompilerDevTools/test/testpkg.jl +++ b/Compiler/extras/CompilerDevTools/test/testpkg.jl @@ -1,6 +1,5 @@ using Pkg Pkg.activate(dirname(@__DIR__)) do - Pkg.instantiate() include("runtests.jl") end diff --git a/JuliaLowering/Manifest.toml b/JuliaLowering/Manifest.toml new file mode 100644 index 0000000000000..1a5f6860b185c --- /dev/null +++ b/JuliaLowering/Manifest.toml @@ -0,0 +1,16 @@ +# This file is machine-generated - editing it directly is not advised + +julia_version = "1.14.0-DEV" +manifest_format = "2.1" +project_hash = "16f6f8d58c46fe20d68a941bfaddb4590471548a" + +[[deps.JuliaLowering]] +deps = ["JuliaSyntax"] +path = "." +uuid = "f3c80556-a63f-4383-b822-37d64f81a311" +version = "1.0.0-DEV" + +[[deps.JuliaSyntax]] +path = "../JuliaSyntax" +uuid = "70703baa-626e-46a2-a12c-08ffd08c73b4" +version = "2.0.0-DEV" diff --git a/base/loading.jl b/base/loading.jl index 7dfa1e8b1492e..7c44b68f57413 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -470,6 +470,8 @@ function locate_package_env(pkg::PkgId, stopenv::Union{String, Nothing}=nothing) path = manifest_uuid_path(env, pkg) # missing is used as a sentinel to stop looking further down in envs if path === missing + # Before stopping, try stdlib fallback + is_stdlib(pkg) && @goto stdlib_fallback path = nothing @goto done end @@ -481,6 +483,7 @@ function locate_package_env(pkg::PkgId, stopenv::Union{String, Nothing}=nothing) stopenv == env && break end end + @label stdlib_fallback # Allow loading of stdlibs if the name/uuid are given # e.g. if they have been explicitly added to the project/manifest mbypath = manifest_uuid_path(Sys.STDLIB, pkg) diff --git a/contrib/generate_precompile.jl b/contrib/generate_precompile.jl index 293d82334719b..eae2fba8308d3 100644 --- a/contrib/generate_precompile.jl +++ b/contrib/generate_precompile.jl @@ -348,8 +348,8 @@ generate_precompile_statements() = try # Make sure `ansi_enablecursor` is printe uuid = "$pkguuid" """) touch(joinpath(pkgpath, "Manifest.toml")) - tmp_prec = tempname(prec_path) - tmp_proc = tempname(prec_path) + tmp_prec = tempname(prec_path; cleanup=false) + tmp_proc = tempname(prec_path; cleanup=false) s = """ pushfirst!(DEPOT_PATH, $(repr(joinpath(prec_path,"depot")))); Base.PRECOMPILE_TRACE_COMPILE[] = $(repr(tmp_prec)); diff --git a/deps/checksums/Pkg-4f9884fdb867f2c928ba43dc41da5f150aaec4ab.tar.gz/md5 b/deps/checksums/Pkg-4f9884fdb867f2c928ba43dc41da5f150aaec4ab.tar.gz/md5 new file mode 100644 index 0000000000000..45f5692993470 --- /dev/null +++ b/deps/checksums/Pkg-4f9884fdb867f2c928ba43dc41da5f150aaec4ab.tar.gz/md5 @@ -0,0 +1 @@ +cb635b45a66cab302b34bf56367e69d7 diff --git a/deps/checksums/Pkg-4f9884fdb867f2c928ba43dc41da5f150aaec4ab.tar.gz/sha512 b/deps/checksums/Pkg-4f9884fdb867f2c928ba43dc41da5f150aaec4ab.tar.gz/sha512 new file mode 100644 index 0000000000000..c512a594e877d --- /dev/null +++ b/deps/checksums/Pkg-4f9884fdb867f2c928ba43dc41da5f150aaec4ab.tar.gz/sha512 @@ -0,0 +1 @@ +40a0495141d6b220bbc6b4119369cdc86b22498ca6a9c83eba47aec397c4c92afa5776e9043b1545a3111ace0317ca0c2412d0ba51731a7505742f47545a5530 diff --git a/deps/checksums/Pkg-d0be1daf22f15da346e83429b323a82554ef241c.tar.gz/md5 b/deps/checksums/Pkg-d0be1daf22f15da346e83429b323a82554ef241c.tar.gz/md5 deleted file mode 100644 index 51c075ed23ea1..0000000000000 --- a/deps/checksums/Pkg-d0be1daf22f15da346e83429b323a82554ef241c.tar.gz/md5 +++ /dev/null @@ -1 +0,0 @@ -c98454356432e070a718a4b840f8619f diff --git a/deps/checksums/Pkg-d0be1daf22f15da346e83429b323a82554ef241c.tar.gz/sha512 b/deps/checksums/Pkg-d0be1daf22f15da346e83429b323a82554ef241c.tar.gz/sha512 deleted file mode 100644 index 302306e0f43ad..0000000000000 --- a/deps/checksums/Pkg-d0be1daf22f15da346e83429b323a82554ef241c.tar.gz/sha512 +++ /dev/null @@ -1 +0,0 @@ -21fb5ed78bde81a7d2cf9bfe77a2bd52b5e792505cc2c55564366e5283af66f5cf60baf8b0cbb89b690bf424669c6b71220484eee4d65832d27ebe10a0334bb2 diff --git a/deps/jlutilities/documenter/Manifest.toml b/deps/jlutilities/documenter/Manifest.toml index b13b4b48880a4..c52fbb709b087 100644 --- a/deps/jlutilities/documenter/Manifest.toml +++ b/deps/jlutilities/documenter/Manifest.toml @@ -146,7 +146,7 @@ version = "1.0.0" [[deps.LibCURL_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "LibSSH2_jll", "Libdl", "OpenSSL_jll", "Zlib_jll", "Zstd_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "8.16.0+0" +version = "8.17.0+0" [[deps.LibGit2]] deps = ["LibGit2_jll", "NetworkOptions", "Printf", "SHA"] diff --git a/deps/jlutilities/objectfile/Manifest.toml b/deps/jlutilities/objectfile/Manifest.toml new file mode 100644 index 0000000000000..5b1d6d29db365 --- /dev/null +++ b/deps/jlutilities/objectfile/Manifest.toml @@ -0,0 +1,28 @@ +# This file is machine-generated - editing it directly is not advised + +julia_version = "1.14.0-DEV" +manifest_format = "2.1" +project_hash = "23b8253b8eadb7ba5d7489bb56f38819b7150654" + +[[deps.ObjectFile]] +deps = ["Reexport", "StructIO"] +git-tree-sha1 = "22faba70c22d2f03e60fbc61da99c4ebfc3eb9ba" +registries = "General" +uuid = "d8793406-e978-5875-9003-1fc021f44a92" +version = "0.5.0" + +[[deps.Reexport]] +git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" +registries = "General" +uuid = "189a3867-3050-52da-a836-e630ba90ab69" +version = "1.2.2" + +[[deps.StructIO]] +git-tree-sha1 = "c581be48ae1cbf83e899b14c07a807e1787512cc" +registries = "General" +uuid = "53d494c1-5632-5724-8f4c-31dff12d585f" +version = "0.3.1" + +[registries.General] +url = "https://github.com/JuliaRegistries/General.git" +uuid = "23338594-aafe-5451-b93e-139f81909106" diff --git a/deps/jlutilities/objectfile/Project.toml b/deps/jlutilities/objectfile/Project.toml new file mode 100644 index 0000000000000..acdde4be0965e --- /dev/null +++ b/deps/jlutilities/objectfile/Project.toml @@ -0,0 +1,2 @@ +[deps] +ObjectFile = "d8793406-e978-5875-9003-1fc021f44a92" diff --git a/doc/make.jl b/doc/make.jl index 9a2c2146b3d1b..ef9548c22a1ed 100644 --- a/doc/make.jl +++ b/doc/make.jl @@ -228,6 +228,15 @@ BaseDocs = [ StdlibDocs = [stdlib.targetfile for stdlib in STDLIB_DOCS] +# HACK: get nicer sorting here, even though we don't have the header +# of the .md files at hand. +sort!(StdlibDocs, by=function(x) + x = replace(x, "stdlib/" => "") + startswith(x, "Libdl") && return lowercase("Dynamic Linker") + startswith(x, "Test") && return lowercase("Unit Testing") + return lowercase(x) +end) + DevDocs = [ "Documentation of Julia's Internals" => [ "devdocs/init.md", diff --git a/doc/src/index.md b/doc/src/index.md index 7d781f25b4235..dea0c11dc1c8b 100644 --- a/doc/src/index.md +++ b/doc/src/index.md @@ -32,18 +32,6 @@ Markdown.parse(""" """) ``` -## [Important Links](@id man-important-links) - -Below is a non-exhaustive list of links that will be useful as you learn and use the Julia programming language. - -- [Julia Homepage](https://julialang.org) -- [Install Julia](https://julialang.org/install/) -- [Discussion forum](https://discourse.julialang.org) -- [Julia YouTube](https://www.youtube.com/user/JuliaLanguage) -- [Find Julia Packages](https://julialang.org/packages/) -- [Learning Resources](https://julialang.org/learning/) -- [Read and write blogs on Julia](https://forem.julialang.org) - ## [Introduction](@id man-introduction) Scientific computing has traditionally required the highest performance, yet domain experts have @@ -127,39 +115,13 @@ language. In addition to the above, some advantages of Julia over comparable sys * Powerful shell-like capabilities for managing other processes * Lisp-like macros and other metaprogramming facilities -## [Julia Standard Modules and the Standard Library](@id man-standard-modules-stdlib) - -The Julia runtime comes with [standard modules](@ref standard-modules), -which are essential namespaces that are usually loaded automatically. - -```@docs; canonical=false -Core -Base -``` - -Julia's `Base` module contains various [useful submodules](@ref base-submodules). - -### [The Standard Library](@id man-stdlib) - -The Julia standard library contains additional, commonly used packages that are installed alongside the Julia runtime by default. -To use a standard library package, it is first necessary to load the package with a [`using`](@ref) or [`import`](@ref) statement. -Links to available standard library packages are provided below, -and may also be found in the website sidebar. -Their source code is available in the `Sys.STDLIB` directory of a Julia installation. - -```@eval -import Markdown -list = sort(filter(x -> match(r"_jll$", x) === nothing, readdir(Sys.STDLIB))) -Markdown.parse(join("- [`" .* list .* "`](stdlib/" .* list .* ".html)", "\n")) -``` +## [Important Links](@id man-important-links) -Julia also provides various standard, pre-built binary libraries -of established software that is written in other languages. -By convention, these packages have names that end with `_jll`. -The [`using`](@ref) statement can load symbol names from these binary libraries: +A non-exhaustive list of links that will be useful as you learn and use the Julia programming language: -```@eval -import Markdown -list = sort(filter(x -> match(r"_jll$", x) !== nothing, readdir(Sys.STDLIB))) -Markdown.parse(join("- [`" .* list .* "`](stdlib/" .* list .* ".html)", "\n")) -``` +- [Julia Homepage](https://julialang.org) +- [Install Julia](https://julialang.org/install/) +- [Discussion forum](https://discourse.julialang.org) +- [Julia YouTube](https://www.youtube.com/user/JuliaLanguage) +- [Find Julia Packages](https://julialang.org/packages/) +- [Learning Resources](https://julialang.org/learning/) diff --git a/src/llvm-multiversioning.cpp b/src/llvm-multiversioning.cpp index e9276526ef263..5387ae1ed93ba 100644 --- a/src/llvm-multiversioning.cpp +++ b/src/llvm-multiversioning.cpp @@ -378,6 +378,8 @@ struct CloneCtx { void clone_partial(Group &grp, Target &tgt); uint32_t get_func_id(Function *F) const; std::pair get_reloc_slot(Function *F) const; + + Function *create_trampoline(Function *F, GlobalVariable *slot, bool autoinit=false); void rewrite_alias(GlobalAlias *alias, Function* F); MDNode *tbaa_const; @@ -493,6 +495,53 @@ void CloneCtx::prepare_vmap(ValueToValueMapTy &vmap) } } +Function *CloneCtx::create_trampoline(Function *F, GlobalVariable *slot, bool autoinit) +{ + Function *trampoline = + Function::Create(F->getFunctionType(), GlobalValue::ExternalLinkage, "", &M); + + trampoline->copyAttributesFrom(F); + trampoline->setVisibility(GlobalValue::HiddenVisibility); + trampoline->setDSOLocal(true); + + // drop multiversioning attributes + trampoline->removeFnAttr("julia.mv.reloc"); + trampoline->removeFnAttr("julia.mv.clones"); + + auto BB = BasicBlock::Create(F->getContext(), "top", trampoline); + IRBuilder<> irbuilder(BB); + + if (autoinit) { + irbuilder.CreateCall(F->getParent()->getOrInsertFunction( + XSTR(jl_autoinit_and_adopt_thread), + PointerType::get(F->getContext(), 0) + )); + } + + auto ptr = irbuilder.CreateLoad(F->getType(), slot); + ptr->setMetadata(llvm::LLVMContext::MD_tbaa, tbaa_const); + ptr->setMetadata(llvm::LLVMContext::MD_invariant_load, MDNode::get(F->getContext(), None)); + + SmallVector Args; + for (auto &arg : trampoline->args()) + Args.push_back(&arg); + auto call = irbuilder.CreateCall(F->getFunctionType(), ptr, ArrayRef(Args)); + if (F->isVarArg()) { + assert(!TT.isARM() && !TT.isPPC() && "musttail not supported on ARM/PPC!"); + call->setTailCallKind(CallInst::TCK_MustTail); + } else { + call->setTailCallKind(CallInst::TCK_Tail); + + } + + if (F->getReturnType() == Type::getVoidTy(F->getContext())) + irbuilder.CreateRetVoid(); + else + irbuilder.CreateRet(call); + + return trampoline; +} + void CloneCtx::prepare_slots() { for (auto &F : orig_funcs) { @@ -507,7 +556,12 @@ void CloneCtx::prepare_slots() else { auto id = get_func_id(F); const_relocs[id] = GV; - GV->setInitializer(Constant::getNullValue(F->getType())); + + // Initialize with a single-use trampoline that calls `jl_autoinit_and_adopt_thread`, + // so that auto-initialization works with multi-versioned entrypoints. + Function *trampoline = create_trampoline(F, GV, /* autoinit */ true); + trampoline->setName(F->getName() + ".autoinit_trampoline"); + GV->setInitializer(trampoline); } } } @@ -665,45 +719,21 @@ void CloneCtx::rewrite_alias(GlobalAlias *alias, Function *F) { assert(!is_vector(F->getFunctionType())); - Function *trampoline = - Function::Create(F->getFunctionType(), alias->getLinkage(), "", &M); - trampoline->copyAttributesFrom(F); - trampoline->takeName(alias); - trampoline->setVisibility(alias->getVisibility()); - trampoline->setDSOLocal(alias->isDSOLocal()); - // drop multiversioning attributes, add alias attribute for testing purposes - trampoline->removeFnAttr("julia.mv.reloc"); - trampoline->removeFnAttr("julia.mv.clones"); - trampoline->addFnAttr("julia.mv.alias"); - trampoline->setDLLStorageClass(alias->getDLLStorageClass()); - alias->eraseFromParent(); - uint32_t id; GlobalVariable *slot; std::tie(id, slot) = get_reloc_slot(F); + assert(slot); - auto BB = BasicBlock::Create(F->getContext(), "top", trampoline); - IRBuilder<> irbuilder(BB); + Function *trampoline = create_trampoline(F, slot, /* autoinit */ false); + trampoline->addFnAttr("julia.mv.alias"); // add alias attribute for testing purposes - auto ptr = irbuilder.CreateLoad(F->getType(), slot); - ptr->setMetadata(llvm::LLVMContext::MD_tbaa, tbaa_const); - ptr->setMetadata(llvm::LLVMContext::MD_invariant_load, MDNode::get(F->getContext(), None)); - - SmallVector Args; - for (auto &arg : trampoline->args()) - Args.push_back(&arg); - auto call = irbuilder.CreateCall(F->getFunctionType(), ptr, ArrayRef(Args)); - if (F->isVarArg()) { - assert(!TT.isARM() && !TT.isPPC() && "musttail not supported on ARM/PPC!"); - call->setTailCallKind(CallInst::TCK_MustTail); - } else { - call->setTailCallKind(CallInst::TCK_Tail); - } + trampoline->takeName(alias); + trampoline->setLinkage(alias->getLinkage()); + trampoline->setVisibility(alias->getVisibility()); + trampoline->setDSOLocal(alias->isDSOLocal()); + trampoline->setDLLStorageClass(alias->getDLLStorageClass()); - if (F->getReturnType() == Type::getVoidTy(F->getContext())) - irbuilder.CreateRetVoid(); - else - irbuilder.CreateRet(call); + alias->eraseFromParent(); } void CloneCtx::fix_gv_uses() diff --git a/stdlib/Pkg.version b/stdlib/Pkg.version index eecee7a5cb6f2..2970f3583bdf3 100644 --- a/stdlib/Pkg.version +++ b/stdlib/Pkg.version @@ -1,4 +1,4 @@ PKG_BRANCH = release-1.13 -PKG_SHA1 = d0be1daf22f15da346e83429b323a82554ef241c +PKG_SHA1 = 4f9884fdb867f2c928ba43dc41da5f150aaec4ab PKG_GIT_URL := https://github.com/JuliaLang/Pkg.jl.git PKG_TAR_URL = https://api.github.com/repos/JuliaLang/Pkg.jl/tarball/$1 diff --git a/test/llvmpasses/multiversioning-clone-only.ll b/test/llvmpasses/multiversioning-clone-only.ll index 00f0db0aa1e91..c4f5257a59988 100644 --- a/test/llvmpasses/multiversioning-clone-only.ll +++ b/test/llvmpasses/multiversioning-clone-only.ll @@ -7,7 +7,7 @@ ; CHECK: @jl_fvar_idxs = hidden constant [1 x i32] zeroinitializer ; CHECK: @jl_gvar_idxs = hidden constant [0 x i32] zeroinitializer ; OPAQUE: @subtarget_cloned_gv = hidden global ptr null -; OPAQUE: @subtarget_cloned.reloc_slot = hidden global ptr null +; OPAQUE: @subtarget_cloned.reloc_slot = hidden global ptr @subtarget_cloned.autoinit_trampoline ; CHECK: @jl_fvar_count = hidden constant i64 1 ; OPAQUE: @jl_fvar_ptrs = hidden global [1 x ptr] [ptr @subtarget_cloned] ; CHECK: @jl_clone_slots = hidden constant [5 x i32] @@ -57,7 +57,7 @@ define noundef i32 @subtarget_cloned(i32 noundef %0) #2 { ; COM: should fixup this callsite since 2 is cloned for a subtarget ; CHECK: define{{.*}}@call_subtarget_cloned({{.*}}#[[CALL_SUBTARGET_CLONED_DEFAULT_ATTRS:[0-9]+]] ; CHECK-NEXT: [[FUNC_PTR:%[0-9]+]] = load{{.*}}@subtarget_cloned.reloc_slot{{.*}}!tbaa ![[TBAA_CONST_METADATA:[0-9]+]], !invariant.load -; CHECK-NEXT: call{{.*}}[[FUNC_PTR]] +; CHECK-NEXT: call{{.*}}[[FUNC_PTR]]({{.*}}) ; CHECK: ret i32 define noundef i32 @call_subtarget_cloned(i32 noundef %0) #3 { %2 = call noundef i32 @subtarget_cloned(i32 noundef %0) @@ -66,13 +66,23 @@ define noundef i32 @call_subtarget_cloned(i32 noundef %0) #3 { ; CHECK: define{{.*}}@call_subtarget_cloned_but_not_cloned({{.*}}#[[BORING_DEFAULT_ATTRS]] ; CHECK-NEXT: [[FUNC_PTR:%[0-9]+]] = load{{.*}}@subtarget_cloned.reloc_slot{{.*}}!tbaa ![[TBAA_CONST_METADATA]], !invariant.load -; CHECK-NEXT: call{{.*}}[[FUNC_PTR]] +; CHECK-NEXT: call{{.*}}[[FUNC_PTR]]({{.*}}) ; CHECK: ret i32 define noundef i32 @call_subtarget_cloned_but_not_cloned(i32 noundef %0) #0 { %2 = call noundef i32 @subtarget_cloned(i32 noundef %0) ret i32 %2 } +; COM: check that the autoinit trampoline is generated correctly +; CHECK: define{{.*}}@subtarget_cloned.autoinit_trampoline({{.*}} +; CHECK-NEXT: top: +; CHECK-NEXT: call ptr @ijl_autoinit_and_adopt_thread() +; CHECK-NEXT: [[FUNC_PTR:%[0-9]+]] = load ptr, ptr @subtarget_cloned.reloc_slot{{.*}}!tbaa ![[TBAA_CONST_METADATA]], !invariant.load +; CHECK-NEXT: call{{.*}}[[FUNC_PTR]]({{.*}}) +; CHECK: ret i32 + +declare ptr @ijl_autoinit_and_adopt_thread() + ; CHECK: define{{.*}}@boring.1({{.*}}#[[BORING_CLONEALL_ATTRS:[0-9]+]] ; CHECK-NEXT: ret i32 %0 @@ -106,10 +116,10 @@ define noundef i32 @call_subtarget_cloned_but_not_cloned(i32 noundef %0) #0 { ; CHECK-NOT: @subtarget_cloned_but_not_cloned.2 ; COM: check for alias being rewritten to a function trampoline -; CHECK: define{{.*}}@subtarget_cloned_aliased{{.*}}#[[SUBTARGET_ALIASED_ATTRS:[0-9]+]] +; CHECK: define{{.*}}@subtarget_cloned_aliased{{[^.]*}}#[[SUBTARGET_ALIASED_ATTRS:[0-9]+]] ; CHECK-NOT: } ; CHECK: [[FUNC_PTR:%[0-9]+]] = load{{.*}}@subtarget_cloned.reloc_slot{{.*}}!tbaa ![[TBAA_CONST_METADATA]], !invariant.load -; CHECK-NEXT: call{{.*}}[[FUNC_PTR]] +; CHECK-NEXT: call{{.*}}[[FUNC_PTR]]({{.*}}) ; CHECK: ret i32 ; CHECK: attributes #[[BORING_DEFAULT_ATTRS]] diff --git a/test/llvmpasses/multiversioning-x86.ll b/test/llvmpasses/multiversioning-x86.ll index ff4a8abba5252..e2918d0c20eec 100644 --- a/test/llvmpasses/multiversioning-x86.ll +++ b/test/llvmpasses/multiversioning-x86.ll @@ -11,7 +11,7 @@ ; OPAQUE: @jl_gvar_ptrs = global [0 x ptr] zeroinitializer, align 8 ; CHECK: @jl_fvar_idxs = hidden constant [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4], align 8 ; CHECK: @jl_gvar_idxs = hidden constant [0 x i32] zeroinitializer, align 8 -; OPAQUE: @simd_test.reloc_slot = hidden global ptr null +; OPAQUE: @simd_test.reloc_slot = hidden global ptr @simd_test.autoinit_trampoline ; OPAQUE: @jl_fvar_ptrs = hidden global [5 x ptr] [ptr @boring, ptr @fastmath_test, ptr @loop_test, ptr @simd_test, ptr @simd_test_call] ; OPAQUE: @jl_clone_slots = hidden constant [3 x i32] [i32 1, i32 3, i32 trunc (i64 sub (i64 ptrtoint (ptr @simd_test.reloc_slot to i64), i64 ptrtoint (ptr @jl_clone_slots to i64)) to i32)] ; CHECK: @jl_clone_idxs = hidden constant [10 x i32] [i32 -2147483647, i32 3, i32 -2147483647, i32 3, i32 4, i32 1, i32 1, i32 2, i32 -2147483645, i32 4] diff --git a/test/loading.jl b/test/loading.jl index d13bc4ea648f1..4baf979cf128a 100644 --- a/test/loading.jl +++ b/test/loading.jl @@ -1533,12 +1533,31 @@ end end @testset "Fallback for stdlib deps if manifest deps aren't found" begin + s = Sys.iswindows() ? ';' : ':' mktempdir() do depot # This manifest has a LibGit2 entry that is missing LibGit2_jll, which should be # handled by falling back to the stdlib Project.toml for dependency truth. - badmanifest_test_dir = joinpath(@__DIR__, "project", "deps", "BadStdlibDeps.jl") + badmanifest_test_dir = joinpath(@__DIR__, "project", "deps", "BadStdlibDeps") @test success(addenv( `$(Base.julia_cmd()) --project=$badmanifest_test_dir --startup-file=no -e 'using LibGit2'`, + "JULIA_DEPOT_PATH" => string(depot * Base.Filesystem.pathsep(), s), + )) + end + mktempdir() do depot + # This manifest has a LibGit2 entry that has a LibGit2_jll with a git-tree-hash1 + # which simulates an old manifest where LibGit2_jll was not a stdlib + badmanifest_test_dir2 = joinpath(@__DIR__, "project", "deps", "BadStdlibDeps2") + @test success(addenv( + `$(Base.julia_cmd()) --project=$badmanifest_test_dir2 --startup-file=no -e 'using LibGit2'`, + "JULIA_DEPOT_PATH" => string(depot * Base.Filesystem.pathsep(), s), + )) + end + mktempdir() do depot + # This manifest has a LibGit2 entry that has a LibGit2_jll with a git-tree-hash1 + # which simulates an old manifest where LibGit2_jll was not a stdlib + badmanifest_test_dir2 = joinpath(@__DIR__, "project", "deps", "BadStdlibDeps2") + @test success(addenv( + `$(Base.julia_cmd()) --project=$badmanifest_test_dir2 --startup-file=no -e 'using LibGit2'`, "JULIA_DEPOT_PATH" => depot * Base.Filesystem.pathsep(), )) end diff --git a/test/project/deps/BadStdlibDeps2/Manifest.toml b/test/project/deps/BadStdlibDeps2/Manifest.toml new file mode 100644 index 0000000000000..988efc8da56f3 --- /dev/null +++ b/test/project/deps/BadStdlibDeps2/Manifest.toml @@ -0,0 +1,54 @@ +# This file is machine-generated - editing it directly is not advised + +julia_version = "1.12.0-DEV" +manifest_format = "2.0" +project_hash = "dc9d33b0ee13d9466bdb75b8d375808a534a79ec" + +[[deps.Artifacts]] +uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" +version = "1.11.0" + +[[deps.LibGit2]] +deps = ["NetworkOptions", "Printf", "SHA", "LibGit2_jll"] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +version = "1.11.0" + +# This is an stdlib but intentionally has a git-tree-sha1 because +# we are emulating that the manifest comes from a version where +# LibGit2_jll was not an stdlib +[[deps.LibGit2_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] +git-tree-sha1 = "1111111111111111111111111111111111111111" +uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" +version = "1.8.0+0" + +[[deps.LibSSH2_jll]] +deps = ["Artifacts", "Libdl", "MbedTLS_jll"] +uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" +version = "1.11.0+1" + +[[deps.Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +version = "1.11.0" + +[[deps.MbedTLS_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" +version = "2.28.6+1" + +[[deps.NetworkOptions]] +uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" +version = "1.2.0" + +[[deps.Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" +version = "1.11.0" + +[[deps.SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +version = "0.7.0" + +[[deps.Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +version = "1.11.0" diff --git a/test/project/deps/BadStdlibDeps2/Project.toml b/test/project/deps/BadStdlibDeps2/Project.toml new file mode 100644 index 0000000000000..223889185ea15 --- /dev/null +++ b/test/project/deps/BadStdlibDeps2/Project.toml @@ -0,0 +1,2 @@ +[deps] +LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" diff --git a/test/runtests.jl b/test/runtests.jl index b7e35e6e14662..4c847884939ac 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -28,6 +28,7 @@ end const rmwait_timeout = running_under_rr() ? 300 : 30 +ENV["JULIA_TEST_BUILDROOT"] = buildroot if use_revise # First put this at the top of the DEPOT PATH to install revise if necessary. # Once it's loaded, we swizzle it to the end, to avoid confusing any tests. diff --git a/test/stdlib_dependencies.jl b/test/stdlib_dependencies.jl index 7e24834b8c442..f034c650c75a0 100644 --- a/test/stdlib_dependencies.jl +++ b/test/stdlib_dependencies.jl @@ -1,14 +1,37 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license using Libdl -using Pkg using Test -prev_env = Base.active_project() -Pkg.activate(temp=true) -Pkg.add(Pkg.PackageSpec(name="ObjectFile", uuid="d8793406-e978-5875-9003-1fc021f44a92", version="0.4")) -using ObjectFile -try +# Load ObjectFile.jl from the vendored jlutilities depot +buildroot = get(ENV, "JULIA_TEST_BUILDROOT", joinpath(@__DIR__, "..")) +depspath = joinpath(buildroot, "deps", "jlutilities") +if ispath(depspath) + depspath = realpath(depspath) + # With a source-tree use the vendored depot + pushfirst!(DEPOT_PATH, joinpath(depspath, "depot")) + using Pkg + old_active_project = Base.active_project() + Base.redirect_stdout(devnull) do + Base.redirect_stderr(devnull) do + Pkg.activate(realpath(joinpath(@__DIR__, "..", "deps", "jlutilities", "objectfile"))) + Pkg.instantiate() + end + end + using ObjectFile + popfirst!(DEPOT_PATH) + Base.set_active_project(old_active_project) +else + # Without a source-tree - expect that the user has installed it for us - warn otherwise + ObjectFile_pkgid = Base.PkgId(Base.UUID("d8793406-e978-5875-9003-1fc021f44a92"), "ObjectFile") + if Base.locate_package(ObjectFile_pkgid) !== nothing + @eval using ObjectFile + end +end + +if !@isdefined(ObjectFile) + @warn("ObjectFile.jl not available; skipping stdlib JLL dependency tests") +else strip_soversion(lib::AbstractString) = Base.BinaryPlatforms.parse_dl_name_version(lib)[1] function get_deps_objectfile_macos(lib_path::String) @@ -249,8 +272,8 @@ try # This is a manually-managed special case if stdlib_name == "libblastrampoline_jll" && - prop_name == :libblastrampoline && - extraneous_deps in (["libopenblas64_"], ["libopenblas"]) + prop_name == :libblastrampoline && + extraneous_deps in (["libopenblas64_"], ["libopenblas"]) deps_mismatch = false end @@ -315,12 +338,4 @@ try end end end - -finally - if prev_env !== nothing - Pkg.activate(prev_env) - else - # If no previous environment, activate the default one - Pkg.activate() - end end