Skip to content

Commit cd44680

Browse files
gbaralditopolarity
andauthored
Fix printing of errors in juliac + searchsorted functions for LinearAlgebra (#59299)
We may want to move this changes to base proper. @LilithHafner should sort functions just always specialize on the `by`/`lt` params? It currently sometimes relies on inlining for good performance --------- Co-authored-by: Cody Tapscott <[email protected]> Co-authored-by: Cody Tapscott <[email protected]>
1 parent 2d9ee0a commit cd44680

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

contrib/juliac/juliac-buildscript.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Initialize some things not usually initialized when output is requested
66
Sys.__init__()
7+
Base.reinit_stdio()
78
Base.init_depot_path()
89
Base.init_load_path()
910
Base.init_active_project()

contrib/juliac/juliac-trim-base.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,23 @@ end
7878
end
7979
end
8080
show_type_name(io::IO, tn::Core.TypeName) = print(io, tn.name)
81+
# this function is not `--trim`-compatible if it resolves to a Varargs{...} specialization
82+
# and since it only has 1-argument methods this happens too often by default (just 2-3 args)
83+
setfield!(typeof(throw_eachindex_mismatch_indices).name, :max_args, Int32(5), :monotonic)
8184
end
8285
@eval Base.Sys begin
8386
__init_build() = nothing # VersionNumber parsing is not supported yet
8487
end
88+
# Used for LinearAlgebre ldiv with SVD
89+
for s in [:searchsortedfirst, :searchsortedlast, :searchsorted]
90+
@eval Base.Sort begin
91+
# identical to existing Base def. but specializes on `lt` / `by`
92+
$s(v::AbstractVector, x, o::Ordering) = $s(v,x,firstindex(v),lastindex(v),o)
93+
$s(v::AbstractVector, x;
94+
lt::T=isless, by::F=identity, rev::Union{Bool,Nothing}=nothing, order::Ordering=Forward) where {T,F} =
95+
$s(v,x,ord(lt,by,rev,order))
96+
end
97+
end
8598
@eval Base.GMP begin
8699
function __init__() # VersionNumber parsing is not supported yet
87100
try
@@ -109,3 +122,9 @@ end
109122
end
110123
end
111124
end
125+
126+
@eval Base.CoreLogging begin
127+
# Disable logging (TypedCallable is required to support the existing dynamic
128+
# logger interface, but it's not implemented yet)
129+
@inline current_logger_for_env(std_level::LogLevel, group, _module) = nothing
130+
end

0 commit comments

Comments
 (0)