Skip to content

Commit ba4290b

Browse files
committed
update path to Compiler stdlib to a valid one similar to how it is done for other stdlibs (#57274)
Fixes #56865. The Compiler "stdlib" resides in a different location so the current logic didn't handle updating it. (cherry picked from commit 9339dea)
1 parent 8615826 commit ba4290b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

base/methodshow.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,17 @@ function fixup_stdlib_path(path::String)
131131
# The file defining Base.Sys gets included after this file is included so make sure
132132
# this function is valid even in this intermediary state
133133
if isdefined(@__MODULE__, :Sys)
134-
BUILD_STDLIB_PATH = Sys.BUILD_STDLIB_PATH::String
135-
STDLIB = Sys.STDLIB::String
136-
if BUILD_STDLIB_PATH != STDLIB
134+
if Sys.BUILD_STDLIB_PATH != Sys.STDLIB
137135
# BUILD_STDLIB_PATH gets defined in sysinfo.jl
138136
npath = normpath(path)
139-
npath′ = replace(npath, normpath(BUILD_STDLIB_PATH) => normpath(STDLIB))
140-
return npath == npath′ ? path : npath′
137+
npath′ = replace(npath, normpath(Sys.BUILD_STDLIB_PATH) => normpath(Sys.STDLIB))
138+
path = npath == npath′ ? path : npath′
139+
end
140+
if isdefined(@__MODULE__, :Core) && isdefined(Core, :Compiler)
141+
compiler_folder = dirname(String(Base.moduleloc(Core.Compiler).file))
142+
if dirname(path) == compiler_folder
143+
return abspath(Sys.STDLIB, "..", "..", "Compiler", "src", basename(path))
144+
end
141145
end
142146
end
143147
return path

stdlib/InteractiveUtils/test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,10 @@ file, ln = functionloc(versioninfo, Tuple{})
658658
@test isfile(pathof(InteractiveUtils))
659659
@test isdir(pkgdir(InteractiveUtils))
660660

661+
# compiler stdlib path updating
662+
file, ln = functionloc(Core.Compiler.tmeet, Tuple{Int, Float64})
663+
@test isfile(file)
664+
661665
@testset "buildbot path updating" begin
662666
file, ln = functionloc(versioninfo, Tuple{})
663667
@test isfile(file)

0 commit comments

Comments
 (0)