Skip to content

Commit 7831da6

Browse files
gbaralditopolarity
andcommitted
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 a2b0e15 commit 7831da6

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,24 @@ end
104104
mapreduce_empty(::typeof(identity), op::F, T) where {F} = reduce_empty(op, T)
105105
mapreduce_empty(::typeof(abs), op::F, T) where {F} = abs(reduce_empty(op, T))
106106
mapreduce_empty(::typeof(abs2), op::F, T) where {F} = abs2(reduce_empty(op, T))
107+
108+
# this function is not `--trim`-compatible if it resolves to a Varargs{...} specialization
109+
# and since it only has 1-argument methods this happens too often by default (just 2-3 args)
110+
setfield!(typeof(throw_eachindex_mismatch_indices).name, :max_args, Int32(5), :monotonic)
107111
end
108112
@eval Base.Sys begin
109113
__init_build() = nothing
110114
end
115+
# Used for LinearAlgebre ldiv with SVD
116+
for s in [:searchsortedfirst, :searchsortedlast, :searchsorted]
117+
@eval Base.Sort begin
118+
# identical to existing Base def. but specializes on `lt` / `by`
119+
$s(v::AbstractVector, x, o::Ordering) = $s(v,x,firstindex(v),lastindex(v),o)
120+
$s(v::AbstractVector, x;
121+
lt::T=isless, by::F=identity, rev::Union{Bool,Nothing}=nothing, order::Ordering=Forward) where {T,F} =
122+
$s(v,x,ord(lt,by,rev,order))
123+
end
124+
end
111125
@eval Base.GMP begin
112126
function __init__()
113127
try
@@ -159,3 +173,9 @@ end
159173
return Time(h, m, s, ms)
160174
end
161175
end
176+
177+
@eval Base.CoreLogging begin
178+
# Disable logging (TypedCallable is required to support the existing dynamic
179+
# logger interface, but it's not implemented yet)
180+
@inline current_logger_for_env(std_level::LogLevel, group, _module) = nothing
181+
end

0 commit comments

Comments
 (0)