From 157774c038ae303e7604434deab9e1bf2bfd757c Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Wed, 5 Feb 2025 16:45:58 +0100 Subject: [PATCH 1/2] udpate path to Compiler stdlib to a valid one --- base/methodshow.jl | 14 +++++++++----- stdlib/InteractiveUtils/test/runtests.jl | 4 ++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/base/methodshow.jl b/base/methodshow.jl index a2158cb9180e4..a9c32b8066a72 100644 --- a/base/methodshow.jl +++ b/base/methodshow.jl @@ -131,13 +131,17 @@ function fixup_stdlib_path(path::String) # The file defining Base.Sys gets included after this file is included so make sure # this function is valid even in this intermediary state if isdefined(@__MODULE__, :Sys) - BUILD_STDLIB_PATH = Sys.BUILD_STDLIB_PATH::String - STDLIB = Sys.STDLIB::String - if BUILD_STDLIB_PATH != STDLIB + if Sys.BUILD_STDLIB_PATH != Sys.STDLIB # BUILD_STDLIB_PATH gets defined in sysinfo.jl npath = normpath(path) - npath′ = replace(npath, normpath(BUILD_STDLIB_PATH) => normpath(STDLIB)) - return npath == npath′ ? path : npath′ + npath′ = replace(npath, normpath(Sys.BUILD_STDLIB_PATH) => normpath(Sys.STDLIB)) + path = npath == npath′ ? path : npath′ + end + if isdefined(@__MODULE__, :Core) && isdefined(Core, :Compiler) + compiler_folder = dirname(string(methods(Core.Compiler.eval)[1].file)) + if dirname(path) == compiler_folder + return abspath(Sys.STDLIB, "..", "..", "Compiler", "src", basename(path)) + end end end return path diff --git a/stdlib/InteractiveUtils/test/runtests.jl b/stdlib/InteractiveUtils/test/runtests.jl index 0de67fea69dea..739ed5fac9ef2 100644 --- a/stdlib/InteractiveUtils/test/runtests.jl +++ b/stdlib/InteractiveUtils/test/runtests.jl @@ -658,6 +658,10 @@ file, ln = functionloc(versioninfo, Tuple{}) @test isfile(pathof(InteractiveUtils)) @test isdir(pkgdir(InteractiveUtils)) +# compiler stdlib path updating +file, ln = functionloc(Core.Compiler.tmeet, Tuple{Int, Float64}) +@test isfile(file) + @testset "buildbot path updating" begin file, ln = functionloc(versioninfo, Tuple{}) @test isfile(file) From 8e9605862d32d80e44108e34ad6432a5299c62d6 Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Tue, 11 Feb 2025 17:25:47 +0100 Subject: [PATCH 2/2] update to use `moduleloc` --- base/methodshow.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/methodshow.jl b/base/methodshow.jl index a9c32b8066a72..7fdefc9b7311f 100644 --- a/base/methodshow.jl +++ b/base/methodshow.jl @@ -138,7 +138,7 @@ function fixup_stdlib_path(path::String) path = npath == npath′ ? path : npath′ end if isdefined(@__MODULE__, :Core) && isdefined(Core, :Compiler) - compiler_folder = dirname(string(methods(Core.Compiler.eval)[1].file)) + compiler_folder = dirname(String(Base.moduleloc(Core.Compiler).file)) if dirname(path) == compiler_folder return abspath(Sys.STDLIB, "..", "..", "Compiler", "src", basename(path)) end